starpu_replay.c 18 KB

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