starpu_replay.c 19 KB

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