starpu_perfmodel_plot.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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. if(model->per_arch[archtype]!=NULL)
  285. for(dev = devmin; model->per_arch[archtype][dev] != NULL && (devmax == 0 || dev < devmax);dev++)
  286. for(core = coremin; model->per_arch[archtype][dev][core] != NULL && (coremax == 0 || core < coremax); core++)
  287. for (implid = 0; implid < STARPU_MAXIMPLEMENTATIONS; implid++)
  288. {
  289. struct starpu_perfmodel_per_arch *arch_model = &model->per_arch[archtype][dev][core][implid];
  290. for (ptr = arch_model->list; ptr; ptr = ptr->next)
  291. {
  292. unsigned long size = ptr->entry->size;
  293. if (size > last && size < minimum)
  294. minimum = size;
  295. }
  296. }
  297. if (minimum == ULONG_MAX)
  298. break;
  299. fprintf(stderr, "%lu ", minimum);
  300. fprintf(datafile, "%-15lu ", minimum);
  301. for (archtype = archmin; archtype < archmax; archtype++)
  302. if(model->per_arch[archtype]!=NULL)
  303. for(dev = devmin; model->per_arch[archtype][dev] != NULL && (devmax == 0 || dev < devmax);dev++)
  304. for(core = coremin; model->per_arch[archtype][dev][core] != NULL && (coremax == 0 || core < coremax); core++)
  305. for (implid = 0; implid < STARPU_MAXIMPLEMENTATIONS; implid++)
  306. {
  307. struct starpu_perfmodel_per_arch *arch_model = &model->per_arch[archtype][dev][core][implid];
  308. for (ptr = arch_model->list; ptr; ptr = ptr->next)
  309. {
  310. struct starpu_perfmodel_history_entry *entry = ptr->entry;
  311. if (entry->size == minimum)
  312. {
  313. if (gflops)
  314. fprintf(datafile, "\t%-15le\t%-15le", entry->flops / (entry->mean * 1000),
  315. entry->flops / ((entry->mean + entry->deviation) * 1000) -
  316. entry->flops / (entry->mean * 1000)
  317. );
  318. else
  319. fprintf(datafile, "\t%-15le\t%-15le", 0.001*entry->mean, 0.001*entry->deviation);
  320. break;
  321. }
  322. }
  323. if (!ptr && arch_model->list)
  324. /* No value for this arch. */
  325. fprintf(datafile, "\t\"\"\t\"\"");
  326. }
  327. fprintf(datafile, "\n");
  328. }
  329. fprintf(stderr, "\n");
  330. fclose(datafile);
  331. }
  332. static void display_selected_arch_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, int *first)
  333. {
  334. unsigned implid;
  335. for (implid = 0; implid < STARPU_MAXIMPLEMENTATIONS; implid++)
  336. display_perf_model(gnuplot_file, model, arch, first, implid);
  337. }
  338. static void display_selected_device_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, enum starpu_worker_archtype archtype, int devid, int *first)
  339. {
  340. unsigned ncore;
  341. struct starpu_perfmodel_arch arch;
  342. arch.type = archtype;
  343. arch.devid = devid;
  344. for(ncore=0; model->per_arch[archtype][devid][ncore] != NULL; ncore++)
  345. {
  346. arch.ncore = ncore;
  347. display_selected_arch_perf_models(gnuplot_file,model,&arch,first);
  348. }
  349. }
  350. static void display_selected_archtype_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, enum starpu_worker_archtype archtype, int *first)
  351. {
  352. unsigned devid;
  353. for(devid=0; model->per_arch[archtype][devid] != NULL; devid++)
  354. display_selected_device_perf_models(gnuplot_file,model,archtype,devid,first);
  355. }
  356. static void display_all_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, int *first)
  357. {
  358. unsigned archtype;
  359. for(archtype = 0; archtype < STARPU_NARCH; archtype++)
  360. display_selected_archtype_perf_models(gnuplot_file,model,archtype,first);
  361. }
  362. #ifdef STARPU_USE_FXT
  363. static void dump_data_file(FILE *data_file)
  364. {
  365. memset(archtype_is_found, 0, STARPU_NARCH_VARIATIONS*sizeof(int));
  366. int i;
  367. for (i = 0; i < options.dumped_codelets_count; i++)
  368. {
  369. /* Dump only if the symbol matches user's request */
  370. if (strncmp(dumped_codelets[i].symbol, symbol, (FXT_MAX_PARAMS - 4)*sizeof(unsigned long)-1) == 0)
  371. {
  372. enum starpu_perfmodel_archtype archtype = dumped_codelets[i].archtype;
  373. archtype_is_found[archtype] = 1;
  374. size_t size = dumped_codelets[i].size;
  375. float time = dumped_codelets[i].time;
  376. fprintf(data_file, "%d %f %f\n", archtype, (float)size, time);
  377. }
  378. }
  379. }
  380. #endif
  381. static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel *model)
  382. {
  383. fprintf(gnuplot_file, "#!/usr/bin/gnuplot -persist\n");
  384. fprintf(gnuplot_file, "\n");
  385. fprintf(gnuplot_file, "set term postscript eps enhanced color\n");
  386. fprintf(gnuplot_file, "set output \"starpu_%s.eps\"\n", symbol);
  387. fprintf(gnuplot_file, "set title \"Model for codelet %s\"\n", symbol);
  388. fprintf(gnuplot_file, "set xlabel \"Total data size\"\n");
  389. if (gflops)
  390. fprintf(gnuplot_file, "set ylabel \"GFlops\"\n");
  391. else
  392. fprintf(gnuplot_file, "set ylabel \"Time (ms)\"\n");
  393. fprintf(gnuplot_file, "\n");
  394. fprintf(gnuplot_file, "set key top left\n");
  395. fprintf(gnuplot_file, "set logscale x\n");
  396. fprintf(gnuplot_file, "set logscale y\n");
  397. fprintf(gnuplot_file, "\n");
  398. /* If no input data is given to gnuplot, we at least need to specify an
  399. * arbitrary range. */
  400. if (no_fxt_file)
  401. fprintf(gnuplot_file, "set xrange [1:10**9]\n\n");
  402. int first = 1;
  403. fprintf(gnuplot_file, "plot\t");
  404. struct starpu_perfmodel_arch arch;
  405. struct _starpu_machine_config *conf = _starpu_get_machine_config();
  406. if (archname == NULL)
  407. {
  408. /* display all architectures */
  409. display_all_perf_models(gnuplot_file, model, &first);
  410. display_history_based_perf_models(gnuplot_file, model, NULL, NULL, NULL, &first);
  411. }
  412. else
  413. {
  414. if (strcmp(archname, "cpu") == 0)
  415. {
  416. arch.type = STARPU_CPU_WORKER;
  417. arch.devid = 1;
  418. arch.ncore = 0;
  419. display_selected_arch_perf_models(gnuplot_file, model, &arch, &first);
  420. display_history_based_perf_models(gnuplot_file, model, &arch.type, &arch.devid, &arch.ncore, &first);
  421. return;
  422. }
  423. unsigned k;
  424. if (sscanf(archname, "cpu:%u", &k) == 1)
  425. {
  426. /* For combined CPU workers */
  427. if ((k < 1) || (k > conf->topology.ncpus))
  428. {
  429. fprintf(stderr, "Invalid CPU size\n");
  430. exit(-1);
  431. }
  432. arch.type = STARPU_CPU_WORKER;
  433. arch.devid = 1;
  434. arch.ncore = k - 1;
  435. display_selected_arch_perf_models(gnuplot_file, model, &arch, &first);
  436. display_history_based_perf_models(gnuplot_file, model, &arch.type, &arch.devid, &arch.ncore, &first);
  437. return;
  438. }
  439. if (strcmp(archname, "cuda") == 0)
  440. {
  441. unsigned archtype = STARPU_CUDA_WORKER;
  442. display_selected_archtype_perf_models(gnuplot_file, model, archtype, &first);
  443. display_history_based_perf_models(gnuplot_file, model, &archtype, NULL, NULL, &first);
  444. return;
  445. }
  446. /* There must be a cleaner way ! */
  447. unsigned gpuid;
  448. int nmatched;
  449. nmatched = sscanf(archname, "cuda_%u", &gpuid);
  450. if (nmatched == 1)
  451. {
  452. if (gpuid < conf->topology.ncudagpus)
  453. {
  454. arch.type = STARPU_CUDA_WORKER;
  455. arch.devid = gpuid;
  456. arch.ncore = 0;
  457. display_selected_arch_perf_models(gnuplot_file, model, &arch, &first);
  458. display_history_based_perf_models(gnuplot_file, model, &arch.type, &arch.devid, &arch.ncore, &first);
  459. return;
  460. }
  461. else
  462. {
  463. fprintf(stderr, "Invalid CUDA device %d (last valid one is %d)\n", gpuid, STARPU_MAXCUDADEVS-1);
  464. exit(-1);
  465. }
  466. }
  467. if (strcmp(archname, "opencl") == 0)
  468. {
  469. unsigned archtype = STARPU_OPENCL_WORKER;
  470. display_selected_archtype_perf_models(gnuplot_file, model, archtype, &first);
  471. display_history_based_perf_models(gnuplot_file, model, &archtype, NULL, NULL, &first);
  472. return;
  473. }
  474. /* There must be a cleaner way ! */
  475. nmatched = sscanf(archname, "opencl_%u", &gpuid);
  476. if (nmatched == 1)
  477. {
  478. if (gpuid < conf->topology.nopenclgpus)
  479. {
  480. arch.type = STARPU_OPENCL_WORKER;
  481. arch.devid = gpuid;
  482. arch.ncore = 0;
  483. display_selected_arch_perf_models(gnuplot_file, model, &arch, &first);
  484. display_history_based_perf_models(gnuplot_file, model, &arch.type, &arch.devid, &arch.ncore, &first);
  485. return;
  486. }
  487. else
  488. {
  489. fprintf(stderr, "Invalid OpenCL device %d (last valid one is %d)\n", gpuid, STARPU_MAXOPENCLDEVS-1);
  490. exit(-1);
  491. }
  492. }
  493. fprintf(stderr, "Unknown architecture requested, aborting.\n");
  494. exit(-1);
  495. }
  496. }
  497. int main(int argc, char **argv)
  498. {
  499. int ret;
  500. struct starpu_perfmodel model;
  501. #ifdef __MINGW32__
  502. WSADATA wsadata;
  503. WSAStartup(MAKEWORD(1,0), &wsadata);
  504. #endif
  505. parse_args(argc, argv);
  506. if (list)
  507. {
  508. ret = starpu_perfmodel_list(stdout);
  509. if (ret)
  510. {
  511. fprintf(stderr, "The performance model directory is invalid\n");
  512. return 1;
  513. }
  514. return 0;
  515. }
  516. /* Load the performance model associated to the symbol */
  517. ret = starpu_perfmodel_load_symbol(symbol, &model);
  518. if (ret == 1)
  519. {
  520. fprintf(stderr, "The performance model for the symbol <%s> could not be loaded\n", symbol);
  521. return 1;
  522. }
  523. /* If some FxT input was specified, we put the points on the graph */
  524. #ifdef STARPU_USE_FXT
  525. if (!no_fxt_file)
  526. {
  527. starpu_fxt_generate_trace(&options);
  528. snprintf(data_file_name, 256, "starpu_%s.data", symbol);
  529. FILE *data_file = fopen(data_file_name, "w+");
  530. STARPU_ASSERT(data_file);
  531. dump_data_file(data_file);
  532. fclose(data_file);
  533. }
  534. #endif
  535. snprintf(gnuplot_file_name, 256, "starpu_%s.gp", symbol);
  536. snprintf(avg_file_name, 256, "starpu_%s_avg.data", symbol);
  537. FILE *gnuplot_file = fopen(gnuplot_file_name, "w+");
  538. STARPU_ASSERT(gnuplot_file);
  539. display_selected_models(gnuplot_file, &model);
  540. fclose(gnuplot_file);
  541. /* Retrieve the current mode of the gnuplot executable */
  542. struct stat sb;
  543. ret = stat(gnuplot_file_name, &sb);
  544. if (ret)
  545. {
  546. perror("stat");
  547. STARPU_ABORT();
  548. }
  549. /* Make the gnuplot scrit executable for the owner */
  550. ret = chmod(gnuplot_file_name, sb.st_mode|S_IXUSR);
  551. if (ret)
  552. {
  553. perror("chmod");
  554. STARPU_ABORT();
  555. }
  556. _STARPU_DISP("Gnuplot file <%s> generated\n", gnuplot_file_name);
  557. return 0;
  558. }