starpu_replay.c 18 KB

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