starpu_replay.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  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 <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 unsigned int submitorder;
  39. static starpu_tag_t tag;
  40. static int workerid;
  41. static uint32_t footprint;
  42. static double flops;
  43. static double startTime; //start time (The instant when the task starts)
  44. static double endTime; //end time (The instant when the task ends)
  45. static int iteration = -1;
  46. static starpu_data_handle_t handles[STARPU_NMAXBUFS];
  47. static enum starpu_data_access_mode modes[STARPU_NMAXBUFS];
  48. /* Use the following arrays when the number of data is greater than STARPU_NMAXBUFS */
  49. starpu_data_handle_t * handles_ptr;
  50. enum starpu_data_access_mode * modes_ptr;
  51. size_t * sizes_set;
  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 job_id;
  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 size_t 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 worker_id, struct starpu_task *task, unsigned nimpl)
  111. {
  112. struct starpu_perfmodel_arch * arch = starpu_worker_get_perf_archtype(worker_id, 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. unsigned i;
  141. for (i = 0 ; 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 job_id)
  148. {
  149. sd = malloc(sizeof(*sd));
  150. sd->job_id = 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. 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;
  164. for (i = 0 ; 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. submitorder = 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;
  241. for(j = 0; 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]->job_id, 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]->job_id, (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. task->task.submit_order = submitorder;
  338. /* Check workerid */
  339. if (workerid >= 0)
  340. {
  341. task->task.cl = &cl;
  342. task->task.workerid = workerid;
  343. if (alloc_mode)
  344. {
  345. /* Duplicating the handles stored (and registered in the current context) into the task */
  346. array_dup((unsigned long *) modes_ptr, (unsigned long *) task->task.modes, nb_parameters);
  347. array_dup((unsigned long *) modes_ptr, (unsigned long *) task->task.cl->modes, nb_parameters);
  348. variable_data_register_check(sizes_set, nb_parameters);
  349. array_dup((unsigned long *) handles_ptr, (unsigned long *) task->task.handles, nb_parameters);
  350. }
  351. else
  352. {
  353. task->task.dyn_modes = modes_ptr;
  354. task->task.cl->dyn_modes = malloc(sizeof(starpu_data_handle_t) * nb_parameters);
  355. array_dup((unsigned long *) modes_ptr, (unsigned long *) task->task.cl->dyn_modes, nb_parameters);
  356. variable_data_register_check(sizes_set, nb_parameters);
  357. task->task.dyn_handles = handles_ptr;
  358. }
  359. task->task.nbuffers = nb_parameters;
  360. struct perfmodel * realmodel;
  361. HASH_FIND_STR(model_hash, model, realmodel);
  362. if (realmodel == NULL)
  363. {
  364. int len = strlen(model);
  365. realmodel = calloc(1, sizeof(struct perfmodel));
  366. if (realmodel == NULL)
  367. {
  368. fprintf(stderr, "[starpu][Error] Not enough memory for allocation ! (replay.c)");
  369. exit(EXIT_FAILURE);
  370. }
  371. realmodel->model_name = (char *) malloc(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 = malloc(sizeof(struct task_arg) + sizeof(double) * narch);
  383. arg->footprint = footprint;
  384. double * perfTime = arg->perf;
  385. int i;
  386. for (i = 0; i < narch ; i++)
  387. {
  388. struct starpu_perfmodel_arch * arch = starpu_perfmodel_arch_comb_fetch(i);
  389. perfTime[i] = starpu_perfmodel_history_based_expected_perf(&realmodel->perfmodel, arch, footprint);
  390. }
  391. task->task.cl_arg = arg;
  392. task->task.flops = flops;
  393. }
  394. task->task.cl_arg_size = 0;
  395. task->task.tag_id = tag;
  396. task->task.use_tag = 1;
  397. s_dep * sd = s_dep_init(sd, jobid);
  398. array_dup((unsigned long *) dependson, (unsigned long *) sd->deps_jobid, ndependson);
  399. sd->ndependson = ndependson;
  400. if (ntask >= jobidDeps_size)
  401. {
  402. jobidDeps_size *= 2;
  403. jobidDeps = realloc(jobidDeps, jobidDeps_size * sizeof(*jobidDeps));
  404. }
  405. jobidDeps[ntask] = sd;
  406. ntask++;
  407. // TODO: call applyOrdoRec(task);
  408. //
  409. // Tag: 1234
  410. // Priority: 12
  411. // Workerid: 0 (-> ExecuteOnSpecificWorker)
  412. // Workers: 0 1 2
  413. // DependsOn: 1235
  414. //
  415. // PrefetchTag: 1234
  416. // DependsOn: 1233
  417. /* Add this task to task hash */
  418. HASH_ADD(hh, tasks, jobid, sizeof(jobid), task);
  419. reset();
  420. }
  421. /* Record various information */
  422. #define TEST(field) (!strncmp(s, field": ", strlen(field) + 2))
  423. else if (TEST("Name"))
  424. {
  425. *ln = 0;
  426. name = strdup(s+6);
  427. }
  428. else if (TEST("Model"))
  429. {
  430. *ln = 0;
  431. model = strdup(s+7);
  432. }
  433. else if (TEST("JobId"))
  434. jobid = atol(s+7);
  435. else if(TEST("SubmitOrder"))
  436. submitorder = atoi(s+13);
  437. else if (TEST("DependsOn"))
  438. {
  439. char *c = s + 11;
  440. for (ndependson = 0; *c != '\n'; ndependson++)
  441. {
  442. if (ndependson >= dependson_size)
  443. {
  444. dependson_size *= 2;
  445. dependson = realloc(dependson, dependson_size * sizeof(*dependson));
  446. }
  447. dependson[ndependson] = strtol(c, &c, 10);
  448. }
  449. }
  450. else if (TEST("Tag"))
  451. tag = strtol(s+5, NULL, 16);
  452. else if (TEST("WorkerId"))
  453. workerid = atoi(s+10);
  454. else if (TEST("Footprint"))
  455. {
  456. footprint = strtoul(s+11, NULL, 16);
  457. }
  458. else if (TEST("Parameters"))
  459. {
  460. /* Parameters line format is PARAM1_PARAM2_(...)PARAMi_(...)PARAMn */
  461. char * param_str = s + 12;
  462. unsigned i;
  463. int count = 0;
  464. for (i = 0 ; param_str[i] != '\n'; i++)
  465. {
  466. if (param_str[i] == '_') /* Checking the number of '_' (underscore), assuming that the file is not corrupted */
  467. {
  468. count++;
  469. }
  470. }
  471. 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) */
  472. alloc_mode = set_alloc_mode(nb_parameters);
  473. arrays_managing(alloc_mode);
  474. reg_signal = (char *) calloc(nb_parameters, sizeof(char));
  475. }
  476. else if (TEST("Handles"))
  477. {
  478. char * buffer = s + 9;
  479. const char * delim = " ";
  480. char * token = strtok(buffer, delim);
  481. while (token != NULL)
  482. {
  483. int i;
  484. for (i = 0 ; i < nb_parameters ; i++)
  485. {
  486. struct handle * handles_cell; /* A cell of the hash table for the handles */
  487. starpu_data_handle_t handle_value = (starpu_data_handle_t) strtol(token, NULL, 16); /* Get the ith handle on the line */
  488. 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 */
  489. if (handles_cell == NULL)
  490. {
  491. handles_cell = malloc(sizeof(*handles_cell));
  492. handles_cell->handle = handle_value;
  493. HASH_ADD(hh, handles_hash, handle, sizeof(handle_value), handles_cell); /* If it wasn't, then add it to the hash table */
  494. handles_ptr[i] = handle_value;
  495. reg_signal[i] = 1;
  496. }
  497. else
  498. {
  499. handles_ptr[i] = handles_cell->mem_ptr;
  500. }
  501. token = strtok(NULL, delim);
  502. }
  503. }
  504. }
  505. else if (TEST("Modes"))
  506. {
  507. char * buffer = s + 7;
  508. int mode_i = 0;
  509. int i = 0;
  510. const char * delim = " ";
  511. char * token = strtok(buffer, delim);
  512. while (token != NULL)
  513. {
  514. /* Subject to the names of starpu modes enumerator are not modified */
  515. if (!strncmp(token, "RW", 2))
  516. {
  517. *(modes_ptr+mode_i) = STARPU_RW;
  518. mode_i++;
  519. i++;
  520. }
  521. else if (!strncmp(token, "R", 1))
  522. {
  523. *(modes_ptr+mode_i) = STARPU_R;
  524. mode_i++;
  525. }
  526. else if (!strncmp(token, "W", 1))
  527. {
  528. *(modes_ptr+mode_i) = STARPU_W;
  529. mode_i++;
  530. }
  531. /* Other cases produce a warning*/
  532. else
  533. {
  534. fprintf(stderr, "[Warning] A mode is different from R/W (jobid task : %lu)", jobid);
  535. }
  536. token = strtok(NULL, delim);
  537. }
  538. }
  539. else if (TEST("Sizes"))
  540. {
  541. char * buffer = s + 7;
  542. const char * delim = " ";
  543. char * token = strtok(buffer, delim);
  544. int k = 0;
  545. sizes_set = (size_t *) malloc(nb_parameters * sizeof(size_t));
  546. while (token != NULL)
  547. {
  548. sizes_set[k] = strtol(token, NULL, 10);
  549. token = strtok(NULL, delim);
  550. k++;
  551. }
  552. }
  553. else if (TEST("StartTime"))
  554. {
  555. startTime = strtod(s+11, NULL);
  556. }
  557. else if (TEST("EndTime"))
  558. {
  559. endTime = strtod(s+9, NULL);
  560. }
  561. else if (TEST("GFlop"))
  562. {
  563. flops = 1000000000 * strtod(s+7, NULL);
  564. }
  565. else if (TEST("Iteration"))
  566. {
  567. iteration = (unsigned) strtol(s+11, NULL, 10);
  568. }
  569. else if (TEST("Priority"))
  570. {
  571. priority = strtol(s + 10, NULL, 10);
  572. }
  573. /* ignore */
  574. //else fprintf(stderr,"warning: unknown '%s' field\n", s);
  575. }
  576. eof:
  577. starpu_task_wait_for_all();
  578. /* FREE allocated memory */
  579. free(dependson);
  580. free(s);
  581. for (alloc_mode = 0; alloc_mode < ntask ; alloc_mode++)
  582. {
  583. s_dep_remove(jobidDeps[alloc_mode]);
  584. }
  585. free(jobidDeps);
  586. /* End of FREE */
  587. struct handle * handle,* handletmp;
  588. HASH_ITER(hh, handles_hash, handle, handletmp)
  589. {
  590. starpu_data_unregister(handle->mem_ptr);
  591. HASH_DEL(handles_hash, handle);
  592. free(handle);
  593. }
  594. starpu_shutdown();
  595. struct perfmodel * model_s, * modeltmp;
  596. HASH_ITER(hh, model_hash, model_s, modeltmp)
  597. {
  598. starpu_perfmodel_unload_model(&model_s->perfmodel);
  599. HASH_DEL(model_hash, model_s);
  600. free(model_s->model_name);
  601. free(model_s);
  602. }
  603. struct task * task, *tasktmp;
  604. HASH_ITER(hh, tasks, task, tasktmp)
  605. {
  606. free(task->task.cl_arg);
  607. free((char*)task->task.name);
  608. HASH_DEL(tasks, task);
  609. starpu_task_clean(&task->task);
  610. free(task);
  611. }
  612. return 0;
  613. enodev:
  614. return 77;
  615. }