replay.c 19 KB

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