sched_ctx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. #include <core/sched_ctx.h>
  2. #include <common/config.h>
  3. #include <common/utils.h>
  4. #include <core/sched_policy.h>
  5. #include <profiling/profiling.h>
  6. static pthread_cond_t blocking_ths_cond = PTHREAD_COND_INITIALIZER;
  7. static pthread_cond_t wakeup_ths_cond = PTHREAD_COND_INITIALIZER;
  8. static pthread_mutex_t blocking_ths_mutex = PTHREAD_MUTEX_INITIALIZER;
  9. static int nblocked_ths = 0;
  10. unsigned _starpu_create_sched_ctx(const char *policy_name, int *workerids_in_ctx,
  11. int nworkerids_in_ctx, unsigned is_initial_sched,
  12. const char *sched_name)
  13. {
  14. struct starpu_machine_config_s *config = (struct starpu_machine_config_s *)_starpu_get_machine_config();
  15. STARPU_ASSERT(config->topology.nsched_ctxs < STARPU_NMAX_SCHED_CTXS - 1);
  16. struct starpu_sched_ctx *sched_ctx = &config->sched_ctxs[config->topology.nsched_ctxs];
  17. sched_ctx->sched_ctx_id = config->topology.nsched_ctxs;
  18. int nworkers = config->topology.nworkers;
  19. STARPU_ASSERT(nworkerids_in_ctx <= nworkers);
  20. sched_ctx->nworkers_in_ctx = nworkerids_in_ctx;
  21. sched_ctx->sched_policy = malloc(sizeof(struct starpu_sched_policy_s));
  22. sched_ctx->is_initial_sched = is_initial_sched;
  23. sched_ctx->sched_name = sched_name;
  24. PTHREAD_COND_INIT(&sched_ctx->submitted_cond, NULL);
  25. PTHREAD_MUTEX_INIT(&sched_ctx->submitted_mutex, NULL);
  26. sched_ctx->nsubmitted = 0;
  27. int j;
  28. /*all the workers are in this contex*/
  29. if(workerids_in_ctx == NULL)
  30. {
  31. for(j = 0; j < nworkers; j++)
  32. {
  33. sched_ctx->workerid[j] = j;
  34. struct starpu_worker_s *workerarg = _starpu_get_worker_struct(j);
  35. workerarg->sched_ctx[workerarg->nctxs++] = sched_ctx;
  36. }
  37. sched_ctx->nworkers_in_ctx = nworkers;
  38. }
  39. else
  40. {
  41. int i;
  42. for(i = 0; i < nworkerids_in_ctx; i++)
  43. {
  44. /*take care the user does not ask for a resource that does not exist*/
  45. STARPU_ASSERT( workerids_in_ctx[i] >= 0 && workerids_in_ctx[i] <= nworkers);
  46. sched_ctx->workerid[i] = workerids_in_ctx[i];
  47. for(j = 0; j < nworkers; j++)
  48. {
  49. if(sched_ctx->workerid[i] == j)
  50. {
  51. struct starpu_worker_s *workerarg = _starpu_get_worker_struct(j);
  52. workerarg->sched_ctx[workerarg->nctxs++] = sched_ctx;
  53. }
  54. }
  55. }
  56. }
  57. sched_ctx->sched_mutex = (pthread_mutex_t**)malloc(sched_ctx->nworkers_in_ctx * sizeof(pthread_mutex_t*));
  58. sched_ctx->sched_cond = (pthread_cond_t**)malloc(sched_ctx->nworkers_in_ctx *sizeof(pthread_cond_t*));
  59. _starpu_init_sched_policy(config, sched_ctx, policy_name);
  60. config->topology.nsched_ctxs++;
  61. return sched_ctx->sched_ctx_id;
  62. }
  63. void _starpu_decrement_nblocked_ths(void)
  64. {
  65. PTHREAD_MUTEX_LOCK(&blocking_ths_mutex);
  66. if(--nblocked_ths == 0)
  67. PTHREAD_COND_BROADCAST(&wakeup_ths_cond);
  68. PTHREAD_MUTEX_UNLOCK(&blocking_ths_mutex);
  69. }
  70. void _starpu_increment_nblocked_ths(int nworkers)
  71. {
  72. PTHREAD_MUTEX_LOCK(&blocking_ths_mutex);
  73. if (++nblocked_ths == nworkers)
  74. PTHREAD_COND_BROADCAST(&blocking_ths_cond);
  75. PTHREAD_MUTEX_UNLOCK(&blocking_ths_mutex);
  76. }
  77. static int _starpu_wait_for_all_threads_to_block(int nworkers)
  78. {
  79. PTHREAD_MUTEX_LOCK(&blocking_ths_mutex);
  80. while (nblocked_ths < nworkers)
  81. PTHREAD_COND_WAIT(&blocking_ths_cond, &blocking_ths_mutex);
  82. PTHREAD_MUTEX_UNLOCK(&blocking_ths_mutex);
  83. return 0;
  84. }
  85. static int _starpu_wait_for_all_threads_to_wake_up(void)
  86. {
  87. PTHREAD_MUTEX_LOCK(&blocking_ths_mutex);
  88. while (nblocked_ths > 0)
  89. PTHREAD_COND_WAIT(&wakeup_ths_cond, &blocking_ths_mutex);
  90. PTHREAD_MUTEX_UNLOCK(&blocking_ths_mutex);
  91. return 0;
  92. }
  93. static int set_changing_ctx_flag(starpu_worker_status changing_ctx, int nworkerids_in_ctx, int *workerids_in_ctx)
  94. {
  95. struct starpu_machine_config_s *config = _starpu_get_machine_config();
  96. int i;
  97. int nworkers = nworkerids_in_ctx == -1 ? (int)config->topology.nworkers : nworkerids_in_ctx;
  98. struct starpu_worker_s *worker = NULL;
  99. pthread_mutex_t *changing_ctx_mutex = NULL;
  100. pthread_cond_t *changing_ctx_cond = NULL;
  101. int workerid = -1;
  102. for(i = 0; i < nworkers; i++)
  103. {
  104. workerid = workerids_in_ctx == NULL ? i : workerids_in_ctx[i];
  105. worker = _starpu_get_worker_struct(workerid);
  106. changing_ctx_mutex = &worker->changing_ctx_mutex;
  107. changing_ctx_cond = &worker->changing_ctx_cond;
  108. /*if the status is CHANGING_CTX let the thread know that it must block*/
  109. PTHREAD_MUTEX_LOCK(changing_ctx_mutex);
  110. worker->status = changing_ctx;
  111. worker->nworkers_of_next_ctx = nworkers;
  112. PTHREAD_MUTEX_UNLOCK(changing_ctx_mutex);
  113. /*if we have finished changing the ctx wake up the blocked threads*/
  114. if(changing_ctx == STATUS_UNKNOWN)
  115. {
  116. PTHREAD_MUTEX_LOCK(changing_ctx_mutex);
  117. PTHREAD_COND_SIGNAL(changing_ctx_cond);
  118. PTHREAD_MUTEX_UNLOCK(changing_ctx_mutex);
  119. }
  120. }
  121. /*after letting know all the concerned threads about the change
  122. wait for them to take into account the info*/
  123. if(changing_ctx == STATUS_CHANGING_CTX)
  124. _starpu_wait_for_all_threads_to_block(nworkers);
  125. else
  126. _starpu_wait_for_all_threads_to_wake_up();
  127. return 0;
  128. }
  129. unsigned starpu_create_sched_ctx(const char *policy_name, int *workerids_in_ctx,
  130. int nworkerids_in_ctx, const char *sched_name)
  131. {
  132. unsigned ret;
  133. /* block the workers until the contex is switched */
  134. set_changing_ctx_flag(STATUS_CHANGING_CTX, nworkerids_in_ctx, workerids_in_ctx);
  135. ret = _starpu_create_sched_ctx(policy_name, workerids_in_ctx, nworkerids_in_ctx, 0, sched_name);
  136. /* also wait the workers to wake up before using the context */
  137. set_changing_ctx_flag(STATUS_UNKNOWN, nworkerids_in_ctx, workerids_in_ctx);
  138. return ret;
  139. }
  140. static unsigned _starpu_worker_belongs_to_ctx(struct starpu_worker_s *workerarg, struct starpu_sched_ctx *sched_ctx)
  141. {
  142. unsigned i;
  143. for(i = 0; i < workerarg->nctxs; i++)
  144. if(sched_ctx != NULL && workerarg->sched_ctx[i] == sched_ctx
  145. && workerarg->status != STATUS_JOINED)
  146. return 1;
  147. return 0;
  148. }
  149. static void _starpu_remove_sched_ctx_from_worker(struct starpu_worker_s *workerarg, struct starpu_sched_ctx *sched_ctx)
  150. {
  151. unsigned i;
  152. unsigned to_remove = 0;
  153. for(i = 0; i < workerarg->nctxs; i++)
  154. {
  155. if(sched_ctx != NULL && workerarg->sched_ctx[i] == sched_ctx
  156. && workerarg->status != STATUS_JOINED)
  157. {
  158. workerarg->sched_ctx[i] = NULL;
  159. to_remove = 1;
  160. break;
  161. }
  162. }
  163. /* if the the worker had belonged to the context it would have been found in the worker's list of sched_ctxs, so it can be removed */
  164. if(to_remove)
  165. workerarg->nctxs--;
  166. return;
  167. }
  168. static void _starpu_manage_delete_sched_ctx(struct starpu_sched_ctx *sched_ctx)
  169. {
  170. int nworkers = sched_ctx->nworkers_in_ctx;
  171. int workerid;
  172. int i;
  173. for(i = 0; i < nworkers; i++)
  174. {
  175. workerid = sched_ctx->workerid[i];
  176. struct starpu_worker_s *workerarg = _starpu_get_worker_struct(workerid);
  177. _starpu_remove_sched_ctx_from_worker(workerarg, sched_ctx);
  178. }
  179. free(sched_ctx->sched_policy);
  180. free(sched_ctx->sched_mutex);
  181. free(sched_ctx->sched_cond);
  182. sched_ctx->sched_policy = NULL;
  183. struct starpu_machine_config_s *config = _starpu_get_machine_config();
  184. config->topology.nsched_ctxs--;
  185. }
  186. void starpu_delete_sched_ctx(unsigned sched_ctx_id)
  187. {
  188. if(!starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx_id))
  189. {
  190. struct starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx(sched_ctx_id);
  191. /* block the workers until the contex is switched */
  192. set_changing_ctx_flag(STATUS_CHANGING_CTX, sched_ctx->nworkers_in_ctx, sched_ctx->workerid);
  193. _starpu_manage_delete_sched_ctx(sched_ctx);
  194. /* also wait the workers to wake up before using the context */
  195. set_changing_ctx_flag(STATUS_UNKNOWN, sched_ctx->nworkers_in_ctx, sched_ctx->workerid);
  196. }
  197. return;
  198. }
  199. void _starpu_delete_all_sched_ctxs()
  200. {
  201. struct starpu_machine_config_s *config = _starpu_get_machine_config();
  202. unsigned nsched_ctxs = config->topology.nsched_ctxs;
  203. unsigned i;
  204. for(i = 0; i < nsched_ctxs; i++)
  205. {
  206. if(!starpu_wait_for_all_tasks_of_sched_ctx(i))
  207. {
  208. struct starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx(i);
  209. _starpu_manage_delete_sched_ctx(sched_ctx);
  210. }
  211. }
  212. return;
  213. }
  214. int starpu_wait_for_all_tasks_of_worker(int workerid)
  215. {
  216. if (STARPU_UNLIKELY(!_starpu_worker_may_perform_blocking_calls()))
  217. return -EDEADLK;
  218. struct starpu_worker_s *worker = _starpu_get_worker_struct(workerid);
  219. PTHREAD_MUTEX_LOCK(&worker->submitted_mutex);
  220. while (worker->nsubmitted > 0)
  221. PTHREAD_COND_WAIT(&worker->submitted_cond, &worker->submitted_mutex);
  222. PTHREAD_MUTEX_UNLOCK(&worker->submitted_mutex);
  223. return 0;
  224. }
  225. int starpu_wait_for_all_tasks_of_workers(int *workerids_in_ctx, int nworkerids_in_ctx){
  226. int ret_val = 0;
  227. struct starpu_machine_config_s *config = _starpu_get_machine_config();
  228. int nworkers = nworkerids_in_ctx == -1 ? (int)config->topology.nworkers : nworkerids_in_ctx;
  229. int workerid = -1;
  230. int i, n;
  231. for(i = 0; i < nworkers; i++)
  232. {
  233. workerid = workerids_in_ctx == NULL ? i : workerids_in_ctx[i];
  234. n = starpu_wait_for_all_tasks_of_worker(workerid);
  235. ret_val = (ret_val && n);
  236. }
  237. return ret_val;
  238. }
  239. void _starpu_decrement_nsubmitted_tasks_of_worker(int workerid)
  240. {
  241. struct starpu_worker_s *worker = _starpu_get_worker_struct(workerid);
  242. PTHREAD_MUTEX_LOCK(&worker->submitted_mutex);
  243. if (--worker->nsubmitted == 0)
  244. PTHREAD_COND_BROADCAST(&worker->submitted_cond);
  245. PTHREAD_MUTEX_UNLOCK(&worker->submitted_mutex);
  246. return;
  247. }
  248. void _starpu_increment_nsubmitted_tasks_of_worker(int workerid)
  249. {
  250. struct starpu_worker_s *worker = _starpu_get_worker_struct(workerid);
  251. PTHREAD_MUTEX_LOCK(&worker->submitted_mutex);
  252. worker->nsubmitted++;
  253. PTHREAD_MUTEX_UNLOCK(&worker->submitted_mutex);
  254. return;
  255. }
  256. static void _starpu_add_workers_to_sched_ctx(int *workerids_in_ctx, int nworkerids_in_ctx,
  257. struct starpu_sched_ctx *sched_ctx)
  258. {
  259. struct starpu_machine_config_s *config = (struct starpu_machine_config_s *)_starpu_get_machine_config();
  260. int nworkers = config->topology.nworkers;
  261. STARPU_ASSERT((nworkerids_in_ctx + sched_ctx->nworkers_in_ctx) <= nworkers);
  262. int nworkerids_already_in_ctx = sched_ctx->nworkers_in_ctx;
  263. int j;
  264. /*if null add the rest of the workers which don't already belong to this ctx*/
  265. if(workerids_in_ctx == NULL)
  266. {
  267. for(j = 0; j < nworkers; j++)
  268. {
  269. struct starpu_worker_s *workerarg = _starpu_get_worker_struct(j);
  270. if(!_starpu_worker_belongs_to_ctx(workerarg, sched_ctx))
  271. {
  272. sched_ctx->workerid[++nworkerids_already_in_ctx] = j;
  273. workerarg->sched_ctx[workerarg->nctxs++] = sched_ctx;
  274. }
  275. sched_ctx->nworkers_in_ctx = nworkers;
  276. }
  277. }
  278. else
  279. {
  280. int i;
  281. for(i = 0; i < nworkerids_in_ctx; i++)
  282. {
  283. /*take care the user does not ask for a resource that does not exist*/
  284. STARPU_ASSERT( workerids_in_ctx[i] >= 0 && workerids_in_ctx[i] <= nworkers);
  285. sched_ctx->workerid[ nworkerids_already_in_ctx + i] = workerids_in_ctx[i];
  286. for(j = 0; j < nworkers; j++)
  287. {
  288. if(sched_ctx->workerid[i] == j)
  289. {
  290. struct starpu_worker_s *workerarg = _starpu_get_worker_struct(j);
  291. workerarg->sched_ctx[workerarg->nctxs++] = sched_ctx;
  292. }
  293. }
  294. }
  295. sched_ctx->nworkers_in_ctx += nworkerids_in_ctx;
  296. }
  297. sched_ctx->sched_policy->init_sched_for_workers(sched_ctx->sched_ctx_id, nworkerids_in_ctx);
  298. return;
  299. }
  300. void starpu_add_workers_to_sched_ctx(int *workerids_in_ctx, int nworkerids_in_ctx,
  301. unsigned sched_ctx_id)
  302. {
  303. struct starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx(sched_ctx_id);
  304. /* block the workers until the contex is switched */
  305. set_changing_ctx_flag(STATUS_CHANGING_CTX, nworkerids_in_ctx, workerids_in_ctx);
  306. _starpu_add_workers_to_sched_ctx(workerids_in_ctx, nworkerids_in_ctx, sched_ctx);
  307. /* also wait the workers to wake up before using the context */
  308. set_changing_ctx_flag(STATUS_UNKNOWN, nworkerids_in_ctx, workerids_in_ctx);
  309. return;
  310. }
  311. static int _starpu_get_first_free_space(int *workerids, int old_nworkerids_in_ctx)
  312. {
  313. int i;
  314. for(i = 0; i < old_nworkerids_in_ctx; i++)
  315. if(workerids[i] == -1)
  316. return i;
  317. return -1;
  318. }
  319. /* rearange array of workerids in order not to have {-1, -1, 5, -1, 7}
  320. and have instead {5, 7, -1, -1, -1}
  321. it is easier afterwards to iterate the array
  322. */
  323. static void _starpu_rearange_sched_ctx_workerids(struct starpu_sched_ctx *sched_ctx, int old_nworkerids_in_ctx)
  324. {
  325. int first_free_id = -1;
  326. int i;
  327. for(i = 0; i < old_nworkerids_in_ctx; i++)
  328. {
  329. if(sched_ctx->workerid[i] != -1)
  330. {
  331. first_free_id = _starpu_get_first_free_space(sched_ctx->workerid,
  332. old_nworkerids_in_ctx);
  333. if(first_free_id != -1)
  334. {
  335. sched_ctx->workerid[first_free_id] = sched_ctx->workerid[i];
  336. sched_ctx->workerid[i] = -1;
  337. }
  338. }
  339. }
  340. }
  341. static void _starpu_remove_workers_from_sched_ctx(int *workerids_in_ctx, int nworkerids_in_ctx,
  342. struct starpu_sched_ctx *sched_ctx)
  343. {
  344. struct starpu_machine_config_s *config = (struct starpu_machine_config_s *)_starpu_get_machine_config();
  345. int nworkers = config->topology.nworkers;
  346. int nworkerids_already_in_ctx = sched_ctx->nworkers_in_ctx;
  347. STARPU_ASSERT(nworkerids_in_ctx <= nworkerids_already_in_ctx);
  348. int i, workerid;
  349. /*if null remove all the workers that belong to this ctx*/
  350. if(workerids_in_ctx == NULL)
  351. {
  352. for(i = 0; i < nworkerids_already_in_ctx; i++)
  353. {
  354. workerid = sched_ctx->workerid[i];
  355. struct starpu_worker_s *workerarg = _starpu_get_worker_struct(workerid);
  356. _starpu_remove_sched_ctx_from_worker(workerarg, sched_ctx);
  357. sched_ctx->workerid[i] = -1;
  358. }
  359. sched_ctx->nworkers_in_ctx = 0;
  360. }
  361. else
  362. {
  363. for(i = 0; i < nworkerids_in_ctx; i++)
  364. {
  365. workerid = workerids_in_ctx[i];
  366. /* take care the user does not ask for a resource that does not exist */
  367. STARPU_ASSERT( workerid >= 0 && workerid <= nworkers);
  368. struct starpu_worker_s *workerarg = _starpu_get_worker_struct(workerid);
  369. _starpu_remove_sched_ctx_from_worker(workerarg, sched_ctx);
  370. int j;
  371. /* don't leave the workerid with a correct value even if we don't use it anymore */
  372. for(j = 0; j < nworkerids_already_in_ctx; j++)
  373. if(sched_ctx->workerid[j] == workerid)
  374. sched_ctx->workerid[j] = -1;
  375. }
  376. sched_ctx->nworkers_in_ctx -= nworkerids_in_ctx;
  377. _starpu_rearange_sched_ctx_workerids(sched_ctx, nworkerids_already_in_ctx);
  378. }
  379. return;
  380. }
  381. void starpu_remove_workers_from_sched_ctx(int *workerids_in_ctx, int nworkerids_in_ctx,
  382. unsigned sched_ctx_id)
  383. {
  384. /* wait for the workers concerned by the change of contex
  385. * to finish their work in the previous context */
  386. if(!starpu_wait_for_all_tasks_of_workers(workerids_in_ctx, nworkerids_in_ctx))
  387. {
  388. struct starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx(sched_ctx_id);
  389. /* block the workers until the contex is switched */
  390. set_changing_ctx_flag(STATUS_CHANGING_CTX, nworkerids_in_ctx, workerids_in_ctx);
  391. _starpu_remove_workers_from_sched_ctx(workerids_in_ctx, nworkerids_in_ctx, sched_ctx);
  392. /* also wait the workers to wake up before using the context */
  393. set_changing_ctx_flag(STATUS_UNKNOWN, nworkerids_in_ctx, workerids_in_ctx);
  394. }
  395. return;
  396. }
  397. int starpu_wait_for_all_tasks_of_sched_ctx(unsigned sched_ctx_id)
  398. {
  399. struct starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx(sched_ctx_id);
  400. if (STARPU_UNLIKELY(!_starpu_worker_may_perform_blocking_calls()))
  401. return -EDEADLK;
  402. PTHREAD_MUTEX_LOCK(&sched_ctx->submitted_mutex);
  403. while (sched_ctx->nsubmitted > 0)
  404. PTHREAD_COND_WAIT(&sched_ctx->submitted_cond, &sched_ctx->submitted_mutex);
  405. PTHREAD_MUTEX_UNLOCK(&sched_ctx->submitted_mutex);
  406. return 0;
  407. }
  408. void _starpu_decrement_nsubmitted_tasks_of_sched_ctx(struct starpu_sched_ctx *sched_ctx)
  409. {
  410. PTHREAD_MUTEX_LOCK(&sched_ctx->submitted_mutex);
  411. if (--sched_ctx->nsubmitted == 0)
  412. PTHREAD_COND_BROADCAST(&sched_ctx->submitted_cond);
  413. PTHREAD_MUTEX_UNLOCK(&sched_ctx->submitted_mutex);
  414. }
  415. void _starpu_increment_nsubmitted_tasks_of_sched_ctx(struct starpu_sched_ctx *sched_ctx)
  416. {
  417. PTHREAD_MUTEX_LOCK(&sched_ctx->submitted_mutex);
  418. sched_ctx->nsubmitted++;
  419. PTHREAD_MUTEX_UNLOCK(&sched_ctx->submitted_mutex);
  420. }
  421. int _starpu_get_index_in_ctx_of_workerid(unsigned sched_ctx_id, unsigned workerid)
  422. {
  423. struct starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx(sched_ctx_id);
  424. int nworkers_in_ctx = sched_ctx->nworkers_in_ctx;
  425. int i;
  426. for(i = 0; i < nworkers_in_ctx; i++)
  427. if(sched_ctx->workerid[i] == (int)workerid)
  428. return i;
  429. return -1;
  430. }
  431. pthread_mutex_t *_starpu_get_sched_mutex(struct starpu_sched_ctx *sched_ctx, int worker)
  432. {
  433. int workerid_ctx = _starpu_get_index_in_ctx_of_workerid(sched_ctx->sched_ctx_id, worker);
  434. return sched_ctx->sched_mutex[workerid_ctx];
  435. }
  436. pthread_cond_t *_starpu_get_sched_cond(struct starpu_sched_ctx *sched_ctx, int worker)
  437. {
  438. int workerid_ctx = _starpu_get_index_in_ctx_of_workerid(sched_ctx->sched_ctx_id, worker);
  439. return sched_ctx->sched_cond[workerid_ctx];
  440. }