simgrid.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012-2015 Université de Bordeaux
  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 <starpu.h>
  17. #include <datawizard/memory_nodes.h>
  18. #include <common/config.h>
  19. #ifdef HAVE_UNISTD_H
  20. #include <unistd.h>
  21. #endif
  22. #include <core/perfmodel/perfmodel.h>
  23. #include <core/workers.h>
  24. #include <core/simgrid.h>
  25. #ifdef STARPU_SIMGRID
  26. #include <sys/resource.h>
  27. #pragma weak starpu_main
  28. extern int starpu_main(int argc, char *argv[]);
  29. #pragma weak smpi_main
  30. extern int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[]);
  31. #pragma weak smpi_simulated_main_
  32. extern int smpi_simulated_main_(int argc, char *argv[]);
  33. #pragma weak _starpu_mpi_simgrid_init
  34. extern int _starpu_mpi_simgrid_init(int argc, char *argv[]);
  35. struct main_args
  36. {
  37. int argc;
  38. char **argv;
  39. };
  40. int do_starpu_main(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[])
  41. {
  42. struct main_args *args = (void*) argv;
  43. return starpu_main(args->argc, args->argv);
  44. }
  45. #ifdef HAVE_MSG_ENVIRONMENT_GET_ROUTING_ROOT
  46. #ifdef HAVE_MSG_GET_AS_BY_NAME
  47. msg_as_t _starpu_simgrid_get_as_by_name(const char *name)
  48. {
  49. return MSG_get_as_by_name(name);
  50. }
  51. #else /* HAVE_MSG_GET_AS_BY_NAME */
  52. static msg_as_t __starpu_simgrid_get_as_by_name(msg_as_t root, const char *name)
  53. {
  54. xbt_dict_t dict;
  55. xbt_dict_cursor_t cursor;
  56. const char *key;
  57. msg_as_t as, ret;
  58. dict = MSG_environment_as_get_routing_sons(root);
  59. xbt_dict_foreach(dict, cursor, key, as)
  60. {
  61. if (!strcmp(MSG_environment_as_get_name(as), name))
  62. return as;
  63. ret = __starpu_simgrid_get_as_by_name(as, name);
  64. if (ret)
  65. return ret;
  66. }
  67. return NULL;
  68. }
  69. msg_as_t _starpu_simgrid_get_as_by_name(const char *name)
  70. {
  71. return __starpu_simgrid_get_as_by_name(MSG_environment_get_routing_root(), name);
  72. }
  73. #endif /* HAVE_MSG_GET_AS_BY_NAME */
  74. #endif /* HAVE_MSG_ENVIRONMENT_GET_ROUTING_ROOT */
  75. int _starpu_simgrid_get_nbhosts(const char *prefix)
  76. {
  77. int ret;
  78. xbt_dynar_t hosts;
  79. unsigned i, nb;
  80. unsigned len = strlen(prefix);
  81. #ifdef HAVE_MSG_ENVIRONMENT_GET_ROUTING_ROOT
  82. char new_prefix[32];
  83. if (_starpu_simgrid_running_smpi())
  84. {
  85. char name[32];
  86. STARPU_ASSERT(starpu_mpi_world_rank);
  87. snprintf(name, sizeof(name), STARPU_MPI_AS_PREFIX"%u", starpu_mpi_world_rank());
  88. hosts = MSG_environment_as_get_hosts(_starpu_simgrid_get_as_by_name(name));
  89. len = snprintf(new_prefix, sizeof(new_prefix), "%s-%s", name, prefix);
  90. prefix = new_prefix;
  91. len = strlen(prefix);
  92. }
  93. else
  94. #endif /* HAVE_MSG_ENVIRONMENT_GET_ROUTING_ROOT */
  95. hosts = MSG_hosts_as_dynar();
  96. nb = xbt_dynar_length(hosts);
  97. ret = 0;
  98. for (i = 0; i < nb; i++)
  99. {
  100. const char *name;
  101. name = MSG_host_get_name(xbt_dynar_get_as(hosts, i, msg_host_t));
  102. if (!strncmp(name, prefix, len))
  103. ret++;
  104. }
  105. xbt_dynar_free(&hosts);
  106. return ret;
  107. }
  108. unsigned long long _starpu_simgrid_get_memsize(const char *prefix, unsigned devid)
  109. {
  110. char name[32];
  111. msg_host_t host;
  112. const char *memsize;
  113. snprintf(name, sizeof(name), "%s%u", prefix, devid);
  114. host = _starpu_simgrid_get_host_by_name(name);
  115. if (!host)
  116. return 0;
  117. if (!MSG_host_get_properties(host))
  118. return 0;
  119. memsize = MSG_host_get_property_value(host, "memsize");
  120. if (!memsize)
  121. return 0;
  122. return atoll(memsize);
  123. }
  124. msg_host_t _starpu_simgrid_get_host_by_name(const char *name)
  125. {
  126. if (_starpu_simgrid_running_smpi())
  127. {
  128. char mpiname[32];
  129. STARPU_ASSERT(starpu_mpi_world_rank);
  130. snprintf(mpiname, sizeof(mpiname), STARPU_MPI_AS_PREFIX"%d-%s", starpu_mpi_world_rank(), name);
  131. return MSG_get_host_by_name(mpiname);
  132. }
  133. else
  134. return MSG_get_host_by_name(name);
  135. }
  136. msg_host_t _starpu_simgrid_get_host_by_worker(struct _starpu_worker *worker)
  137. {
  138. char *prefix;
  139. char name[16];
  140. msg_host_t host;
  141. switch (worker->arch)
  142. {
  143. case STARPU_CPU_WORKER:
  144. prefix = "CPU";
  145. break;
  146. case STARPU_CUDA_WORKER:
  147. prefix = "CUDA";
  148. break;
  149. case STARPU_OPENCL_WORKER:
  150. prefix = "OpenCL";
  151. break;
  152. default:
  153. STARPU_ASSERT(0);
  154. }
  155. snprintf(name, sizeof(name), "%s%d", prefix, worker->devid);
  156. host = _starpu_simgrid_get_host_by_name(name);
  157. STARPU_ASSERT_MSG(host, "Could not find host %s!", name);
  158. return host;
  159. }
  160. #ifdef STARPU_DEVEL
  161. #warning TODO: use another way to start main, when simgrid provides it, and then include the application-provided configuration for platform numbers
  162. #endif
  163. #undef main
  164. int main(int argc, char **argv)
  165. {
  166. char path[256];
  167. if (!starpu_main && !(smpi_main && smpi_simulated_main_))
  168. {
  169. _STARPU_ERROR("In simgrid mode, the file containing the main() function of this application needs to be compiled with starpu.h included, to properly rename it into starpu_main\n");
  170. exit(EXIT_FAILURE);
  171. }
  172. if (_starpu_simgrid_running_smpi())
  173. {
  174. /* Oops, we are running SMPI, let it start Simgrid, and we'll
  175. * take back hand in _starpu_simgrid_init from starpu_init() */
  176. return smpi_main(_starpu_mpi_simgrid_init, argc, argv);
  177. }
  178. MSG_init(&argc, argv);
  179. #if SIMGRID_VERSION_MAJOR < 3 || (SIMGRID_VERSION_MAJOR == 3 && SIMGRID_VERSION_MINOR < 9)
  180. /* Versions earlier than 3.9 didn't support our communication tasks */
  181. MSG_config("workstation/model", "ptask_L07");
  182. #endif
  183. /* Simgrid uses tiny stacks by default. This comes unexpected to our users. */
  184. extern xbt_cfg_t _sg_cfg_set;
  185. unsigned stack_size = 8192;
  186. struct rlimit rlim;
  187. if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur != 0 && rlim.rlim_cur != RLIM_INFINITY)
  188. stack_size = rlim.rlim_cur / 1024;
  189. xbt_cfg_set_int(_sg_cfg_set, "contexts/stack_size", stack_size);
  190. /* Load XML platform */
  191. _starpu_simgrid_get_platform_path(path, sizeof(path));
  192. MSG_create_environment(path);
  193. struct main_args *args = malloc(sizeof(*args));
  194. args->argc = argc;
  195. args->argv = argv;
  196. MSG_process_create_with_arguments("main", &do_starpu_main, calloc(MAX_TSD, sizeof(void*)), MSG_get_host_by_name("MAIN"), 0, (char**) args);
  197. MSG_main();
  198. return 0;
  199. }
  200. void _starpu_simgrid_init()
  201. {
  202. if (!starpu_main && !(smpi_main && smpi_simulated_main_))
  203. {
  204. _STARPU_ERROR("In simgrid mode, the file containing the main() function of this application needs to be compiled with starpu.h included, to properly rename it into starpu_main\n");
  205. exit(EXIT_FAILURE);
  206. }
  207. }
  208. /*
  209. * Tasks
  210. */
  211. struct task
  212. {
  213. msg_task_t task;
  214. int workerid;
  215. /* communication termination signalization */
  216. unsigned *finished;
  217. starpu_pthread_mutex_t *mutex;
  218. starpu_pthread_cond_t *cond;
  219. /* Task which waits for this task */
  220. struct task *next;
  221. };
  222. static struct task *last_task[STARPU_NMAXWORKERS];
  223. /* Actually execute the task. */
  224. static int task_execute(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[])
  225. {
  226. struct task *task = (void*) argv;
  227. _STARPU_DEBUG("task %p started\n", task);
  228. MSG_task_execute(task->task);
  229. MSG_task_destroy(task->task);
  230. _STARPU_DEBUG("task %p finished\n", task);
  231. STARPU_PTHREAD_MUTEX_LOCK(task->mutex);
  232. *task->finished = 1;
  233. STARPU_PTHREAD_COND_BROADCAST(task->cond);
  234. STARPU_PTHREAD_MUTEX_UNLOCK(task->mutex);
  235. /* The worker which started this task may be sleeping out of tasks, wake it */
  236. starpu_wake_worker(task->workerid);
  237. if (last_task[task->workerid] == task)
  238. last_task[task->workerid] = NULL;
  239. if (task->next)
  240. MSG_process_create_with_arguments("task", task_execute, calloc(MAX_TSD, sizeof(void*)), MSG_host_self(), 0, (char**) task->next);
  241. /* Task is freed with process context */
  242. return 0;
  243. }
  244. /* Wait for completion of all asynchronous tasks for this worker */
  245. void _starpu_simgrid_wait_tasks(int workerid)
  246. {
  247. struct task *task = last_task[workerid];
  248. if (!task)
  249. return;
  250. unsigned *finished = task->finished;
  251. starpu_pthread_mutex_t *mutex = task->mutex;
  252. starpu_pthread_cond_t *cond = task->cond;
  253. STARPU_PTHREAD_MUTEX_LOCK(mutex);
  254. while (!*finished)
  255. STARPU_PTHREAD_COND_WAIT(cond, mutex);
  256. STARPU_PTHREAD_MUTEX_UNLOCK(mutex);
  257. }
  258. /* Task execution submitted by StarPU */
  259. void _starpu_simgrid_submit_job(int workerid, struct _starpu_job *j, struct starpu_perfmodel_arch* perf_arch, double length, unsigned *finished, starpu_pthread_mutex_t *mutex, starpu_pthread_cond_t *cond)
  260. {
  261. struct starpu_task *starpu_task = j->task;
  262. msg_task_t simgrid_task;
  263. if (j->internal)
  264. /* This is not useful to include in simulation (and probably
  265. * doesn't have a perfmodel anyway) */
  266. return;
  267. if (isnan(length))
  268. {
  269. length = starpu_task_expected_length(starpu_task, perf_arch, j->nimpl);
  270. STARPU_ASSERT_MSG(!_STARPU_IS_ZERO(length) && !isnan(length),
  271. "Codelet %s does not have a perfmodel, or is not calibrated enough, please re-run in non-simgrid mode until it is calibrated",
  272. _starpu_job_get_model_name(j));
  273. }
  274. simgrid_task = MSG_task_create(_starpu_job_get_model_name(j),
  275. length/1000000.0*MSG_get_host_speed(MSG_host_self()),
  276. 0, NULL);
  277. if (finished == NULL)
  278. {
  279. /* Synchronous execution */
  280. /* First wait for previous tasks */
  281. _starpu_simgrid_wait_tasks(workerid);
  282. MSG_task_execute(simgrid_task);
  283. MSG_task_destroy(simgrid_task);
  284. }
  285. else
  286. {
  287. /* Asynchronous execution */
  288. struct task *task = malloc(sizeof(*task));
  289. task->task = simgrid_task;
  290. task->workerid = workerid;
  291. task->finished = finished;
  292. *finished = 0;
  293. task->mutex = mutex;
  294. task->cond = cond;
  295. task->next = NULL;
  296. /* Sleep 10µs for the GPU task queueing */
  297. if (_starpu_simgrid_queue_malloc_cost())
  298. MSG_process_sleep(0.000010);
  299. if (last_task[workerid])
  300. {
  301. /* Make this task depend on the previous */
  302. last_task[workerid]->next = task;
  303. last_task[workerid] = task;
  304. }
  305. else
  306. {
  307. last_task[workerid] = task;
  308. MSG_process_create_with_arguments("task", task_execute, calloc(MAX_TSD, sizeof(void*)), MSG_host_self(), 0, (char**) task);
  309. }
  310. }
  311. }
  312. /*
  313. * Transfers
  314. */
  315. /* Note: simgrid is not parallel, so there is no need to hold locks for management of transfers. */
  316. LIST_TYPE(transfer,
  317. msg_task_t task;
  318. int src_node;
  319. int dst_node;
  320. int run_node;
  321. /* communication termination signalization */
  322. unsigned *finished;
  323. starpu_pthread_mutex_t *mutex;
  324. starpu_pthread_cond_t *cond;
  325. /* transfers which wait for this transfer */
  326. struct transfer **wake;
  327. unsigned nwake;
  328. /* Number of transfers that this transfer waits for */
  329. unsigned nwait;
  330. )
  331. struct transfer_list pending;
  332. /* Tell for two transfers whether they should be handled in sequence */
  333. static int transfers_are_sequential(struct transfer *new_transfer, struct transfer *old_transfer)
  334. {
  335. int new_is_cuda STARPU_ATTRIBUTE_UNUSED, old_is_cuda STARPU_ATTRIBUTE_UNUSED;
  336. int new_is_opencl STARPU_ATTRIBUTE_UNUSED, old_is_opencl STARPU_ATTRIBUTE_UNUSED;
  337. int new_is_gpu_gpu, old_is_gpu_gpu;
  338. new_is_cuda = starpu_node_get_kind(new_transfer->src_node) == STARPU_CUDA_RAM;
  339. new_is_cuda |= starpu_node_get_kind(new_transfer->dst_node) == STARPU_CUDA_RAM;
  340. old_is_cuda = starpu_node_get_kind(old_transfer->src_node) == STARPU_CUDA_RAM;
  341. old_is_cuda |= starpu_node_get_kind(old_transfer->dst_node) == STARPU_CUDA_RAM;
  342. new_is_opencl = starpu_node_get_kind(new_transfer->src_node) == STARPU_OPENCL_RAM;
  343. new_is_opencl |= starpu_node_get_kind(new_transfer->dst_node) == STARPU_OPENCL_RAM;
  344. old_is_opencl = starpu_node_get_kind(old_transfer->src_node) == STARPU_OPENCL_RAM;
  345. old_is_opencl |= starpu_node_get_kind(old_transfer->dst_node) == STARPU_OPENCL_RAM;
  346. new_is_gpu_gpu = new_transfer->src_node && new_transfer->dst_node;
  347. old_is_gpu_gpu = old_transfer->src_node && old_transfer->dst_node;
  348. /* We ignore cuda-opencl transfers, they can not happen */
  349. STARPU_ASSERT(!((new_is_cuda && old_is_opencl) || (old_is_cuda && new_is_opencl)));
  350. /* The following constraints have been observed with CUDA alone */
  351. /* Same source/destination, sequential */
  352. if (new_transfer->src_node == old_transfer->src_node && new_transfer->dst_node == old_transfer->dst_node)
  353. return 1;
  354. /* Crossed GPU-GPU, sequential */
  355. if (new_is_gpu_gpu
  356. && new_transfer->src_node == old_transfer->dst_node
  357. && old_transfer->src_node == new_transfer->dst_node)
  358. return 1;
  359. /* GPU-GPU transfers are sequential with any RAM->GPU transfer */
  360. if (new_is_gpu_gpu
  361. && old_transfer->dst_node == new_transfer->src_node
  362. && old_transfer->dst_node == new_transfer->dst_node)
  363. return 1;
  364. if (old_is_gpu_gpu
  365. && new_transfer->dst_node == old_transfer->src_node
  366. && new_transfer->dst_node == old_transfer->dst_node)
  367. return 1;
  368. /* StarPU's constraint on CUDA transfers is using one stream per
  369. * source/destination pair, which is already handled above */
  370. return 0;
  371. }
  372. /* Actually execute the transfer, and then start transfers waiting for this one. */
  373. static int transfer_execute(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[])
  374. {
  375. struct transfer *transfer = (void*) argv;
  376. unsigned i;
  377. _STARPU_DEBUG("transfer %p started\n", transfer);
  378. MSG_task_execute(transfer->task);
  379. MSG_task_destroy(transfer->task);
  380. _STARPU_DEBUG("transfer %p finished\n", transfer);
  381. STARPU_PTHREAD_MUTEX_LOCK(transfer->mutex);
  382. *transfer->finished = 1;
  383. STARPU_PTHREAD_COND_BROADCAST(transfer->cond);
  384. STARPU_PTHREAD_MUTEX_UNLOCK(transfer->mutex);
  385. /* The workers which started this request may be sleeping out of tasks, wake it */
  386. _starpu_wake_all_blocked_workers_on_node(transfer->run_node);
  387. /* Wake transfers waiting for my termination */
  388. /* Note: due to possible preemption inside process_create, the array
  389. * may grow while doing this */
  390. for (i = 0; i < transfer->nwake; i++)
  391. {
  392. struct transfer *wake = transfer->wake[i];
  393. STARPU_ASSERT(wake->nwait > 0);
  394. wake->nwait--;
  395. if (!wake->nwait)
  396. {
  397. _STARPU_DEBUG("triggering transfer %p\n", wake);
  398. MSG_process_create_with_arguments("transfer task", transfer_execute, calloc(MAX_TSD, sizeof(void*)), _starpu_simgrid_get_host_by_name("MAIN"), 0, (char**) wake);
  399. }
  400. }
  401. free(transfer->wake);
  402. transfer_list_erase(&pending, transfer);
  403. /* transfer is freed with process context */
  404. return 0;
  405. }
  406. /* Look for sequentialization between this transfer and pending transfers, and submit this one */
  407. static void transfer_submit(struct transfer *transfer)
  408. {
  409. struct transfer *old;
  410. for (old = transfer_list_begin(&pending);
  411. old != transfer_list_end(&pending);
  412. old = transfer_list_next(old))
  413. {
  414. if (transfers_are_sequential(transfer, old))
  415. {
  416. _STARPU_DEBUG("transfer %p(%d->%d) waits for %p(%d->%d)\n",
  417. transfer, transfer->src_node, transfer->dst_node,
  418. old, old->src_node, old->dst_node);
  419. /* Make new wait for the old */
  420. transfer->nwait++;
  421. /* Make old wake the new */
  422. old->wake = realloc(old->wake, (old->nwake + 1) * sizeof(old->wake));
  423. old->wake[old->nwake] = transfer;
  424. old->nwake++;
  425. }
  426. }
  427. transfer_list_push_front(&pending, transfer);
  428. if (!transfer->nwait)
  429. {
  430. _STARPU_DEBUG("transfer %p waits for nobody, starting\n", transfer);
  431. MSG_process_create_with_arguments("transfer task", transfer_execute, calloc(MAX_TSD, sizeof(void*)), _starpu_simgrid_get_host_by_name("MAIN"), 0, (char**) transfer);
  432. }
  433. }
  434. /* Data transfer issued by StarPU */
  435. int _starpu_simgrid_transfer(size_t size, unsigned src_node, unsigned dst_node, struct _starpu_data_request *req)
  436. {
  437. msg_task_t task;
  438. msg_host_t *hosts = calloc(2, sizeof(*hosts));
  439. double *computation = calloc(2, sizeof(*computation));
  440. double *communication = calloc(4, sizeof(*communication));
  441. starpu_pthread_mutex_t mutex;
  442. starpu_pthread_cond_t cond;
  443. unsigned finished;
  444. hosts[0] = _starpu_simgrid_memory_node_get_host(src_node);
  445. hosts[1] = _starpu_simgrid_memory_node_get_host(dst_node);
  446. STARPU_ASSERT(hosts[0] != hosts[1]);
  447. communication[1] = size;
  448. task = MSG_parallel_task_create("copy", 2, hosts, computation, communication, NULL);
  449. struct transfer *transfer = transfer_new();
  450. _STARPU_DEBUG("creating transfer %p for %lu bytes\n", transfer, (unsigned long) size);
  451. transfer->task = task;
  452. transfer->src_node = src_node;
  453. transfer->dst_node = dst_node;
  454. transfer->run_node = _starpu_memory_node_get_local_key();
  455. if (req)
  456. {
  457. transfer->finished = &req->async_channel.event.finished;
  458. transfer->mutex = &req->async_channel.event.mutex;
  459. transfer->cond = &req->async_channel.event.cond;
  460. }
  461. else
  462. {
  463. transfer->finished = &finished;
  464. transfer->mutex = &mutex;
  465. transfer->cond = &cond;
  466. }
  467. *transfer->finished = 0;
  468. STARPU_PTHREAD_MUTEX_INIT(transfer->mutex, NULL);
  469. STARPU_PTHREAD_COND_INIT(transfer->cond, NULL);
  470. transfer->wake = NULL;
  471. transfer->nwake = 0;
  472. transfer->nwait = 0;
  473. if (req)
  474. _STARPU_TRACE_START_DRIVER_COPY_ASYNC(src_node, dst_node);
  475. /* Sleep 10µs for the GPU transfer queueing */
  476. if (_starpu_simgrid_queue_malloc_cost())
  477. MSG_process_sleep(0.000010);
  478. transfer_submit(transfer);
  479. /* Note: from here, transfer might be already freed */
  480. if (req)
  481. {
  482. _STARPU_TRACE_END_DRIVER_COPY_ASYNC(src_node, dst_node);
  483. _STARPU_TRACE_DATA_COPY(src_node, dst_node, size);
  484. return -EAGAIN;
  485. }
  486. else
  487. {
  488. /* this is not associated to a request so it's synchronous */
  489. STARPU_PTHREAD_MUTEX_LOCK(&mutex);
  490. while (!finished)
  491. STARPU_PTHREAD_COND_WAIT(&cond, &mutex);
  492. STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
  493. return 0;
  494. }
  495. }
  496. int
  497. _starpu_simgrid_thread_start(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[])
  498. {
  499. struct _starpu_pthread_args *_args = (void*) argv;
  500. struct _starpu_pthread_args args = *_args;
  501. /* _args is freed with process context */
  502. args.f(args.arg);
  503. return 0;
  504. }
  505. #endif