sched_ctx_hypervisor.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011, 2012 INRIA
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <sched_ctx_hypervisor_intern.h>
  17. unsigned imposed_resize = 0;
  18. struct starpu_performance_counters* perf_counters = NULL;
  19. static void notify_idle_cycle(unsigned sched_ctx, int worker, double idle_time);
  20. static void notify_pushed_task(unsigned sched_ctx, int worker);
  21. static void notify_poped_task(unsigned sched_ctx, int worker, double flops);
  22. static void notify_post_exec_hook(unsigned sched_ctx, int taskid);
  23. static void notify_idle_end(unsigned sched_ctx, int worker);
  24. extern struct hypervisor_policy idle_policy;
  25. extern struct hypervisor_policy app_driven_policy;
  26. extern struct hypervisor_policy gflops_rate_policy;
  27. #ifdef HAVE_GLPK_H
  28. extern struct hypervisor_policy lp_policy;
  29. #endif
  30. static struct hypervisor_policy *predefined_policies[] = {
  31. &idle_policy,
  32. &app_driven_policy,
  33. #ifdef HAVE_GLPK_H
  34. &lp_policy,
  35. #endif
  36. &gflops_rate_policy
  37. };
  38. static void _load_hypervisor_policy(struct hypervisor_policy *policy)
  39. {
  40. STARPU_ASSERT(policy);
  41. #ifdef STARPU_VERBOSE
  42. if (policy->name)
  43. {
  44. _STARPU_DEBUG("Use %s hypervisor policy \n", policy->name);
  45. }
  46. #endif
  47. hypervisor.policy.name = policy->name;
  48. hypervisor.policy.handle_poped_task = policy->handle_poped_task;
  49. hypervisor.policy.handle_pushed_task = policy->handle_pushed_task;
  50. hypervisor.policy.handle_idle_cycle = policy->handle_idle_cycle;
  51. hypervisor.policy.handle_idle_end = policy->handle_idle_end;
  52. hypervisor.policy.handle_post_exec_hook = policy->handle_post_exec_hook;
  53. }
  54. static struct hypervisor_policy *_find_hypervisor_policy_from_name(const char *policy_name)
  55. {
  56. if (!policy_name)
  57. return NULL;
  58. unsigned i;
  59. for (i = 0; i < sizeof(predefined_policies)/sizeof(predefined_policies[0]); i++)
  60. {
  61. struct hypervisor_policy *p;
  62. p = predefined_policies[i];
  63. if (p->name)
  64. {
  65. if (strcmp(policy_name, p->name) == 0) {
  66. /* we found a policy with the requested name */
  67. return p;
  68. }
  69. }
  70. }
  71. fprintf(stderr, "Warning: hypervisor policy \"%s\" was not found, try \"help\" to get a list\n", policy_name);
  72. /* nothing was found */
  73. return NULL;
  74. }
  75. static struct hypervisor_policy *_select_hypervisor_policy(struct hypervisor_policy* hypervisor_policy)
  76. {
  77. struct hypervisor_policy *selected_policy = NULL;
  78. if(hypervisor_policy && hypervisor_policy->custom)
  79. return hypervisor_policy;
  80. /* we look if the application specified the name of a policy to load */
  81. const char *policy_name;
  82. if (hypervisor_policy && hypervisor_policy->name)
  83. {
  84. policy_name = hypervisor_policy->name;
  85. }
  86. else
  87. {
  88. policy_name = getenv("HYPERVISOR_POLICY");
  89. }
  90. if (policy_name)
  91. selected_policy = _find_hypervisor_policy_from_name(policy_name);
  92. /* Perhaps there was no policy that matched the name */
  93. if (selected_policy)
  94. return selected_policy;
  95. /* If no policy was specified, we use the idle policy as a default */
  96. return &idle_policy;
  97. }
  98. /* initializez the performance counters that starpu will use to retrive hints for resizing */
  99. struct starpu_performance_counters* sched_ctx_hypervisor_init(struct hypervisor_policy *hypervisor_policy)
  100. {
  101. hypervisor.min_tasks = 0;
  102. hypervisor.nsched_ctxs = 0;
  103. pthread_mutex_init(&act_hypervisor_mutex, NULL);
  104. int i;
  105. for(i = 0; i < STARPU_NMAX_SCHED_CTXS; i++)
  106. {
  107. hypervisor.resize[i] = 0;
  108. hypervisor.configurations[i] = NULL;
  109. hypervisor.sched_ctxs[i] = STARPU_NMAX_SCHED_CTXS;
  110. hypervisor.sched_ctx_w[i].sched_ctx = STARPU_NMAX_SCHED_CTXS;
  111. hypervisor.sched_ctx_w[i].config = NULL;
  112. hypervisor.sched_ctx_w[i].total_flops = 0.0;
  113. hypervisor.sched_ctx_w[i].remaining_flops = 0.0;
  114. hypervisor.sched_ctx_w[i].start_time = 0.0;
  115. hypervisor.sched_ctx_w[i].resize_ack.receiver_sched_ctx = -1;
  116. hypervisor.sched_ctx_w[i].resize_ack.moved_workers = NULL;
  117. hypervisor.sched_ctx_w[i].resize_ack.nmoved_workers = 0;
  118. hypervisor.sched_ctx_w[i].resize_ack.acked_workers = NULL;
  119. int j;
  120. for(j = 0; j < STARPU_NMAXWORKERS; j++)
  121. {
  122. hypervisor.sched_ctx_w[i].current_idle_time[j] = 0.0;
  123. hypervisor.sched_ctx_w[i].pushed_tasks[j] = 0;
  124. hypervisor.sched_ctx_w[i].poped_tasks[j] = 0;
  125. hypervisor.sched_ctx_w[i].elapsed_flops[j] = 0.0;
  126. hypervisor.sched_ctx_w[i].total_elapsed_flops[j] = 0.0;
  127. }
  128. }
  129. struct hypervisor_policy *selected_hypervisor_policy = _select_hypervisor_policy(hypervisor_policy);
  130. _load_hypervisor_policy(selected_hypervisor_policy);
  131. perf_counters = (struct starpu_performance_counters*)malloc(sizeof(struct starpu_performance_counters));
  132. perf_counters->notify_idle_cycle = notify_idle_cycle;
  133. perf_counters->notify_pushed_task = notify_pushed_task;
  134. perf_counters->notify_poped_task = notify_poped_task;
  135. perf_counters->notify_post_exec_hook = notify_post_exec_hook;
  136. perf_counters->notify_idle_end = notify_idle_end;
  137. starpu_notify_hypervisor_exists();
  138. return perf_counters;
  139. }
  140. char* sched_ctx_hypervisor_get_policy()
  141. {
  142. return hypervisor.policy.name;
  143. }
  144. /* the user can forbid the resizing process*/
  145. void sched_ctx_hypervisor_stop_resize(unsigned sched_ctx)
  146. {
  147. imposed_resize = 1;
  148. hypervisor.resize[sched_ctx] = 0;
  149. }
  150. /* the user can restart the resizing process*/
  151. void sched_ctx_hypervisor_start_resize(unsigned sched_ctx)
  152. {
  153. imposed_resize = 1;
  154. hypervisor.resize[sched_ctx] = 1;
  155. }
  156. void sched_ctx_hypervisor_shutdown(void)
  157. {
  158. printf("shutdown\n");
  159. int i;
  160. for(i = 0; i < STARPU_NMAX_SCHED_CTXS; i++)
  161. {
  162. if(hypervisor.sched_ctxs[i] != STARPU_NMAX_SCHED_CTXS && hypervisor.nsched_ctxs > 0)
  163. {
  164. sched_ctx_hypervisor_stop_resize(hypervisor.sched_ctxs[i]);
  165. sched_ctx_hypervisor_unregister_ctx(hypervisor.sched_ctxs[i]);
  166. }
  167. }
  168. perf_counters->notify_idle_cycle = NULL;
  169. perf_counters->notify_pushed_task = NULL;
  170. perf_counters->notify_poped_task = NULL;
  171. perf_counters->notify_post_exec_hook = NULL;
  172. perf_counters->notify_idle_end = NULL;
  173. free(perf_counters);
  174. perf_counters = NULL;
  175. pthread_mutex_destroy(&act_hypervisor_mutex);
  176. }
  177. /* the hypervisor is in charge only of the contexts registered to it*/
  178. void sched_ctx_hypervisor_register_ctx(unsigned sched_ctx, double total_flops)
  179. {
  180. hypervisor.configurations[sched_ctx] = (struct starpu_htbl32_node*)malloc(sizeof(struct starpu_htbl32_node));
  181. hypervisor.resize_requests[sched_ctx] = (struct starpu_htbl32_node*)malloc(sizeof(struct starpu_htbl32_node));
  182. _add_config(sched_ctx);
  183. hypervisor.sched_ctx_w[sched_ctx].sched_ctx = sched_ctx;
  184. hypervisor.sched_ctxs[hypervisor.nsched_ctxs++] = sched_ctx;
  185. hypervisor.sched_ctx_w[sched_ctx].total_flops = total_flops;
  186. hypervisor.sched_ctx_w[sched_ctx].remaining_flops = total_flops;
  187. if(strcmp(hypervisor.policy.name, "app_driven") == 0)
  188. hypervisor.resize[sched_ctx] = 1;
  189. }
  190. static int _get_first_free_sched_ctx(int *sched_ctxs, unsigned nsched_ctxs)
  191. {
  192. int i;
  193. for(i = 0; i < nsched_ctxs; i++)
  194. if(sched_ctxs[i] == STARPU_NMAX_SCHED_CTXS)
  195. return i;
  196. return STARPU_NMAX_SCHED_CTXS;
  197. }
  198. /* rearange array of sched_ctxs in order not to have {MAXVAL, MAXVAL, 5, MAXVAL, 7}
  199. and have instead {5, 7, MAXVAL, MAXVAL, MAXVAL}
  200. it is easier afterwards to iterate the array
  201. */
  202. static void _rearange_sched_ctxs(int *sched_ctxs, int old_nsched_ctxs)
  203. {
  204. int first_free_id = STARPU_NMAX_SCHED_CTXS;
  205. int i;
  206. for(i = 0; i < old_nsched_ctxs; i++)
  207. {
  208. if(sched_ctxs[i] != STARPU_NMAX_SCHED_CTXS)
  209. {
  210. first_free_id = _get_first_free_sched_ctx(sched_ctxs, old_nsched_ctxs);
  211. if(first_free_id != STARPU_NMAX_SCHED_CTXS)
  212. {
  213. sched_ctxs[first_free_id] = sched_ctxs[i];
  214. sched_ctxs[i] = STARPU_NMAX_SCHED_CTXS;
  215. }
  216. }
  217. }
  218. }
  219. /* unregistered contexts will no longer be resized */
  220. void sched_ctx_hypervisor_unregister_ctx(unsigned sched_ctx)
  221. {
  222. unsigned i;
  223. for(i = 0; i < hypervisor.nsched_ctxs; i++)
  224. {
  225. if(hypervisor.sched_ctxs[i] == sched_ctx)
  226. {
  227. hypervisor.sched_ctxs[i] = STARPU_NMAX_SCHED_CTXS;
  228. break;
  229. }
  230. }
  231. _rearange_sched_ctxs(hypervisor.sched_ctxs, hypervisor.nsched_ctxs);
  232. hypervisor.nsched_ctxs--;
  233. hypervisor.sched_ctx_w[sched_ctx].sched_ctx = STARPU_NMAX_SCHED_CTXS;
  234. _remove_config(sched_ctx);
  235. free(hypervisor.configurations[sched_ctx]);
  236. free(hypervisor.resize_requests[sched_ctx]);
  237. }
  238. static int get_ntasks( int *tasks)
  239. {
  240. int ntasks = 0;
  241. int j;
  242. for(j = 0; j < STARPU_NMAXWORKERS; j++)
  243. {
  244. ntasks += tasks[j];
  245. }
  246. return ntasks;
  247. }
  248. static void _get_cpus(int *workers, int nworkers, int *cpus, int *ncpus)
  249. {
  250. int i, worker;
  251. *ncpus = 0;
  252. for(i = 0; i < nworkers; i++)
  253. {
  254. worker = workers[i];
  255. enum starpu_archtype arch = starpu_worker_get_type(worker);
  256. if(arch == STARPU_CPU_WORKER)
  257. cpus[(*ncpus)++] = worker;
  258. }
  259. }
  260. /* actually move the workers: the cpus are moved, gpus are only shared */
  261. /* forbids another resize request before this one is take into account */
  262. void sched_ctx_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned receiver_sched_ctx, int* workers_to_move, unsigned nworkers_to_move)
  263. {
  264. if(nworkers_to_move > 0 && hypervisor.resize[sender_sched_ctx] && hypervisor.resize[receiver_sched_ctx])
  265. {
  266. int j;
  267. printf("resize ctx %d with", sender_sched_ctx);
  268. for(j = 0; j < nworkers_to_move; j++)
  269. printf(" %d", workers_to_move[j]);
  270. printf("\n");
  271. int *cpus = (int*) malloc(nworkers_to_move * sizeof(int));
  272. int ncpus;
  273. _get_cpus(workers_to_move, nworkers_to_move, cpus, &ncpus);
  274. if(ncpus != 0)
  275. starpu_remove_workers_from_sched_ctx(cpus, ncpus, sender_sched_ctx);
  276. starpu_add_workers_to_sched_ctx(workers_to_move, nworkers_to_move, receiver_sched_ctx);
  277. hypervisor.sched_ctx_w[sender_sched_ctx].resize_ack.receiver_sched_ctx = receiver_sched_ctx;
  278. hypervisor.sched_ctx_w[sender_sched_ctx].resize_ack.moved_workers = (int*)malloc(nworkers_to_move * sizeof(int));
  279. hypervisor.sched_ctx_w[sender_sched_ctx].resize_ack.nmoved_workers = nworkers_to_move;
  280. hypervisor.sched_ctx_w[sender_sched_ctx].resize_ack.acked_workers = (int*)malloc(nworkers_to_move * sizeof(int));
  281. int i;
  282. for(i = 0; i < nworkers_to_move; i++)
  283. {
  284. hypervisor.sched_ctx_w[sender_sched_ctx].current_idle_time[workers_to_move[i]] = 0.0;
  285. hypervisor.sched_ctx_w[sender_sched_ctx].resize_ack.moved_workers[i] = workers_to_move[i];
  286. hypervisor.sched_ctx_w[sender_sched_ctx].resize_ack.acked_workers[i] = 0;
  287. }
  288. hypervisor.resize[sender_sched_ctx] = 0;
  289. hypervisor.resize[receiver_sched_ctx] = 0;
  290. }
  291. return;
  292. }
  293. static void _set_elapsed_flops_per_sched_ctx(unsigned sched_ctx, double val)
  294. {
  295. int i;
  296. for(i = 0; i < STARPU_NMAXWORKERS; i++)
  297. hypervisor.sched_ctx_w[sched_ctx].elapsed_flops[i] = val;
  298. }
  299. double sched_ctx_hypervisor_get_elapsed_flops_per_sched_ctx(struct sched_ctx_wrapper* sc_w)
  300. {
  301. double ret_val = 0.0;
  302. int i;
  303. for(i = 0; i < STARPU_NMAXWORKERS; i++)
  304. ret_val += sc_w->elapsed_flops[i];
  305. return ret_val;
  306. }
  307. static unsigned _ack_resize_completed(unsigned sched_ctx, int worker)
  308. {
  309. struct resize_ack *resize_ack = NULL;
  310. unsigned sender_sched_ctx = STARPU_NMAX_SCHED_CTXS;
  311. if(hypervisor.nsched_ctxs > 0)
  312. {
  313. int i;
  314. for(i = 0; i < STARPU_NMAX_SCHED_CTXS; i++)
  315. {
  316. if(hypervisor.sched_ctxs[i] != STARPU_NMAX_SCHED_CTXS)
  317. {
  318. struct sched_ctx_wrapper *sc_w = &hypervisor.sched_ctx_w[hypervisor.sched_ctxs[i]];
  319. if(sc_w->resize_ack.receiver_sched_ctx != -1 &&
  320. sc_w->resize_ack.receiver_sched_ctx == sched_ctx)
  321. {
  322. resize_ack = &sc_w->resize_ack;
  323. sender_sched_ctx = hypervisor.sched_ctxs[i];
  324. break;
  325. }
  326. }
  327. }
  328. }
  329. /* if there is no ctx waiting for its ack return 1*/
  330. if(resize_ack == NULL)
  331. return 1;
  332. else
  333. {
  334. int *moved_workers = resize_ack->moved_workers;
  335. int nmoved_workers = resize_ack->nmoved_workers;
  336. int *acked_workers = resize_ack->acked_workers;
  337. int i;
  338. if(worker != -1)
  339. {
  340. for(i = 0; i < nmoved_workers; i++)
  341. {
  342. int moved_worker = moved_workers[i];
  343. if(moved_worker == worker && acked_workers[i] == 0)
  344. acked_workers[i] = 1;
  345. }
  346. }
  347. int nacked_workers = 0;
  348. for(i = 0; i < nmoved_workers; i++)
  349. {
  350. nacked_workers += (acked_workers[i] == 1);
  351. }
  352. unsigned resize_completed = (nacked_workers == nmoved_workers);
  353. unsigned receiver_sched_ctx = resize_ack->receiver_sched_ctx;
  354. /* if the permission to resize is not allowed by the user don't do it
  355. whatever the application says */
  356. if(resize_completed && !((hypervisor.resize[sched_ctx] == 0 || hypervisor.resize[receiver_sched_ctx] == 0) && imposed_resize) && worker == moved_workers[0])
  357. {
  358. /* info concerning only the gflops_rate strateg */
  359. struct sched_ctx_wrapper *sender_sc_w = &hypervisor.sched_ctx_w[sender_sched_ctx];
  360. struct sched_ctx_wrapper *receiver_sc_w = &hypervisor.sched_ctx_w[receiver_sched_ctx];
  361. double start_time = starpu_timing_now();
  362. sender_sc_w->start_time = start_time;
  363. sender_sc_w->remaining_flops = sender_sc_w->remaining_flops - sched_ctx_hypervisor_get_elapsed_flops_per_sched_ctx(sender_sc_w);
  364. _set_elapsed_flops_per_sched_ctx(sender_sched_ctx, 0.0);
  365. receiver_sc_w->start_time = start_time;
  366. receiver_sc_w->remaining_flops = receiver_sc_w->remaining_flops - sched_ctx_hypervisor_get_elapsed_flops_per_sched_ctx(receiver_sc_w);
  367. _set_elapsed_flops_per_sched_ctx(receiver_sched_ctx, 0.0);
  368. hypervisor.resize[sender_sched_ctx] = 1;
  369. hypervisor.resize[receiver_sched_ctx] = 1;
  370. /* if the user allowed resizing leave the decisions to the application */
  371. if(imposed_resize) imposed_resize = 0;
  372. resize_ack->receiver_sched_ctx = -1;
  373. resize_ack->nmoved_workers = 0;
  374. free(resize_ack->moved_workers);
  375. free(resize_ack->acked_workers);
  376. }
  377. return resize_completed;
  378. }
  379. return 0;
  380. }
  381. void sched_ctx_hypervisor_resize(unsigned sched_ctx, int task_tag)
  382. {
  383. _starpu_htbl_insert_32(&hypervisor.resize_requests[sched_ctx], (uint32_t)task_tag, (void*)sched_ctx);
  384. }
  385. /* notifies the hypervisor that the worker is no longer idle and a new task was pushed on its queue */
  386. static void notify_idle_end(unsigned sched_ctx, int worker)
  387. {
  388. if(hypervisor.nsched_ctxs > 1)
  389. {
  390. if(hypervisor.resize[sched_ctx])
  391. hypervisor.sched_ctx_w[sched_ctx].current_idle_time[worker] = 0.0;
  392. if(hypervisor.policy.handle_idle_end)
  393. hypervisor.policy.handle_idle_end(sched_ctx, worker);
  394. _ack_resize_completed(sched_ctx, worker);
  395. }
  396. }
  397. /* notifies the hypervisor that the worker spent another cycle in idle time */
  398. static void notify_idle_cycle(unsigned sched_ctx, int worker, double idle_time)
  399. {
  400. if(hypervisor.nsched_ctxs > 1)
  401. {
  402. if(hypervisor.resize[sched_ctx])
  403. {
  404. struct sched_ctx_wrapper *sc_w = &hypervisor.sched_ctx_w[sched_ctx];
  405. sc_w->current_idle_time[worker] += idle_time;
  406. if(hypervisor.policy.handle_idle_cycle)
  407. hypervisor.policy.handle_idle_cycle(sched_ctx, worker);
  408. }
  409. else
  410. _ack_resize_completed(sched_ctx, worker);
  411. }
  412. return;
  413. }
  414. /* notifies the hypervisor that a new task was pushed on the queue of the worker */
  415. static void notify_pushed_task(unsigned sched_ctx, int worker)
  416. {
  417. hypervisor.sched_ctx_w[sched_ctx].pushed_tasks[worker]++;
  418. if(hypervisor.sched_ctx_w[sched_ctx].total_flops != 0.0 && hypervisor.sched_ctx_w[sched_ctx].start_time == 0.0)
  419. hypervisor.sched_ctx_w[sched_ctx].start_time = starpu_timing_now();
  420. int ntasks = get_ntasks(hypervisor.sched_ctx_w[sched_ctx].pushed_tasks);
  421. if(hypervisor.min_tasks == 0 || (!(hypervisor.resize[sched_ctx] == 0 && imposed_resize) && ntasks == hypervisor.min_tasks))
  422. {
  423. hypervisor.resize[sched_ctx] = 1;
  424. if(imposed_resize) imposed_resize = 0;
  425. }
  426. if(hypervisor.policy.handle_pushed_task)
  427. hypervisor.policy.handle_pushed_task(sched_ctx, worker);
  428. }
  429. /* notifies the hypervisor that a task was poped from the queue of the worker */
  430. static void notify_poped_task(unsigned sched_ctx, int worker, double elapsed_flops)
  431. {
  432. hypervisor.sched_ctx_w[sched_ctx].poped_tasks[worker]++;
  433. hypervisor.sched_ctx_w[sched_ctx].elapsed_flops[worker] += elapsed_flops;
  434. hypervisor.sched_ctx_w[sched_ctx].total_elapsed_flops[worker] += elapsed_flops;
  435. if(hypervisor.nsched_ctxs > 1)
  436. {
  437. if(hypervisor.resize[sched_ctx])
  438. {
  439. if(hypervisor.policy.handle_poped_task)
  440. hypervisor.policy.handle_poped_task(sched_ctx, worker);
  441. }
  442. else
  443. _ack_resize_completed(sched_ctx, worker);
  444. }
  445. }
  446. /* notifies the hypervisor that a tagged task has just been executed */
  447. static void notify_post_exec_hook(unsigned sched_ctx, int task_tag)
  448. {
  449. STARPU_ASSERT(task_tag > 0);
  450. if(hypervisor.nsched_ctxs > 1)
  451. {
  452. unsigned conf_sched_ctx;
  453. int i;
  454. for(i = 0; i < hypervisor.nsched_ctxs; i++)
  455. {
  456. conf_sched_ctx = hypervisor.sched_ctxs[i];
  457. void *config = _starpu_htbl_search_32(hypervisor.configurations[conf_sched_ctx], (uint32_t)task_tag);
  458. if(config && config != hypervisor.configurations[conf_sched_ctx])
  459. {
  460. sched_ctx_hypervisor_set_config(conf_sched_ctx, config);
  461. free(config);
  462. _starpu_htbl_insert_32(&hypervisor.configurations[sched_ctx], (uint32_t)task_tag, NULL);
  463. }
  464. }
  465. /* for the app driven we have to wait for the resize to be available
  466. because the event is required to be executed at this specific moment */
  467. while(!_ack_resize_completed(sched_ctx, -1));
  468. if(hypervisor.resize[sched_ctx])
  469. {
  470. struct starpu_htbl32_node* resize_requests = hypervisor.resize_requests[sched_ctx];
  471. if(hypervisor.policy.handle_post_exec_hook)
  472. hypervisor.policy.handle_post_exec_hook(sched_ctx, resize_requests, task_tag);
  473. }
  474. }
  475. }
  476. struct sched_ctx_wrapper* sched_ctx_hypervisor_get_wrapper(unsigned sched_ctx)
  477. {
  478. return &hypervisor.sched_ctx_w[sched_ctx];
  479. }
  480. int* sched_ctx_hypervisor_get_sched_ctxs()
  481. {
  482. return hypervisor.sched_ctxs;
  483. }
  484. int sched_ctx_hypervisor_get_nsched_ctxs()
  485. {
  486. return hypervisor.nsched_ctxs;
  487. }