starpu_perfmodel_plot.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2013 Université de Bordeaux 1
  4. * Copyright (C) 2011, 2012, 2013 Centre National de la Recherche Scientifique
  5. * Copyright (C) 2011 Télécom-SudParis
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #include <config.h>
  19. #include <assert.h>
  20. #include <unistd.h>
  21. #include <stdio.h>
  22. #include <sys/stat.h>
  23. #include <limits.h>
  24. #ifdef STARPU_USE_FXT
  25. #include <common/fxt.h>
  26. #endif
  27. #include <common/utils.h>
  28. #include <starpu.h>
  29. #include <core/perfmodel/perfmodel.h> // we need to browse the list associated to history-based models
  30. #include <core/workers.h>
  31. #ifdef __MINGW32__
  32. #include <windows.h>
  33. #endif
  34. #define PROGNAME "starpu_perfmodel_plot"
  35. /* display all available models */
  36. static int list = 0;
  37. /* what kernel ? */
  38. static char *symbol = NULL;
  39. /* which architecture ? (NULL = all)*/
  40. static char *archname = NULL;
  41. /* Unless a FxT file is specified, we just display the model */
  42. static int no_fxt_file = 1;
  43. static int gflops = 0;
  44. #ifdef STARPU_USE_FXT
  45. static struct starpu_fxt_codelet_event *dumped_codelets;
  46. static struct starpu_fxt_options options;
  47. #endif
  48. #ifdef STARPU_USE_FXT
  49. static int **archtype_is_found[STARPU_NARCH];
  50. static char data_file_name[256];
  51. #endif
  52. static char avg_file_name[256];
  53. static char gnuplot_file_name[256];
  54. static void usage()
  55. {
  56. fprintf(stderr, "Draw a graph corresponding to the execution time of a \
  57. given perfmodel\n");
  58. fprintf(stderr, "Usage: %s [ options ]\n", PROGNAME);
  59. fprintf(stderr, "\n");
  60. fprintf(stderr, "One must specify a symbol with the -s option or use -l\n");
  61. fprintf(stderr, "Options:\n");
  62. fprintf(stderr, " -l display all available models\n");
  63. fprintf(stderr, " -s <symbol> specify the symbol\n");
  64. fprintf(stderr, " -f draw GFlops instead of time\n");
  65. fprintf(stderr, " -i <Fxt files> input FxT files generated by StarPU\n");
  66. fprintf(stderr, " -a <arch> specify the architecture (e.g. cpu, cpu:x, cuda, cuda_d, opencl, opencl_d)\n");
  67. fprintf(stderr, " -h, --help display this help and exit\n");
  68. fprintf(stderr, " -v, --version output version information and exit\n\n");
  69. fprintf(stderr, "Report bugs to <%s>.", PACKAGE_BUGREPORT);
  70. fprintf(stderr, "\n");
  71. }
  72. static void parse_args(int argc, char **argv)
  73. {
  74. #ifdef STARPU_USE_FXT
  75. /* Default options */
  76. starpu_fxt_options_init(&options);
  77. options.out_paje_path = NULL;
  78. options.activity_path = NULL;
  79. options.distrib_time_path = NULL;
  80. options.dag_path = NULL;
  81. options.dumped_codelets = &dumped_codelets;
  82. #endif
  83. /* We want to support arguments such as "-i trace_*" */
  84. unsigned reading_input_filenames = 0;
  85. int i;
  86. for (i = 1; i < argc; i++)
  87. {
  88. if (strcmp(argv[i], "-s") == 0)
  89. {
  90. symbol = argv[++i];
  91. continue;
  92. }
  93. if (strcmp(argv[i], "-i") == 0)
  94. {
  95. reading_input_filenames = 1;
  96. #ifdef STARPU_USE_FXT
  97. options.filenames[options.ninputfiles++] = argv[++i];
  98. no_fxt_file = 0;
  99. #else
  100. fprintf(stderr, "Warning: FxT support was not enabled in StarPU: FxT traces will thus be ignored!\n");
  101. #endif
  102. continue;
  103. }
  104. if (strcmp(argv[i], "-l") == 0)
  105. {
  106. list = 1;
  107. continue;
  108. }
  109. if (strcmp(argv[i], "-f") == 0)
  110. {
  111. gflops = 1;
  112. continue;
  113. }
  114. if (strcmp(argv[i], "-a") == 0)
  115. {
  116. archname = argv[++i];
  117. continue;
  118. }
  119. if (strcmp(argv[i], "-h") == 0 ||
  120. strcmp(argv[i], "--help") == 0)
  121. {
  122. usage();
  123. exit(EXIT_SUCCESS);
  124. }
  125. if (strcmp(argv[i], "-v") == 0 ||
  126. strcmp(argv[i], "--version") == 0)
  127. {
  128. fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
  129. exit(EXIT_SUCCESS);
  130. }
  131. /* If the reading_input_filenames flag is set, and that the
  132. * argument does not match an option, we assume this may be
  133. * another filename */
  134. if (reading_input_filenames)
  135. {
  136. #ifdef STARPU_USE_FXT
  137. options.filenames[options.ninputfiles++] = argv[i];
  138. #endif
  139. continue;
  140. }
  141. }
  142. if (!symbol && !list)
  143. {
  144. fprintf(stderr, "Incorrect usage, aborting\n");
  145. usage();
  146. exit(-1);
  147. }
  148. }
  149. static void print_comma(FILE *gnuplot_file, int *first)
  150. {
  151. if (*first)
  152. {
  153. *first = 0;
  154. }
  155. else
  156. {
  157. fprintf(gnuplot_file, ",\\\n\t");
  158. }
  159. }
  160. static void display_perf_model(FILE *gnuplot_file, struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, int *first, unsigned nimpl)
  161. {
  162. char arch_name[256];
  163. starpu_perfmodel_get_arch_name(arch, arch_name, 256, nimpl);
  164. struct starpu_perfmodel_per_arch *arch_model =
  165. &model->per_arch[arch->type][arch->devid][arch->ncore][nimpl];
  166. if (arch_model->regression.valid || arch_model->regression.nl_valid)
  167. fprintf(stderr,"Arch: %s\n", arch_name);
  168. #ifdef STARPU_USE_FXT
  169. if (!gflops && !no_fxt_file && archtype_is_found[arch] && nimpl == 0)
  170. {
  171. print_comma(gnuplot_file, first);
  172. fprintf(gnuplot_file, "\"< grep -w \\^%d %s\" using 2:3 title \"Profiling %s\"", arch, data_file_name, arch_name);
  173. }
  174. #endif
  175. /* Only display the regression model if we could actually build a model */
  176. if (!gflops && arch_model->regression.valid && !arch_model->regression.nl_valid)
  177. {
  178. print_comma(gnuplot_file, first);
  179. fprintf(stderr, "\tLinear: y = alpha size ^ beta\n");
  180. fprintf(stderr, "\t\talpha = %e\n", arch_model->regression.alpha * 0.001);
  181. fprintf(stderr, "\t\tbeta = %e\n", arch_model->regression.beta);
  182. fprintf(gnuplot_file, "0.001 * %f * x ** %f title \"Linear Regression %s\"",
  183. arch_model->regression.alpha, arch_model->regression.beta, arch_name);
  184. }
  185. if (!gflops && arch_model->regression.nl_valid)
  186. {
  187. print_comma(gnuplot_file, first);
  188. fprintf(stderr, "\tNon-Linear: y = a size ^b + c\n");
  189. fprintf(stderr, "\t\ta = %e\n", arch_model->regression.a * 0.001);
  190. fprintf(stderr, "\t\tb = %e\n", arch_model->regression.b);
  191. fprintf(stderr, "\t\tc = %e\n", arch_model->regression.c * 0.001);
  192. fprintf(gnuplot_file, "0.001 * %f * x ** %f + 0.001 * %f title \"Non-Linear Regression %s\"",
  193. arch_model->regression.a, arch_model->regression.b, arch_model->regression.c, arch_name);
  194. }
  195. }
  196. static void display_history_based_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, enum starpu_worker_archtype* type, int* devid, int* ncore, int *first)
  197. {
  198. char *command;
  199. FILE *datafile;
  200. struct starpu_perfmodel_history_list *ptr;
  201. char arch_name[32];
  202. int col;
  203. size_t len;
  204. unsigned long last, minimum = 0;
  205. len = 10 + strlen(avg_file_name) + 1;
  206. command = (char *) malloc(len);
  207. datafile = fopen(avg_file_name, "w");
  208. free(command);
  209. col = 2;
  210. unsigned implid;
  211. unsigned archmin, archmax, devmin, devmax, coremin, coremax;
  212. if(type != NULL)
  213. {
  214. archmin = *type;
  215. archmax = *type +1;
  216. if(devid != NULL)
  217. {
  218. devmin = *devid;
  219. devmax = *devid +1;
  220. if(ncore != NULL)
  221. {
  222. coremin = *ncore;
  223. coremax = *ncore +1;
  224. }
  225. else
  226. {
  227. coremin = 0;
  228. coremax = 0;
  229. }
  230. }
  231. else
  232. {
  233. devmin = 0;
  234. devmax = 0;
  235. coremin = 0;
  236. coremax = 0;
  237. }
  238. }
  239. else
  240. {
  241. archmin = 0;
  242. archmax = STARPU_NARCH;
  243. devmin = 0;
  244. devmax = 0;
  245. coremin = 0;
  246. coremax = 0;
  247. }
  248. struct starpu_perfmodel_arch arch;
  249. unsigned archtype, dev, core;
  250. for (archtype = archmin; archtype < archmax; archtype++)
  251. {
  252. arch.type = archtype;
  253. if(model->per_arch[archtype]!=NULL)
  254. {
  255. for(dev = devmin; model->per_arch[archtype][dev] != NULL && (devmax == 0 || dev < devmax);dev++)
  256. {
  257. arch.devid = dev;
  258. for(core = coremin; model->per_arch[archtype][dev][core] != NULL && (coremax == 0 || core < coremax); core++)
  259. {
  260. arch.ncore = core;
  261. for (implid = 0; implid < STARPU_MAXIMPLEMENTATIONS; implid++)
  262. {
  263. struct starpu_perfmodel_per_arch *arch_model = &model->per_arch[archtype][dev][core][implid];
  264. starpu_perfmodel_get_arch_name(&arch, arch_name, 32, implid);
  265. //ptrs[arch-arch1][implid] = ptr[arch-arch1][implid] = arch_model->list;
  266. if (arch_model->list)
  267. {
  268. print_comma(gnuplot_file, first);
  269. fprintf(gnuplot_file, "\"%s\" using 1:%d:%d with errorlines title \"Average %s\"", avg_file_name, col, col+1, arch_name);
  270. col += 2;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. /* Dump entries in size order */
  278. while (1)
  279. {
  280. last = minimum;
  281. minimum = ULONG_MAX;
  282. /* Get the next minimum */
  283. for (archtype = archmin; archtype < archmax; archtype++)
  284. {
  285. if(model->per_arch[archtype]!=NULL)
  286. {
  287. for(dev = devmin; model->per_arch[archtype][dev] != NULL && (devmax == 0 || dev < devmax);dev++)
  288. {
  289. for(core = coremin; model->per_arch[archtype][dev][core] != NULL && (coremax == 0 || core < coremax); core++)
  290. {
  291. for (implid = 0; implid < STARPU_MAXIMPLEMENTATIONS; implid++)
  292. {
  293. struct starpu_perfmodel_per_arch *arch_model = &model->per_arch[archtype][dev][core][implid];
  294. for (ptr = arch_model->list; ptr; ptr = ptr->next)
  295. {
  296. unsigned long size = ptr->entry->size;
  297. if (size > last && size < minimum)
  298. minimum = size;
  299. }
  300. }
  301. }
  302. }
  303. }
  304. }
  305. if (minimum == ULONG_MAX)
  306. break;
  307. fprintf(stderr, "%lu ", minimum);
  308. fprintf(datafile, "%-15lu ", minimum);
  309. for (archtype = archmin; archtype < archmax; archtype++)
  310. if(model->per_arch[archtype]!=NULL)
  311. for(dev = devmin; model->per_arch[archtype][dev] != NULL && (devmax == 0 || dev < devmax);dev++)
  312. for(core = coremin; model->per_arch[archtype][dev][core] != NULL && (coremax == 0 || core < coremax); core++)
  313. for (implid = 0; implid < STARPU_MAXIMPLEMENTATIONS; implid++)
  314. {
  315. struct starpu_perfmodel_per_arch *arch_model = &model->per_arch[archtype][dev][core][implid];
  316. for (ptr = arch_model->list; ptr; ptr = ptr->next)
  317. {
  318. struct starpu_perfmodel_history_entry *entry = ptr->entry;
  319. if (entry->size == minimum)
  320. {
  321. if (gflops)
  322. fprintf(datafile, "\t%-15le\t%-15le", entry->flops / (entry->mean * 1000),
  323. entry->flops / ((entry->mean + entry->deviation) * 1000) -
  324. entry->flops / (entry->mean * 1000)
  325. );
  326. else
  327. fprintf(datafile, "\t%-15le\t%-15le", 0.001*entry->mean, 0.001*entry->deviation);
  328. break;
  329. }
  330. }
  331. if (!ptr && arch_model->list)
  332. /* No value for this arch. */
  333. fprintf(datafile, "\t\"\"\t\"\"");
  334. }
  335. fprintf(datafile, "\n");
  336. }
  337. fprintf(stderr, "\n");
  338. fclose(datafile);
  339. }
  340. static void display_selected_arch_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, int *first)
  341. {
  342. unsigned implid;
  343. for (implid = 0; implid < STARPU_MAXIMPLEMENTATIONS; implid++)
  344. display_perf_model(gnuplot_file, model, arch, first, implid);
  345. }
  346. static void display_selected_device_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, enum starpu_worker_archtype archtype, int devid, int *first)
  347. {
  348. unsigned ncore;
  349. struct starpu_perfmodel_arch arch;
  350. arch.type = archtype;
  351. arch.devid = devid;
  352. for(ncore=0; model->per_arch[archtype][devid][ncore] != NULL; ncore++)
  353. {
  354. arch.ncore = ncore;
  355. display_selected_arch_perf_models(gnuplot_file,model,&arch,first);
  356. }
  357. }
  358. static void display_selected_archtype_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, enum starpu_worker_archtype archtype, int *first)
  359. {
  360. unsigned devid;
  361. for(devid=0; model->per_arch[archtype][devid] != NULL; devid++)
  362. display_selected_device_perf_models(gnuplot_file,model,archtype,devid,first);
  363. }
  364. static void display_all_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, int *first)
  365. {
  366. unsigned archtype;
  367. for(archtype = 0; archtype < STARPU_NARCH; archtype++)
  368. display_selected_archtype_perf_models(gnuplot_file,model,archtype,first);
  369. }
  370. #ifdef STARPU_USE_FXT
  371. static void dump_data_file(FILE *data_file)
  372. {
  373. memset(archtype_is_found, 0, STARPU_NARCH_VARIATIONS*sizeof(int));
  374. int i;
  375. for (i = 0; i < options.dumped_codelets_count; i++)
  376. {
  377. /* Dump only if the symbol matches user's request */
  378. if (strncmp(dumped_codelets[i].symbol, symbol, (FXT_MAX_PARAMS - 4)*sizeof(unsigned long)-1) == 0)
  379. {
  380. enum starpu_perfmodel_archtype archtype = dumped_codelets[i].archtype;
  381. archtype_is_found[archtype] = 1;
  382. size_t size = dumped_codelets[i].size;
  383. float time = dumped_codelets[i].time;
  384. fprintf(data_file, "%d %f %f\n", archtype, (float)size, time);
  385. }
  386. }
  387. }
  388. #endif
  389. static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel *model)
  390. {
  391. fprintf(gnuplot_file, "#!/usr/bin/gnuplot -persist\n");
  392. fprintf(gnuplot_file, "\n");
  393. fprintf(gnuplot_file, "set term postscript eps enhanced color\n");
  394. fprintf(gnuplot_file, "set output \"starpu_%s.eps\"\n", symbol);
  395. fprintf(gnuplot_file, "set title \"Model for codelet %s\"\n", symbol);
  396. fprintf(gnuplot_file, "set xlabel \"Total data size\"\n");
  397. if (gflops)
  398. fprintf(gnuplot_file, "set ylabel \"GFlops\"\n");
  399. else
  400. fprintf(gnuplot_file, "set ylabel \"Time (ms)\"\n");
  401. fprintf(gnuplot_file, "\n");
  402. fprintf(gnuplot_file, "set key top left\n");
  403. fprintf(gnuplot_file, "set logscale x\n");
  404. fprintf(gnuplot_file, "set logscale y\n");
  405. fprintf(gnuplot_file, "\n");
  406. /* If no input data is given to gnuplot, we at least need to specify an
  407. * arbitrary range. */
  408. if (no_fxt_file)
  409. fprintf(gnuplot_file, "set xrange [1:10**9]\n\n");
  410. int first = 1;
  411. fprintf(gnuplot_file, "plot\t");
  412. struct starpu_perfmodel_arch arch;
  413. struct _starpu_machine_config *conf = _starpu_get_machine_config();
  414. if (archname == NULL)
  415. {
  416. /* display all architectures */
  417. display_all_perf_models(gnuplot_file, model, &first);
  418. display_history_based_perf_models(gnuplot_file, model, NULL, NULL, NULL, &first);
  419. }
  420. else
  421. {
  422. if (strcmp(archname, "cpu") == 0)
  423. {
  424. arch.type = STARPU_CPU_WORKER;
  425. arch.devid = 1;
  426. arch.ncore = 0;
  427. display_selected_arch_perf_models(gnuplot_file, model, &arch, &first);
  428. display_history_based_perf_models(gnuplot_file, model, &arch.type, &arch.devid, &arch.ncore, &first);
  429. return;
  430. }
  431. unsigned k;
  432. if (sscanf(archname, "cpu:%u", &k) == 1)
  433. {
  434. /* For combined CPU workers */
  435. if ((k < 1) || (k > conf->topology.ncpus))
  436. {
  437. fprintf(stderr, "Invalid CPU size\n");
  438. exit(-1);
  439. }
  440. arch.type = STARPU_CPU_WORKER;
  441. arch.devid = 1;
  442. arch.ncore = k - 1;
  443. display_selected_arch_perf_models(gnuplot_file, model, &arch, &first);
  444. display_history_based_perf_models(gnuplot_file, model, &arch.type, &arch.devid, &arch.ncore, &first);
  445. return;
  446. }
  447. if (strcmp(archname, "cuda") == 0)
  448. {
  449. unsigned archtype = STARPU_CUDA_WORKER;
  450. display_selected_archtype_perf_models(gnuplot_file, model, archtype, &first);
  451. display_history_based_perf_models(gnuplot_file, model, &archtype, NULL, NULL, &first);
  452. return;
  453. }
  454. /* There must be a cleaner way ! */
  455. unsigned gpuid;
  456. int nmatched;
  457. nmatched = sscanf(archname, "cuda_%u", &gpuid);
  458. if (nmatched == 1)
  459. {
  460. if (gpuid < conf->topology.ncudagpus)
  461. {
  462. arch.type = STARPU_CUDA_WORKER;
  463. arch.devid = gpuid;
  464. arch.ncore = 0;
  465. display_selected_arch_perf_models(gnuplot_file, model, &arch, &first);
  466. display_history_based_perf_models(gnuplot_file, model, &arch.type, &arch.devid, &arch.ncore, &first);
  467. return;
  468. }
  469. else
  470. {
  471. fprintf(stderr, "Invalid CUDA device %d (last valid one is %d)\n", gpuid, STARPU_MAXCUDADEVS-1);
  472. exit(-1);
  473. }
  474. }
  475. if (strcmp(archname, "opencl") == 0)
  476. {
  477. unsigned archtype = STARPU_OPENCL_WORKER;
  478. display_selected_archtype_perf_models(gnuplot_file, model, archtype, &first);
  479. display_history_based_perf_models(gnuplot_file, model, &archtype, NULL, NULL, &first);
  480. return;
  481. }
  482. /* There must be a cleaner way ! */
  483. nmatched = sscanf(archname, "opencl_%u", &gpuid);
  484. if (nmatched == 1)
  485. {
  486. if (gpuid < conf->topology.nopenclgpus)
  487. {
  488. arch.type = STARPU_OPENCL_WORKER;
  489. arch.devid = gpuid;
  490. arch.ncore = 0;
  491. display_selected_arch_perf_models(gnuplot_file, model, &arch, &first);
  492. display_history_based_perf_models(gnuplot_file, model, &arch.type, &arch.devid, &arch.ncore, &first);
  493. return;
  494. }
  495. else
  496. {
  497. fprintf(stderr, "Invalid OpenCL device %d (last valid one is %d)\n", gpuid, STARPU_MAXOPENCLDEVS-1);
  498. exit(-1);
  499. }
  500. }
  501. fprintf(stderr, "Unknown architecture requested, aborting.\n");
  502. exit(-1);
  503. }
  504. }
  505. int main(int argc, char **argv)
  506. {
  507. int ret;
  508. struct starpu_perfmodel model;
  509. ret = starpu_init(NULL);
  510. if (ret == -ENODEV) return 1;
  511. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  512. #ifdef __MINGW32__
  513. WSADATA wsadata;
  514. WSAStartup(MAKEWORD(1,0), &wsadata);
  515. #endif
  516. parse_args(argc, argv);
  517. if (list)
  518. {
  519. ret = starpu_perfmodel_list(stdout);
  520. if (ret)
  521. {
  522. fprintf(stderr, "The performance model directory is invalid\n");
  523. return 1;
  524. }
  525. return 0;
  526. }
  527. /* Load the performance model associated to the symbol */
  528. ret = starpu_perfmodel_load_symbol(symbol, &model);
  529. if (ret == 1)
  530. {
  531. fprintf(stderr, "The performance model for the symbol <%s> could not be loaded\n", symbol);
  532. return 1;
  533. }
  534. /* If some FxT input was specified, we put the points on the graph */
  535. #ifdef STARPU_USE_FXT
  536. if (!no_fxt_file)
  537. {
  538. starpu_fxt_generate_trace(&options);
  539. snprintf(data_file_name, 256, "starpu_%s.data", symbol);
  540. FILE *data_file = fopen(data_file_name, "w+");
  541. STARPU_ASSERT(data_file);
  542. dump_data_file(data_file);
  543. fclose(data_file);
  544. }
  545. #endif
  546. snprintf(gnuplot_file_name, 256, "starpu_%s.gp", symbol);
  547. snprintf(avg_file_name, 256, "starpu_%s_avg.data", symbol);
  548. FILE *gnuplot_file = fopen(gnuplot_file_name, "w+");
  549. STARPU_ASSERT(gnuplot_file);
  550. display_selected_models(gnuplot_file, &model);
  551. fclose(gnuplot_file);
  552. /* Retrieve the current mode of the gnuplot executable */
  553. struct stat sb;
  554. ret = stat(gnuplot_file_name, &sb);
  555. if (ret)
  556. {
  557. perror("stat");
  558. STARPU_ABORT();
  559. }
  560. /* Make the gnuplot scrit executable for the owner */
  561. ret = chmod(gnuplot_file_name, sb.st_mode|S_IXUSR);
  562. if (ret)
  563. {
  564. perror("chmod");
  565. STARPU_ABORT();
  566. }
  567. _STARPU_DISP("Gnuplot file <%s> generated\n", gnuplot_file_name);
  568. starpu_shutdown();
  569. return 0;
  570. }