replay.c 19 KB

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