starpu_perfmodel_plot.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. * Copyright (C) 2011 Télécom-SudParis
  5. * Copyright (C) 2013 Thibaut Lambert
  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 <common/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. #if defined(_WIN32) && !defined(__CYGWIN__)
  31. #include <windows.h>
  32. #endif
  33. #define PROGNAME "starpu_perfmodel_plot"
  34. struct _perfmodel_plot_options
  35. {
  36. /* display all available models */
  37. int list;
  38. /* display directory */
  39. int directory;
  40. /* what kernel ? */
  41. char *symbol;
  42. /* what energy model ? */
  43. char *energy_symbol;
  44. /* which combination */
  45. int comb_is_set;
  46. int comb;
  47. /* display all available combinations of a specific model */
  48. int list_combs;
  49. int gflops;
  50. int energy;
  51. /* Unless a FxT file is specified, we just display the model */
  52. int with_fxt_file;
  53. char avg_file_name[256];
  54. #ifdef STARPU_USE_FXT
  55. struct starpu_fxt_codelet_event *dumped_codelets;
  56. struct starpu_fxt_options fxt_options;
  57. char data_file_name[256];
  58. #endif
  59. };
  60. static void usage()
  61. {
  62. fprintf(stderr, "Draw a graph corresponding to the execution time of a given perfmodel\n");
  63. fprintf(stderr, "Usage: %s [ options ]\n", PROGNAME);
  64. fprintf(stderr, "\n");
  65. fprintf(stderr, "One must specify a symbol with the -s option or use -l or -d\n");
  66. fprintf(stderr, "Options:\n");
  67. fprintf(stderr, " -d display the directory storing performance models\n");
  68. fprintf(stderr, " -l display all available models\n");
  69. fprintf(stderr, " -s <symbol> specify the symbol\n");
  70. fprintf(stderr, " -e display perfmodel as energy instead of time\n");
  71. fprintf(stderr, " -se <time_symbol> <energy_symbol> \n");
  72. fprintf(stderr, " specify both a time symbol and an energy symbol\n");
  73. fprintf(stderr, " -f draw GFlops instead of time\n");
  74. fprintf(stderr, " -i <Fxt files> input FxT files generated by StarPU\n");
  75. fprintf(stderr, " -lc display all combinations of a given model\n");
  76. fprintf(stderr, " -c <combination> specify the combination (use the option -lc to list all combinations of a given model)\n");
  77. fprintf(stderr, " -o <directory> specify directory in which to create output files (current directory by default)\n");
  78. fprintf(stderr, " -h, --help display this help and exit\n");
  79. fprintf(stderr, " -v, --version output version information and exit\n\n");
  80. fprintf(stderr, "Report bugs to <%s>.", PACKAGE_BUGREPORT);
  81. fprintf(stderr, "\n");
  82. }
  83. static void parse_args(int argc, char **argv, struct _perfmodel_plot_options *options, char **directory)
  84. {
  85. int correct_usage = 0;
  86. memset(options, 0, sizeof(struct _perfmodel_plot_options));
  87. #ifdef STARPU_USE_FXT
  88. /* Default options */
  89. starpu_fxt_options_init(&options->fxt_options);
  90. options->fxt_options.out_paje_path = NULL;
  91. options->fxt_options.activity_path = NULL;
  92. options->fxt_options.distrib_time_path = NULL;
  93. options->fxt_options.dag_path = NULL;
  94. options->fxt_options.dumped_codelets = &options->dumped_codelets;
  95. #endif
  96. /* We want to support arguments such as "-i trace_*" */
  97. unsigned reading_input_filenames = 0;
  98. int i;
  99. for (i = 1; i < argc; i++)
  100. {
  101. if (strcmp(argv[i], "-s") == 0)
  102. {
  103. options->symbol = argv[++i];
  104. correct_usage = 1;
  105. continue;
  106. }
  107. if (strcmp(argv[i], "-se") == 0)
  108. {
  109. options->symbol = argv[++i];
  110. options->energy_symbol = argv[++i];
  111. correct_usage = 1;
  112. continue;
  113. }
  114. if (strcmp(argv[i], "-o") == 0)
  115. {
  116. free(*directory);
  117. *directory = strdup(argv[++i]);
  118. #ifdef STARPU_USE_FXT
  119. options->fxt_options.dir = strdup(*directory);
  120. #endif
  121. continue;
  122. }
  123. if (strcmp(argv[i], "-i") == 0)
  124. {
  125. reading_input_filenames = 1;
  126. #ifdef STARPU_USE_FXT
  127. options->fxt_options.filenames[options->fxt_options.ninputfiles++] = argv[++i];
  128. options->with_fxt_file = 1;
  129. #else
  130. fprintf(stderr, "Warning: FxT support was not enabled in StarPU: FxT traces will thus be ignored!\n");
  131. #endif
  132. continue;
  133. }
  134. if (strcmp(argv[i], "-l") == 0)
  135. {
  136. options->list = 1;
  137. correct_usage = 1;
  138. continue;
  139. }
  140. if (strcmp(argv[i], "-lc") == 0)
  141. {
  142. options->list_combs = 1;
  143. continue;
  144. }
  145. if (strcmp(argv[i], "-f") == 0)
  146. {
  147. options->gflops = 1;
  148. continue;
  149. }
  150. if (strcmp(argv[i], "-e") == 0)
  151. {
  152. options->energy = 1;
  153. continue;
  154. }
  155. if (strcmp(argv[i], "-c") == 0)
  156. {
  157. options->comb_is_set = 1;
  158. options->comb = atoi(argv[++i]);
  159. continue;
  160. }
  161. if (strcmp(argv[i], "-d") == 0)
  162. {
  163. options->directory = 1;
  164. correct_usage = 1;
  165. continue;
  166. }
  167. if (strcmp(argv[i], "-h") == 0 ||
  168. strcmp(argv[i], "--help") == 0)
  169. {
  170. usage();
  171. exit(EXIT_SUCCESS);
  172. }
  173. if (strcmp(argv[i], "-v") == 0 ||
  174. strcmp(argv[i], "--version") == 0)
  175. {
  176. fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
  177. exit(EXIT_SUCCESS);
  178. }
  179. /* If the reading_input_filenames flag is set, and that the
  180. * argument does not match an option, we assume this may be
  181. * another filename */
  182. if (reading_input_filenames)
  183. {
  184. #ifdef STARPU_USE_FXT
  185. options->fxt_options.filenames[options->fxt_options.ninputfiles++] = argv[i];
  186. #endif
  187. continue;
  188. }
  189. }
  190. if (correct_usage == 0)
  191. {
  192. fprintf(stderr, "Incorrect usage, aborting\n");
  193. usage();
  194. exit(-1);
  195. }
  196. }
  197. static char *replace_char(char *str, char old, char new)
  198. {
  199. char *p = strdup(str);
  200. char *ptr = p;
  201. while (*ptr)
  202. {
  203. if (*ptr == old) *ptr = new;
  204. ptr ++;
  205. }
  206. return p;
  207. }
  208. static void print_comma(FILE *gnuplot_file, int *first)
  209. {
  210. if (*first)
  211. {
  212. *first = 0;
  213. }
  214. else
  215. {
  216. fprintf(gnuplot_file, ",\\\n\t");
  217. }
  218. }
  219. static void display_perf_model(FILE *gnuplot_file, struct starpu_perfmodel_arch* arch, struct starpu_perfmodel_per_arch *arch_model, int impl, int *first, struct _perfmodel_plot_options *options)
  220. {
  221. char arch_name[256];
  222. starpu_perfmodel_get_arch_name(arch, arch_name, 256, impl);
  223. #ifdef STARPU_USE_FXT
  224. if (options->with_fxt_file && impl == 0)
  225. {
  226. if (options->gflops)
  227. {
  228. _STARPU_DISP("gflops unit selected, ignoring fxt trace\n");
  229. }
  230. else
  231. {
  232. char *arch_name2 = replace_char(arch_name, '_', '-');
  233. print_comma(gnuplot_file, first);
  234. fprintf(gnuplot_file, "\"< grep '^%s' %s\" using 3:4 title \"Profiling %s\"", arch_name, options->data_file_name, arch_name2);
  235. free(arch_name2);
  236. }
  237. }
  238. #endif
  239. /* Only display the regression model if we could actually build a model */
  240. if (!options->gflops && arch_model->regression.valid && !arch_model->regression.nl_valid)
  241. {
  242. print_comma(gnuplot_file, first);
  243. fprintf(stderr, "\tLinear: y = alpha size ^ beta\n");
  244. fprintf(stderr, "\t\talpha = %e\n", arch_model->regression.alpha * 0.001);
  245. fprintf(stderr, "\t\tbeta = %e\n", arch_model->regression.beta);
  246. fprintf(gnuplot_file, "0.001 * %f * x ** %f title \"Linear Regression %s\"",
  247. arch_model->regression.alpha, arch_model->regression.beta, arch_name);
  248. }
  249. if (!options->gflops && arch_model->regression.nl_valid)
  250. {
  251. print_comma(gnuplot_file, first);
  252. fprintf(stderr, "\tNon-Linear: y = a size ^b + c\n");
  253. fprintf(stderr, "\t\ta = %e\n", arch_model->regression.a * 0.001);
  254. fprintf(stderr, "\t\tb = %e\n", arch_model->regression.b);
  255. fprintf(stderr, "\t\tc = %e\n", arch_model->regression.c * 0.001);
  256. fprintf(gnuplot_file, "0.001 * %f * x ** %f + 0.001 * %f title \"Non-Linear Regression %s\"",
  257. arch_model->regression.a, arch_model->regression.b, arch_model->regression.c, arch_name);
  258. }
  259. }
  260. static void display_history_based_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, struct starpu_perfmodel *energy_model, int *first, struct _perfmodel_plot_options *options)
  261. {
  262. FILE *datafile;
  263. struct starpu_perfmodel_history_list *ptr;
  264. char arch_name[32];
  265. int col;
  266. unsigned long minimum = 0;
  267. datafile = fopen(options->avg_file_name, "w");
  268. col = 2;
  269. int i;
  270. for(i = 0; i < model->state->ncombs; i++)
  271. {
  272. int comb = model->state->combs[i];
  273. if (options->comb_is_set == 0 || options->comb == comb)
  274. {
  275. struct starpu_perfmodel_arch *arch;
  276. int impl;
  277. arch = starpu_perfmodel_arch_comb_fetch(comb);
  278. for(impl = 0; impl < model->state->nimpls[comb]; impl++)
  279. {
  280. struct starpu_perfmodel_per_arch *arch_model = &model->state->per_arch[comb][impl];
  281. starpu_perfmodel_get_arch_name(arch, arch_name, 32, impl);
  282. if (arch_model->list)
  283. {
  284. char *arch_name2 = replace_char(arch_name, '_', '-');
  285. print_comma(gnuplot_file, first);
  286. fprintf(gnuplot_file, "\"%s\" using 1:%d:%d with errorlines title \"Average %s\"", options->avg_file_name, col, col+1, arch_name2);
  287. col += 2;
  288. free(arch_name2);
  289. }
  290. }
  291. }
  292. }
  293. /* Dump entries in size order */
  294. while (1)
  295. {
  296. unsigned long last = minimum;
  297. minimum = ULONG_MAX;
  298. /* Get the next minimum */
  299. for(i = 0; i < model->state->ncombs; i++)
  300. {
  301. int comb = model->state->combs[i];
  302. if (options->comb_is_set == 0 || options->comb == comb)
  303. {
  304. int impl;
  305. for(impl = 0; impl < model->state->nimpls[comb]; impl++)
  306. {
  307. struct starpu_perfmodel_per_arch *arch_model = &model->state->per_arch[comb][impl];
  308. for (ptr = arch_model->list; ptr; ptr = ptr->next)
  309. {
  310. unsigned long size = ptr->entry->size;
  311. if (size > last && size < minimum)
  312. minimum = size;
  313. }
  314. }
  315. }
  316. }
  317. if (minimum == ULONG_MAX)
  318. break;
  319. fprintf(stderr, "%lu ", minimum);
  320. fprintf(datafile, "%-15lu ", minimum);
  321. /* Find that minimum */
  322. for(i = 0; i < model->state->ncombs; i++)
  323. {
  324. int comb = model->state->combs[i];
  325. if (options->comb_is_set == 0 || options->comb == comb)
  326. {
  327. int impl;
  328. for(impl = 0; impl < model->state->nimpls[comb]; impl++)
  329. {
  330. int found = 0;
  331. struct starpu_perfmodel_per_arch *arch_model = &model->state->per_arch[comb][impl];
  332. for (ptr = arch_model->list; ptr; ptr = ptr->next)
  333. {
  334. struct starpu_perfmodel_history_entry *entry = ptr->entry;
  335. if (entry->size == minimum)
  336. {
  337. if (options->energy_symbol)
  338. {
  339. /* Look for the same in the energy model */
  340. if (impl >= energy_model->state->nimpls[comb])
  341. /* Doesn't have measurements for this impl */
  342. break;
  343. struct starpu_perfmodel_per_arch *arch_model2 = &energy_model->state->per_arch[comb][impl];
  344. struct starpu_perfmodel_history_list *ptr2;
  345. for (ptr2 = arch_model2->list; ptr2; ptr2 = ptr2->next)
  346. {
  347. struct starpu_perfmodel_history_entry *entry2 = ptr2->entry;
  348. if (entry2->size == minimum)
  349. {
  350. /* Found the same size, can print */
  351. double rel_delta = sqrt(
  352. (entry2->deviation * entry2->deviation) / (entry2->mean * entry2->mean)
  353. + (entry->deviation * entry->deviation) / (entry->mean * entry->mean));
  354. if (options->gflops)
  355. fprintf(datafile, "\t%-15le\t%-15le", entry->flops / (entry->mean * 1000) / entry2->mean,
  356. entry->flops / (entry->mean * 1000) / entry2->mean * rel_delta);
  357. else
  358. fprintf(datafile, "\t%-15le\t%-15le", entry2->mean / (entry->mean / 1000000),
  359. entry2->mean / (entry->mean / 1000000) * rel_delta);
  360. found = 1;
  361. break;
  362. }
  363. }
  364. }
  365. else
  366. {
  367. if (options->gflops)
  368. if (options->energy)
  369. fprintf(datafile, "\t%-15le\t%-15le", entry->flops / entry->mean / 1000000000,
  370. entry->flops * entry->deviation / (entry->mean * entry->mean) / 1000000000
  371. );
  372. else
  373. fprintf(datafile, "\t%-15le\t%-15le", entry->flops / (entry->mean * 1000),
  374. entry->flops * entry->deviation / (entry->mean * entry->mean * 1000)
  375. );
  376. else
  377. if (options->energy)
  378. fprintf(datafile, "\t%-15le\t%-15le", entry->mean, entry->deviation);
  379. else
  380. fprintf(datafile, "\t%-15le\t%-15le", 0.001*entry->mean, 0.001*entry->deviation);
  381. found = 1;
  382. }
  383. break;
  384. }
  385. }
  386. if (!found && arch_model->list)
  387. /* No value for this arch. */
  388. fprintf(datafile, "\t\"\"\t\"\"");
  389. }
  390. }
  391. }
  392. fprintf(datafile, "\n");
  393. }
  394. fprintf(stderr, "\n");
  395. fclose(datafile);
  396. }
  397. static void display_all_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, int *first, struct _perfmodel_plot_options *options)
  398. {
  399. int i;
  400. for(i = 0; i < model->state->ncombs; i++)
  401. {
  402. int comb = model->state->combs[i];
  403. if (options->comb_is_set == 0 || options->comb == comb)
  404. {
  405. struct starpu_perfmodel_arch *arch;
  406. int impl;
  407. arch = starpu_perfmodel_arch_comb_fetch(comb);
  408. for(impl = 0; impl < model->state->nimpls[comb]; impl++)
  409. {
  410. struct starpu_perfmodel_per_arch *archmodel = &model->state->per_arch[comb][impl];
  411. display_perf_model(gnuplot_file, arch, archmodel, impl, first, options);
  412. }
  413. }
  414. }
  415. }
  416. #ifdef STARPU_USE_FXT
  417. static void dump_data_file(FILE *data_file, struct _perfmodel_plot_options *options)
  418. {
  419. int i;
  420. for (i = 0; i < options->fxt_options.dumped_codelets_count; i++)
  421. {
  422. /* Dump only if the codelet symbol matches user's request (with or without the machine name) */
  423. char *tmp = strdup(options->symbol);
  424. char *dot = strchr(tmp, '.');
  425. if (dot) tmp[strlen(tmp)-strlen(dot)] = '\0';
  426. if ((strncmp(options->dumped_codelets[i].symbol, options->symbol, (FXT_MAX_PARAMS - 4)*sizeof(unsigned long)-1) == 0)
  427. || (strncmp(options->dumped_codelets[i].symbol, tmp, (FXT_MAX_PARAMS - 4)*sizeof(unsigned long)-1) == 0))
  428. {
  429. char *archname = options->dumped_codelets[i].perfmodel_archname;
  430. size_t size = options->dumped_codelets[i].size;
  431. float time = options->dumped_codelets[i].time;
  432. fprintf(data_file, "%s %f %f\n", archname, (float)size, time);
  433. }
  434. free(tmp);
  435. }
  436. }
  437. #endif
  438. static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel *model, struct starpu_perfmodel *energy_model, struct _perfmodel_plot_options *options)
  439. {
  440. char *symbol = replace_char(options->symbol, '_', '-');
  441. fprintf(gnuplot_file, "#!/usr/bin/gnuplot -persist\n");
  442. fprintf(gnuplot_file, "\n");
  443. fprintf(gnuplot_file, "set term postscript eps enhanced color\n");
  444. fprintf(gnuplot_file, "set output \"starpu_%s.eps\"\n", options->symbol);
  445. fprintf(gnuplot_file, "set title \"Model for codelet %s\"\n", symbol);
  446. fprintf(gnuplot_file, "set xlabel \"Total data size\"\n");
  447. if (options->gflops)
  448. if (options->energy_symbol)
  449. fprintf(gnuplot_file, "set ylabel \"GFlop/W\"\n");
  450. else if (options->energy)
  451. fprintf(gnuplot_file, "set ylabel \"GFlop/J\"\n");
  452. else
  453. fprintf(gnuplot_file, "set ylabel \"GFlop/s\"\n");
  454. else
  455. if (options->energy_symbol)
  456. fprintf(gnuplot_file, "set ylabel \"Power (W)\"\n");
  457. else if (options->energy)
  458. fprintf(gnuplot_file, "set ylabel \"Energy (J)\"\n");
  459. else
  460. fprintf(gnuplot_file, "set ylabel \"Time (ms)\"\n");
  461. fprintf(gnuplot_file, "\n");
  462. fprintf(gnuplot_file, "set key top left\n");
  463. fprintf(gnuplot_file, "set logscale x\n");
  464. fprintf(gnuplot_file, "set logscale y\n");
  465. fprintf(gnuplot_file, "\n");
  466. /* If no input data is given to gnuplot, we at least need to specify an
  467. * arbitrary range. */
  468. if (options->with_fxt_file == 0 || options->gflops)
  469. fprintf(gnuplot_file, "set xrange [1:10**9]\n\n");
  470. int first = 1;
  471. fprintf(gnuplot_file, "plot\t");
  472. /* display all or selected combinations */
  473. display_all_perf_models(gnuplot_file, model, &first, options);
  474. if (options->energy_symbol)
  475. display_all_perf_models(gnuplot_file, energy_model, &first, options);
  476. display_history_based_perf_models(gnuplot_file, model, energy_model, &first, options);
  477. free(symbol);
  478. }
  479. int main(int argc, char **argv)
  480. {
  481. int ret = 0;
  482. struct starpu_perfmodel model = { .type = STARPU_PERFMODEL_INVALID };
  483. struct starpu_perfmodel energy_model = { .type = STARPU_PERFMODEL_INVALID };
  484. char gnuplot_file_name[256];
  485. struct _perfmodel_plot_options options;
  486. char *directory = strdup("./");
  487. #if defined(_WIN32) && !defined(__CYGWIN__)
  488. WSADATA wsadata;
  489. WSAStartup(MAKEWORD(1,0), &wsadata);
  490. #endif
  491. parse_args(argc, argv, &options, &directory);
  492. starpu_perfmodel_initialize();
  493. if (options.directory)
  494. {
  495. starpu_perfmodel_directory(stdout);
  496. }
  497. else if (options.list)
  498. {
  499. ret = starpu_perfmodel_list(stdout);
  500. if (ret)
  501. {
  502. _STARPU_DISP("The performance model directory is invalid\n");
  503. }
  504. }
  505. else
  506. {
  507. /* Load the performance model associated to the symbol */
  508. ret = starpu_perfmodel_load_symbol(options.symbol, &model);
  509. if (options.energy_symbol)
  510. ret = starpu_perfmodel_load_symbol(options.energy_symbol, &energy_model);
  511. if (ret)
  512. {
  513. _STARPU_DISP("The performance model for the symbol <%s> could not be loaded\n", options.symbol);
  514. }
  515. else if (options.list_combs)
  516. {
  517. ret = starpu_perfmodel_list_combs(stdout, &model);
  518. if (ret)
  519. {
  520. fprintf(stderr, "Error when listing combinations for model <%s>\n", options.symbol);
  521. }
  522. }
  523. else
  524. {
  525. /* If some FxT input was specified, we put the points on the graph */
  526. #ifdef STARPU_USE_FXT
  527. if (options.with_fxt_file)
  528. {
  529. starpu_fxt_generate_trace(&options.fxt_options);
  530. snprintf(options.data_file_name, sizeof(options.data_file_name), "%s/starpu_%s.data", directory, options.symbol);
  531. FILE *data_file = fopen(options.data_file_name, "w+");
  532. STARPU_ASSERT(data_file);
  533. dump_data_file(data_file, &options);
  534. fclose(data_file);
  535. }
  536. #endif
  537. snprintf(gnuplot_file_name, sizeof(gnuplot_file_name), "%s/starpu_%s.gp", directory, options.symbol);
  538. snprintf(options.avg_file_name, sizeof(options.avg_file_name), "%s/starpu_%s_avg.data", directory, options.symbol);
  539. FILE *gnuplot_file = fopen(gnuplot_file_name, "w+");
  540. STARPU_ASSERT_MSG(gnuplot_file, "Cannot create file <%s>\n", gnuplot_file_name);
  541. display_selected_models(gnuplot_file, &model, &energy_model, &options);
  542. fprintf(gnuplot_file,"\n");
  543. fclose(gnuplot_file);
  544. /* Retrieve the current mode of the gnuplot executable */
  545. struct stat sb;
  546. ret = stat(gnuplot_file_name, &sb);
  547. if (ret)
  548. {
  549. perror("stat");
  550. STARPU_ABORT();
  551. }
  552. /* Make the gnuplot scrit executable for the owner */
  553. ret = chmod(gnuplot_file_name, sb.st_mode|S_IXUSR);
  554. if (ret)
  555. {
  556. perror("chmod");
  557. STARPU_ABORT();
  558. }
  559. _STARPU_DISP("Gnuplot file <%s> generated\n", gnuplot_file_name);
  560. }
  561. }
  562. starpu_perfmodel_free_sampling();
  563. free(directory);
  564. return ret;
  565. }