starpu_perfmodel_plot.c 18 KB

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