starpu_replay.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2016-2017 Université de Bordeaux
  4. * Copyright (C) 2017 Erwan Leria
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. /*
  18. * This reads a tasks.rec file and replays the recorded task graph.
  19. * Currently, this version is done to run with simgrid.
  20. *
  21. * For further information, contact erwan.leria@inria.fr
  22. */
  23. #include <starpu.h>
  24. #include <unistd.h>
  25. #include <stdio.h>
  26. #include <math.h>
  27. #include <common/uthash.h>
  28. #include <common/utils.h>
  29. #include <starpu_scheduler.h>
  30. #include <rbtree.h>
  31. #include <common/utils.h>
  32. #define REPLAY_NMAX_DEPENDENCIES 8
  33. #define ARRAY_DUP(in, out, n) memcpy(out, in, n * sizeof(*out))
  34. #define ARRAY_INIT(array, n) memset(array, 0, n * sizeof(*array))
  35. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  36. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  37. * Declarations of global variables, structures, pointers, ... *
  38. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  39. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  40. typedef unsigned long jobid_t;
  41. static char *name = NULL;
  42. static char *model = NULL;
  43. static jobid_t jobid;
  44. static jobid_t *dependson;
  45. static unsigned int submitorder = -1;
  46. static starpu_tag_t tag;
  47. static int workerid;
  48. static uint32_t footprint;
  49. static double flops;
  50. static double startTime; //start time (The instant when the task starts)
  51. static double endTime; //end time (The instant when the task ends)
  52. static int iteration = -1;
  53. static starpu_data_handle_t handles[STARPU_NMAXBUFS];
  54. static enum starpu_data_access_mode modes[STARPU_NMAXBUFS];
  55. /* Use the following arrays when the number of data is greater than STARPU_NMAXBUFS */
  56. starpu_data_handle_t * handles_ptr;
  57. enum starpu_data_access_mode * modes_ptr;
  58. size_t * sizes_set;
  59. static size_t dependson_size;
  60. static size_t ndependson;
  61. static int nb_parameters = 0; /* Number of parameters */
  62. static int alloc_mode; /* If alloc_mode value is 1, then the handles are stored in dyn_handles, else they are in handles */
  63. static int priority = 0;
  64. char * reg_signal = NULL; /* The register signal (0 or 1 coded on 8 bit) it is used to know which handle of the task has to be registered in StarPU */
  65. static int device;
  66. /* Record all tasks, hashed by jobid. */
  67. static struct task
  68. {
  69. struct starpu_rbtree_node node;
  70. UT_hash_handle hh;
  71. jobid_t jobid;
  72. int iteration;
  73. unsigned int submit_order;
  74. jobid_t deps[REPLAY_NMAX_DEPENDENCIES];
  75. size_t ndependson;
  76. struct starpu_task task;
  77. } *tasks;
  78. /* Record handles */
  79. static struct handle
  80. {
  81. UT_hash_handle hh;
  82. starpu_data_handle_t mem_ptr; /* This value should be the registered handle */
  83. starpu_data_handle_t handle; /* The key is the original value of the handle in the file */
  84. } * handles_hash;
  85. /* Record models */
  86. static struct perfmodel
  87. {
  88. UT_hash_handle hh;
  89. struct starpu_perfmodel perfmodel;
  90. char * model_name;
  91. } * model_hash;
  92. //* * Record a dependent task by its jobid and the jobids of its dependencies *\/ */
  93. /* struct s_dep */
  94. /* { */
  95. /* jobid_t job_id; */
  96. /* jobid_t deps_jobid[REPLAY_NMAX_DEPENDENCIES]; /\* That array has to contain the jobids of the dependencies, notice that the number of dependencies is limited to 16, modify NMAX_DEPENDENCIES at your convenience *\/ */
  97. /* size_t ndependson; */
  98. /* }; */
  99. /* [SUBMITORDER] The tree of the submit order */
  100. static struct starpu_rbtree tree = STARPU_RBTREE_INITIALIZER;
  101. /* the cmp_fn arg for rb_tree_insert() */
  102. unsigned int diff(struct starpu_rbtree_node * left_elm, struct starpu_rbtree_node * right_elm)
  103. {
  104. return ((struct task *) left_elm)->submit_order - ((struct task *) right_elm)->submit_order;
  105. }
  106. /* /\* Declaration of an AoS (array of structures) *\/ */
  107. /* struct s_dep ** jobidDeps; */
  108. /* size_t jobidDeps_size; */
  109. /* static size_t ntask = 0; /\* This is the number of dependent tasks *\/ */
  110. /* Settings for the perfmodel */
  111. struct task_arg
  112. {
  113. uint32_t footprint;
  114. double perf[];
  115. };
  116. uint32_t get_footprint(struct starpu_task * task)
  117. {
  118. return ((struct task_arg*) (task->cl_arg))->footprint;
  119. }
  120. double arch_cost_function(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl STARPU_ATTRIBUTE_UNUSED)
  121. {
  122. device = starpu_perfmodel_arch_comb_get(arch->ndevices, arch->devices);
  123. STARPU_ASSERT(device != -1);
  124. /* Then, get the pointer to the value of the expected time */
  125. double * val = (double *) ((struct task_arg *) (task->cl_arg))->perf+device;
  126. if (!(*val == 0 || isnan(*val)))
  127. return *val;
  128. fprintf(stderr, "[starpu] Error, expected_time is 0 or lower (replay.c line : %d)", __LINE__- 6);
  129. return 0.0;
  130. }
  131. /* End of settings */
  132. void dumb_kernel(void) {}
  133. /* [CODELET] Initialization of an unique codelet for all the tasks*/
  134. static int can_execute(unsigned worker_id, struct starpu_task *task, unsigned nimpl STARPU_ATTRIBUTE_UNUSED)
  135. {
  136. struct starpu_perfmodel_arch * arch = starpu_worker_get_perf_archtype(worker_id, STARPU_NMAX_SCHED_CTXS);
  137. double expected_time = ((struct task_arg *) (task->cl_arg))->perf[(starpu_perfmodel_arch_comb_get(arch->ndevices, arch->devices))];
  138. if (!(expected_time == 0 || isnan(expected_time)))
  139. {
  140. return 1;
  141. }
  142. return 0;
  143. }
  144. static struct starpu_perfmodel myperfmodel =
  145. {
  146. .type = STARPU_PER_ARCH,
  147. .arch_cost_function = arch_cost_function,
  148. .footprint = get_footprint,
  149. };
  150. static struct starpu_codelet cl =
  151. {
  152. .cpu_funcs = { (void*) 1 },
  153. .cpu_funcs_name = { "dumb_kernel" },
  154. .cuda_funcs = { (void*) 1 },
  155. .opencl_funcs = { (void*) 1 },
  156. .nbuffers = STARPU_VARIABLE_NBUFFERS,
  157. .can_execute = can_execute,
  158. .model = &myperfmodel,
  159. };
  160. /* * * * * * * * * * * * * *
  161. * * * * * Functions * * * * *
  162. * * * * * * * * * * * * * * */
  163. /* The following function checks if the program has to use static or dynamic arrays*/
  164. static int set_alloc_mode(int total_parameters)
  165. {
  166. return (total_parameters <= STARPU_NMAXBUFS);
  167. }
  168. /* According to the allocation mode, modify handles_ptr and modes_ptr in static or dynamic */
  169. static void arrays_managing(int mode)
  170. {
  171. if (mode)
  172. {
  173. handles_ptr = &handles[0];
  174. modes_ptr = &modes[0];
  175. }
  176. else
  177. {
  178. _STARPU_MALLOC(handles_ptr, sizeof(*handles_ptr) * nb_parameters);
  179. _STARPU_MALLOC(modes_ptr, sizeof(*modes_ptr) * nb_parameters);
  180. }
  181. }
  182. /* Check if a handle hasn't been registered yet */
  183. static void variable_data_register_check(size_t * array_of_size, int nb_handles)
  184. {
  185. int h;
  186. for (h = 0 ; h < nb_handles ; h++)
  187. {
  188. if(reg_signal[h]) /* Get the register signal, and if it's 1 do ... */
  189. {
  190. struct handle * strhandle_tmp;
  191. /* Find the key that was stored in &handles_ptr[h] */
  192. HASH_FIND(hh, handles_hash, handles_ptr+h, sizeof(handles_ptr[h]), strhandle_tmp);
  193. STARPU_ASSERT(strhandle_tmp);
  194. starpu_variable_data_register(handles_ptr+h, STARPU_MAIN_RAM, (uintptr_t) 1, array_of_size[h]);
  195. strhandle_tmp->mem_ptr = handles_ptr[h];
  196. }
  197. }
  198. }
  199. void reset(void)
  200. {
  201. if (name != NULL)
  202. {
  203. free(name);
  204. name = NULL;
  205. }
  206. if (model != NULL)
  207. {
  208. free(model);
  209. model = NULL;
  210. }
  211. if (sizes_set != NULL)
  212. {
  213. free(sizes_set);
  214. sizes_set = NULL;
  215. }
  216. if (reg_signal != NULL)
  217. {
  218. free(reg_signal);
  219. reg_signal = NULL;
  220. }
  221. jobid = 0;
  222. ndependson = 0;
  223. tag = -1;
  224. workerid = -1;
  225. footprint = 0;
  226. startTime = 0.0;
  227. endTime = 0.0;
  228. if (submitorder != -1)
  229. submitorder = -1;
  230. iteration = -1;
  231. nb_parameters = 0;
  232. alloc_mode = 1;
  233. }
  234. /* Function that submits all the tasks (used when the program reaches EOF) */
  235. int submit_tasks(void)
  236. {
  237. /* Add dependencies */
  238. const struct starpu_rbtree * tmptree = &tree;
  239. while (!starpu_rbtree_empty(tmptree))
  240. {
  241. struct starpu_rbtree_node * currentNode = starpu_rbtree_first(tmptree);
  242. struct task * currentTask = (struct task *) currentNode;
  243. if (currentTask->ndependson > 0)
  244. {
  245. struct starpu_task * taskdeps[currentTask->ndependson];
  246. unsigned i;
  247. for (i = 0; i < currentTask->ndependson; i++)
  248. {
  249. struct task * taskdep;
  250. /* Get the ith jobid of deps_jobid */
  251. HASH_FIND(hh, tasks, &currentTask->deps[i], sizeof(jobid), taskdep);
  252. STARPU_ASSERT(taskdep);
  253. taskdeps[i] = &taskdep->task;
  254. }
  255. starpu_task_declare_deps_array(&currentTask->task, currentTask->ndependson, taskdeps);
  256. }
  257. if (!(currentTask->iteration == -1))
  258. starpu_iteration_push(currentTask->iteration);
  259. int ret_val = starpu_task_submit(&currentTask->task);
  260. if (!(currentTask->iteration == -1))
  261. starpu_iteration_pop();
  262. printf("submitting task %s (%lu, %llu)\n", currentTask->task.name?currentTask->task.name:"anonymous", currentTask->jobid, (unsigned long long) currentTask->task.tag_id /* tag*/);
  263. starpu_rbtree_remove(&tree, currentNode);
  264. //free(currentNode);
  265. tmptree = &tree;
  266. if (ret_val != 0)
  267. return -1;
  268. }
  269. return 1;
  270. }
  271. /* * * * * * * * * * * * * * * */
  272. /* * * * * * MAIN * * * * * * */
  273. /* * * * * * * * * * * * * * */
  274. int main(int argc, char **argv)
  275. {
  276. starpu_data_set_default_sequential_consistency_flag(0);
  277. FILE *rec;
  278. char *s;
  279. size_t s_allocated = 128;
  280. _STARPU_MALLOC(s, s_allocated);
  281. dependson_size = REPLAY_NMAX_DEPENDENCIES;
  282. _STARPU_MALLOC(dependson, dependson_size * sizeof (* dependson));
  283. alloc_mode = 1;
  284. if (argc <= 1)
  285. {
  286. fprintf(stderr,"Usage: %s tasks.rec [sched.rec]\n", argv[0]);
  287. exit(EXIT_FAILURE);
  288. }
  289. rec = fopen(argv[1], "r");
  290. if (!rec)
  291. {
  292. fprintf(stderr,"unable to open file %s: %s\n", argv[1], strerror(errno));
  293. exit(EXIT_FAILURE);
  294. }
  295. int ret = starpu_init(NULL);
  296. if (ret == -ENODEV) goto enodev;
  297. /* Read line by line, and on empty line submit the task with the accumulated information */
  298. reset();
  299. while(1)
  300. {
  301. char *ln;
  302. if (!fgets(s, s_allocated, rec))
  303. {
  304. int submitted = submit_tasks();
  305. if (submitted == -1)
  306. {
  307. goto enodev;
  308. }
  309. goto eof;
  310. }
  311. while (!(ln = strchr(s, '\n')))
  312. {
  313. /* fprintf(stderr,"buffer size %d too small, doubling it\n", s_allocated); */
  314. _STARPU_REALLOC(s, s_allocated * 2);
  315. if (!fgets(s + s_allocated-1, s_allocated+1, rec))
  316. {
  317. int submitted = submit_tasks();
  318. if (submitted == -1)
  319. {
  320. goto enodev;
  321. }
  322. goto eof;
  323. }
  324. s_allocated *= 2;
  325. }
  326. if (ln == s)
  327. {
  328. /* Empty line, do task */
  329. struct task * task;
  330. _STARPU_MALLOC(task, sizeof(*task));
  331. starpu_task_init(&task->task);
  332. if (submitorder != -1)
  333. {
  334. task->submit_order = submitorder;
  335. starpu_rbtree_node_init(&task->node);
  336. starpu_rbtree_insert(&tree, &task->node, diff);
  337. }
  338. task->jobid = jobid;
  339. task->iteration = iteration;
  340. if (name != NULL)
  341. task->task.name = strdup(name);
  342. /* Check workerid */
  343. if (workerid >= 0)
  344. {
  345. task->task.priority = priority;
  346. task->task.cl = &cl;
  347. task->task.workerid = workerid;
  348. if (alloc_mode)
  349. {
  350. /* Duplicating the handles stored (and registered in the current context) into the task */
  351. ARRAY_DUP(modes_ptr, task->task.modes, nb_parameters);
  352. ARRAY_DUP(modes_ptr, task->task.cl->modes, nb_parameters);
  353. variable_data_register_check(sizes_set, nb_parameters);
  354. ARRAY_DUP(handles_ptr, task->task.handles, nb_parameters);
  355. }
  356. else
  357. {
  358. task->task.dyn_modes = modes_ptr;
  359. _STARPU_MALLOC(task->task.cl->dyn_modes, (sizeof(*task->task.cl->dyn_modes) * nb_parameters));
  360. ARRAY_DUP(modes_ptr, task->task.cl->dyn_modes, nb_parameters);
  361. variable_data_register_check(sizes_set, nb_parameters);
  362. task->task.dyn_handles = handles_ptr;
  363. }
  364. task->task.nbuffers = nb_parameters;
  365. struct perfmodel * realmodel;
  366. HASH_FIND_STR(model_hash, model, realmodel);
  367. if (realmodel == NULL)
  368. {
  369. int len = strlen(model);
  370. _STARPU_CALLOC(realmodel, 1, sizeof(struct perfmodel));
  371. _STARPU_MALLOC(realmodel->model_name, sizeof(char) * (len+1));
  372. realmodel->model_name = strcpy(realmodel->model_name, model);
  373. starpu_perfmodel_init(&realmodel->perfmodel);
  374. HASH_ADD_STR(model_hash, model_name, realmodel);
  375. int error = starpu_perfmodel_load_symbol(model, &realmodel->perfmodel);
  376. if (error)
  377. {
  378. fprintf(stderr, "[starpu][Warning] Error loading perfmodel symbol");
  379. }
  380. }
  381. int narch = starpu_perfmodel_get_narch_combs();
  382. struct task_arg *arg;
  383. _STARPU_MALLOC(arg, sizeof(struct task_arg) + sizeof(double) * narch);
  384. arg->footprint = footprint;
  385. double * perfTime = arg->perf;
  386. int i;
  387. for (i = 0; i < narch ; i++)
  388. {
  389. struct starpu_perfmodel_arch *arch = starpu_perfmodel_arch_comb_fetch(i);
  390. perfTime[i] = starpu_perfmodel_history_based_expected_perf(&realmodel->perfmodel, arch, footprint);
  391. }
  392. task->task.cl_arg = arg;
  393. task->task.flops = flops;
  394. }
  395. task->task.cl_arg_size = 0;
  396. task->task.tag_id = tag;
  397. task->task.use_tag = 1;
  398. task->ndependson = ndependson;
  399. ARRAY_DUP(dependson, task->deps, ndependson);
  400. // TODO: call applyOrdoRec(task);
  401. //
  402. // Tag: 1234
  403. // Priority: 12
  404. // ExecuteOnSpecificWorker: 1
  405. // Workers: 0 1 2
  406. // DependsOn: 1235
  407. //
  408. // PrefetchTag: 1234
  409. // DependsOn: 1233
  410. /* Add this task to task hash */
  411. HASH_ADD(hh, tasks, jobid, sizeof(jobid), task);
  412. reset();
  413. }
  414. /* Record various information */
  415. #define TEST(field) (!strncmp(s, field": ", strlen(field) + 2))
  416. else if (TEST("Name"))
  417. {
  418. *ln = 0;
  419. name = strdup(s+6);
  420. }
  421. else if (TEST("Model"))
  422. {
  423. *ln = 0;
  424. model = strdup(s+7);
  425. }
  426. else if (TEST("JobId"))
  427. jobid = atol(s+7);
  428. else if(TEST("SubmitOrder"))
  429. submitorder = atoi(s+13);
  430. else if (TEST("DependsOn"))
  431. {
  432. char *c = s + 11;
  433. for (ndependson = 0; *c != '\n'; ndependson++)
  434. {
  435. if (ndependson >= dependson_size)
  436. {
  437. dependson_size *= 2;
  438. _STARPU_REALLOC(dependson, dependson_size * sizeof(*dependson));
  439. }
  440. dependson[ndependson] = strtol(c, &c, 10);
  441. }
  442. }
  443. else if (TEST("Tag"))
  444. tag = strtol(s+5, NULL, 16);
  445. else if (TEST("WorkerId"))
  446. workerid = atoi(s+10);
  447. else if (TEST("Footprint"))
  448. {
  449. footprint = strtoul(s+11, NULL, 16);
  450. }
  451. else if (TEST("Parameters"))
  452. {
  453. /* Parameters line format is PARAM1_PARAM2_(...)PARAMi_(...)PARAMn */
  454. char * param_str = s + 12;
  455. unsigned i;
  456. int count = 0;
  457. for (i = 0 ; param_str[i] != '\n'; i++)
  458. {
  459. if (param_str[i] == '_') /* Checking the number of '_' (underscore), assuming that the file is not corrupted */
  460. {
  461. count++;
  462. }
  463. }
  464. nb_parameters = count + 1; /* There is one underscore per paramater execept for the last one, that's why we have to add +1 (dirty programming) */
  465. alloc_mode = set_alloc_mode(nb_parameters);
  466. arrays_managing(alloc_mode);
  467. _STARPU_CALLOC(reg_signal, nb_parameters, sizeof(char));
  468. }
  469. else if (TEST("Handles"))
  470. {
  471. char *buffer = s + 9;
  472. const char *delim = " ";
  473. char *token = strtok(buffer, delim);
  474. while (token != NULL)
  475. {
  476. int i;
  477. for (i = 0 ; i < nb_parameters ; i++)
  478. {
  479. struct handle *handles_cell; /* A cell of the hash table for the handles */
  480. starpu_data_handle_t handle_value = (starpu_data_handle_t) strtol(token, NULL, 16); /* Get the ith handle on the line */
  481. HASH_FIND(hh, handles_hash, &handle_value, sizeof(handle_value), handles_cell); /* Find if the handle_value was already registered as a key in the hash table */
  482. if (handles_cell == NULL)
  483. {
  484. _STARPU_MALLOC(handles_cell, sizeof(*handles_cell));
  485. handles_cell->handle = handle_value;
  486. HASH_ADD(hh, handles_hash, handle, sizeof(handle_value), handles_cell); /* If it wasn't, then add it to the hash table */
  487. handles_ptr[i] = handle_value;
  488. reg_signal[i] = 1;
  489. }
  490. else
  491. {
  492. handles_ptr[i] = handles_cell->mem_ptr;
  493. }
  494. token = strtok(NULL, delim);
  495. }
  496. }
  497. }
  498. else if (TEST("Modes"))
  499. {
  500. char * buffer = s + 7;
  501. int mode_i = 0;
  502. int i = 0;
  503. const char * delim = " ";
  504. char * token = strtok(buffer, delim);
  505. while (token != NULL)
  506. {
  507. /* Subject to the names of starpu modes enumerator are not modified */
  508. if (!strncmp(token, "RW", 2))
  509. {
  510. *(modes_ptr+mode_i) = STARPU_RW;
  511. mode_i++;
  512. i++;
  513. }
  514. else if (!strncmp(token, "R", 1))
  515. {
  516. *(modes_ptr+mode_i) = STARPU_R;
  517. mode_i++;
  518. }
  519. else if (!strncmp(token, "W", 1))
  520. {
  521. *(modes_ptr+mode_i) = STARPU_W;
  522. mode_i++;
  523. }
  524. /* Other cases produce a warning*/
  525. else
  526. {
  527. fprintf(stderr, "[Warning] A mode is different from R/W (jobid task : %lu)", jobid);
  528. }
  529. token = strtok(NULL, delim);
  530. }
  531. }
  532. else if (TEST("Sizes"))
  533. {
  534. char * buffer = s + 7;
  535. const char * delim = " ";
  536. char * token = strtok(buffer, delim);
  537. int k = 0;
  538. _STARPU_MALLOC(sizes_set, nb_parameters * sizeof(size_t));
  539. while (token != NULL)
  540. {
  541. sizes_set[k] = strtol(token, NULL, 10);
  542. token = strtok(NULL, delim);
  543. k++;
  544. }
  545. }
  546. else if (TEST("StartTime"))
  547. {
  548. startTime = strtod(s+11, NULL);
  549. }
  550. else if (TEST("EndTime"))
  551. {
  552. endTime = strtod(s+9, NULL);
  553. }
  554. else if (TEST("GFlop"))
  555. {
  556. flops = 1000000000 * strtod(s+7, NULL);
  557. }
  558. else if (TEST("Iteration"))
  559. {
  560. iteration = (unsigned) strtol(s+11, NULL, 10);
  561. }
  562. else if (TEST("Priority"))
  563. {
  564. priority = strtol(s + 10, NULL, 10);
  565. }
  566. }
  567. eof:
  568. starpu_task_wait_for_all();
  569. /* FREE allocated memory */
  570. free(dependson);
  571. free(s);
  572. /* End of FREE */
  573. struct handle * handle,* handletmp;
  574. HASH_ITER(hh, handles_hash, handle, handletmp)
  575. {
  576. starpu_data_unregister(handle->mem_ptr);
  577. HASH_DEL(handles_hash, handle);
  578. free(handle);
  579. }
  580. struct perfmodel * model_s, * modeltmp;
  581. HASH_ITER(hh, model_hash, model_s, modeltmp)
  582. {
  583. starpu_perfmodel_unload_model(&model_s->perfmodel);
  584. HASH_DEL(model_hash, model_s);
  585. free(model_s->model_name);
  586. free(model_s);
  587. }
  588. struct task * task, *tasktmp;
  589. HASH_ITER(hh, tasks, task, tasktmp)
  590. {
  591. free(task->task.cl_arg);
  592. free((char*)task->task.name);
  593. if (task->task.dyn_handles != NULL)
  594. {
  595. free(task->task.dyn_handles);
  596. free(task->task.dyn_modes);
  597. }
  598. HASH_DEL(tasks, task);
  599. starpu_task_clean(&task->task);
  600. free(task);
  601. }
  602. starpu_shutdown();
  603. return 0;
  604. enodev:
  605. return 77;
  606. }