sink_common.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 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 <starpu.h>
  17. #include <common/config.h>
  18. #include <common/utils.h>
  19. #include <drivers/mp_common/mp_common.h>
  20. #include <datawizard/interfaces/data_interface.h>
  21. #include <common/barrier.h>
  22. #include <core/workers.h>
  23. #include <common/barrier_counter.h>
  24. #ifdef STARPU_USE_MIC
  25. #include <common/COISysInfo_common.h>
  26. #endif
  27. #include "sink_common.h"
  28. /* Return the sink kind of the running process, based on the value of the
  29. * STARPU_SINK environment variable.
  30. * If there is no valid value retrieved, return STARPU_INVALID_KIND
  31. */
  32. static enum _starpu_mp_node_kind _starpu_sink_common_get_kind(void)
  33. {
  34. /* Environment varible STARPU_SINK must be defined when running on sink
  35. * side : let's use it to get the kind of node we're running on */
  36. char *node_kind = getenv("STARPU_SINK");
  37. STARPU_ASSERT(node_kind);
  38. if (!strcmp(node_kind, "STARPU_MIC"))
  39. return STARPU_MIC_SINK;
  40. else if (!strcmp(node_kind, "STARPU_SCC"))
  41. return STARPU_SCC_SINK;
  42. else if (!strcmp(node_kind, "STARPU_MPI"))
  43. return STARPU_MPI_SINK;
  44. else
  45. return STARPU_INVALID_KIND;
  46. }
  47. /* Send to host the number of cores of the sink device
  48. */
  49. static void _starpu_sink_common_get_nb_cores (struct _starpu_mp_node *node)
  50. {
  51. // Process packet received from `_starpu_src_common_sink_cores'.
  52. _starpu_mp_common_send_command (node, STARPU_ANSWER_SINK_NBCORES,
  53. &node->nb_cores, sizeof (int));
  54. }
  55. /* Send to host the address of the function given in parameter
  56. */
  57. static void _starpu_sink_common_lookup(const struct _starpu_mp_node *node,
  58. char *func_name)
  59. {
  60. void (*func)(void);
  61. func = node->lookup(node,func_name);
  62. //_STARPU_DEBUG("Looked up %s, got %p\n", func_name, func);
  63. /* If we couldn't find the function, let's send an error to the host.
  64. * The user probably made a mistake in the name */
  65. if (func)
  66. _starpu_mp_common_send_command(node, STARPU_ANSWER_LOOKUP,
  67. &func, sizeof(func));
  68. else
  69. _starpu_mp_common_send_command(node, STARPU_ERROR_LOOKUP,
  70. NULL, 0);
  71. }
  72. /* Allocate a memory space and send the address of this space to the host
  73. */
  74. void _starpu_sink_common_allocate(const struct _starpu_mp_node *mp_node,
  75. void *arg, int arg_size)
  76. {
  77. STARPU_ASSERT(arg_size == sizeof(size_t));
  78. void *addr = malloc(*(size_t *)(arg));
  79. /* If the allocation fail, let's send an error to the host.
  80. */
  81. if (addr)
  82. _starpu_mp_common_send_command(mp_node, STARPU_ANSWER_ALLOCATE,
  83. &addr, sizeof(addr));
  84. else
  85. _starpu_mp_common_send_command(mp_node, STARPU_ERROR_ALLOCATE,
  86. NULL, 0);
  87. }
  88. void _starpu_sink_common_free(const struct _starpu_mp_node *mp_node STARPU_ATTRIBUTE_UNUSED,
  89. void *arg, int arg_size)
  90. {
  91. STARPU_ASSERT(arg_size == sizeof(void *));
  92. free(*(void **)(arg));
  93. }
  94. static void _starpu_sink_common_copy_from_host(const struct _starpu_mp_node *mp_node,
  95. void *arg, int arg_size)
  96. {
  97. STARPU_ASSERT(arg_size == sizeof(struct _starpu_mp_transfer_command));
  98. struct _starpu_mp_transfer_command *cmd = (struct _starpu_mp_transfer_command *)arg;
  99. mp_node->dt_recv(mp_node, cmd->addr, cmd->size);
  100. }
  101. static void _starpu_sink_common_copy_to_host(const struct _starpu_mp_node *mp_node,
  102. void *arg, int arg_size)
  103. {
  104. STARPU_ASSERT(arg_size == sizeof(struct _starpu_mp_transfer_command));
  105. struct _starpu_mp_transfer_command *cmd = (struct _starpu_mp_transfer_command *)arg;
  106. mp_node->dt_send(mp_node, cmd->addr, cmd->size);
  107. }
  108. static void _starpu_sink_common_copy_from_sink(const struct _starpu_mp_node *mp_node,
  109. void *arg, int arg_size)
  110. {
  111. STARPU_ASSERT(arg_size == sizeof(struct _starpu_mp_transfer_command_to_device));
  112. struct _starpu_mp_transfer_command_to_device *cmd = (struct _starpu_mp_transfer_command_to_device *)arg;
  113. mp_node->dt_recv_from_device(mp_node, cmd->devid, cmd->addr, cmd->size);
  114. _starpu_mp_common_send_command(mp_node, STARPU_TRANSFER_COMPLETE, NULL, 0);
  115. }
  116. static void _starpu_sink_common_copy_to_sink(const struct _starpu_mp_node *mp_node,
  117. void *arg, int arg_size)
  118. {
  119. STARPU_ASSERT(arg_size == sizeof(struct _starpu_mp_transfer_command_to_device));
  120. struct _starpu_mp_transfer_command_to_device *cmd = (struct _starpu_mp_transfer_command_to_device *)arg;
  121. mp_node->dt_send_to_device(mp_node, cmd->devid, cmd->addr, cmd->size);
  122. }
  123. /* Receive workers and combined workers and store them into the struct config
  124. */
  125. static void _starpu_sink_common_recv_workers(struct _starpu_mp_node * node, void *arg, int arg_size)
  126. {
  127. /* Retrieve information from the message */
  128. STARPU_ASSERT(arg_size == (sizeof(int)*5));
  129. void * arg_ptr = arg;
  130. int i;
  131. int nworkers = *(int *)arg_ptr;
  132. arg_ptr += sizeof(nworkers);
  133. int worker_size = *(int *)arg_ptr;
  134. arg_ptr += sizeof(worker_size);
  135. int combined_worker_size = *(int *)arg_ptr;
  136. arg_ptr += sizeof(combined_worker_size);
  137. int baseworkerid = *(int *)arg_ptr;
  138. arg_ptr += sizeof(baseworkerid);
  139. struct _starpu_machine_config *config = _starpu_get_machine_config();
  140. config->topology.nworkers = *(int *)arg_ptr;
  141. /* Retrieve workers */
  142. struct _starpu_worker * workers = &config->workers[baseworkerid];
  143. node->dt_recv(node,workers,worker_size);
  144. /* Update workers to have coherent field */
  145. for(i=0; i<nworkers; i++)
  146. {
  147. workers[i].config = config;
  148. starpu_pthread_mutex_init(&workers[i].mutex,NULL);
  149. starpu_pthread_mutex_destroy(&workers[i].mutex);
  150. starpu_pthread_cond_init(&workers[i].started_cond,NULL);
  151. starpu_pthread_cond_destroy(&workers[i].started_cond);
  152. starpu_pthread_cond_init(&workers[i].ready_cond,NULL);
  153. starpu_pthread_cond_destroy(&workers[i].ready_cond);
  154. starpu_pthread_mutex_init(&workers[i].sched_mutex,NULL);
  155. starpu_pthread_mutex_destroy(&workers[i].sched_mutex);
  156. starpu_pthread_cond_init(&workers[i].sched_cond,NULL);
  157. starpu_pthread_cond_destroy(&workers[i].sched_cond);
  158. workers[i].current_task = NULL;
  159. workers[i].set = NULL;
  160. workers[i].terminated_jobs = NULL;
  161. //_starpu_barrier_counter_init(&workers[i].tasks_barrier, 1);
  162. //_starpu_barrier_counter_destroy(&workers[i].tasks_barrier);
  163. starpu_pthread_mutex_init(&workers[i].parallel_sect_mutex,NULL);
  164. starpu_pthread_mutex_destroy(&workers[i].parallel_sect_mutex);
  165. starpu_pthread_cond_init(&workers[i].parallel_sect_cond,NULL);
  166. starpu_pthread_cond_destroy(&workers[i].parallel_sect_cond);
  167. }
  168. /* Retrieve combined workers */
  169. struct _starpu_combined_worker * combined_workers = config->combined_workers;
  170. node->dt_recv(node, combined_workers, combined_worker_size);
  171. node->baseworkerid = baseworkerid;
  172. STARPU_PTHREAD_BARRIER_WAIT(&node->init_completed_barrier);
  173. }
  174. /* Function looping on the sink, waiting for tasks to execute.
  175. * If the caller is the host, don't do anything.
  176. */
  177. void _starpu_sink_common_worker(void)
  178. {
  179. struct _starpu_mp_node *node = NULL;
  180. enum _starpu_mp_command command = STARPU_EXIT;
  181. int arg_size = 0;
  182. void *arg = NULL;
  183. int exit_starpu = 0;
  184. enum _starpu_mp_node_kind node_kind = _starpu_sink_common_get_kind();
  185. if (node_kind == STARPU_INVALID_KIND)
  186. _STARPU_ERROR("No valid sink kind retrieved, use the"
  187. "STARPU_SINK environment variable to specify"
  188. "this\n");
  189. /* Create and initialize the node */
  190. node = _starpu_mp_common_node_create(node_kind, -1);
  191. starpu_pthread_key_t worker_key;
  192. STARPU_PTHREAD_KEY_CREATE(&worker_key, NULL);
  193. struct _starpu_machine_config *config;
  194. while (!exit_starpu)
  195. {
  196. /* If we have received a message */
  197. if(node->mp_recv_is_ready(node))
  198. {
  199. command = _starpu_mp_common_recv_command(node, &arg, &arg_size);
  200. switch(command)
  201. {
  202. case STARPU_EXIT:
  203. exit_starpu = 1;
  204. break;
  205. case STARPU_EXECUTE:
  206. config = _starpu_get_machine_config();
  207. node->execute(node, arg, arg_size);
  208. break;
  209. case STARPU_SINK_NBCORES:
  210. _starpu_sink_common_get_nb_cores(node);
  211. break;
  212. case STARPU_LOOKUP:
  213. _starpu_sink_common_lookup(node, (char *) arg);
  214. break;
  215. case STARPU_ALLOCATE:
  216. node->allocate(node, arg, arg_size);
  217. break;
  218. case STARPU_FREE:
  219. node->free(node, arg, arg_size);
  220. break;
  221. case STARPU_RECV_FROM_HOST:
  222. _starpu_sink_common_copy_from_host(node, arg, arg_size);
  223. break;
  224. case STARPU_SEND_TO_HOST:
  225. _starpu_sink_common_copy_to_host(node, arg, arg_size);
  226. break;
  227. case STARPU_RECV_FROM_SINK:
  228. _starpu_sink_common_copy_from_sink(node, arg, arg_size);
  229. break;
  230. case STARPU_SEND_TO_SINK:
  231. _starpu_sink_common_copy_to_sink(node, arg, arg_size);
  232. break;
  233. case STARPU_SYNC_WORKERS:
  234. _starpu_sink_common_recv_workers(node, arg, arg_size);
  235. break;
  236. default:
  237. printf("Oops, command %x unrecognized\n", command);
  238. }
  239. }
  240. STARPU_PTHREAD_MUTEX_LOCK(&node->message_queue_mutex);
  241. /* If the list is not empty */
  242. if(!mp_message_list_empty(node->message_queue))
  243. {
  244. /* We pop a message and send it to the host */
  245. struct mp_message * message = mp_message_list_pop_back(node->message_queue);
  246. STARPU_PTHREAD_MUTEX_UNLOCK(&node->message_queue_mutex);
  247. //_STARPU_DEBUG("telling host that we have finished the task %p sur %d.\n", task->kernel, task->coreid);
  248. config = _starpu_get_machine_config();
  249. _starpu_mp_common_send_command(node, message->type,
  250. &message->buffer, message->size);
  251. mp_message_delete(message);
  252. }
  253. else
  254. {
  255. STARPU_PTHREAD_MUTEX_UNLOCK(&node->message_queue_mutex);
  256. }
  257. }
  258. /* Deinitialize the node and release it */
  259. _starpu_mp_common_node_destroy(node);
  260. exit(0);
  261. }
  262. /* Search for the mp_barrier correspondind to the specified combined worker
  263. * and create it if it doesn't exist
  264. */
  265. static struct mp_barrier * _starpu_sink_common_get_barrier(struct _starpu_mp_node * node, int cb_workerid, int cb_workersize)
  266. {
  267. struct mp_barrier * b = NULL;
  268. STARPU_PTHREAD_MUTEX_LOCK(&node->barrier_mutex);
  269. /* Search if the barrier already exist */
  270. for(b = mp_barrier_list_begin(node->barrier_list);
  271. b != mp_barrier_list_end(node->barrier_list) && b->id != cb_workerid;
  272. b = mp_barrier_list_next(b));
  273. /* If we found the barrier */
  274. if(b != NULL)
  275. {
  276. STARPU_PTHREAD_MUTEX_UNLOCK(&node->barrier_mutex);
  277. return b;
  278. }
  279. else
  280. {
  281. /* Else we create, initialize and add it to the list*/
  282. b = mp_barrier_new();
  283. b->id = cb_workerid;
  284. STARPU_PTHREAD_BARRIER_INIT(&b->before_work_barrier,NULL,cb_workersize);
  285. STARPU_PTHREAD_BARRIER_INIT(&b->after_work_barrier,NULL,cb_workersize);
  286. mp_barrier_list_push_back(node->barrier_list,b);
  287. STARPU_PTHREAD_MUTEX_UNLOCK(&node->barrier_mutex);
  288. return b;
  289. }
  290. }
  291. /* Erase for the mp_barrier correspondind to the specified combined worker
  292. */
  293. static void _starpu_sink_common_erase_barrier(struct _starpu_mp_node * node, struct mp_barrier *barrier)
  294. {
  295. STARPU_PTHREAD_MUTEX_LOCK(&node->barrier_mutex);
  296. mp_barrier_list_erase(node->barrier_list,barrier);
  297. STARPU_PTHREAD_MUTEX_UNLOCK(&node->barrier_mutex);
  298. }
  299. /* Append the message given in parameter to the message list
  300. */
  301. static void _starpu_sink_common_append_message(struct _starpu_mp_node *node, struct mp_message * message)
  302. {
  303. struct _starpu_machine_config *config = _starpu_get_machine_config();
  304. STARPU_PTHREAD_MUTEX_LOCK(&node->message_queue_mutex);
  305. mp_message_list_push_front(node->message_queue,message);
  306. STARPU_PTHREAD_MUTEX_UNLOCK(&node->message_queue_mutex);
  307. }
  308. /* Append to the message list a "STARPU_PRE_EXECUTION" message
  309. */
  310. static void _starpu_sink_common_pre_execution_message(struct _starpu_mp_node *node, struct mp_task *task)
  311. {
  312. /* Init message to tell the sink that the execution has begun */
  313. struct mp_message * message = mp_message_new();
  314. message->type = STARPU_PRE_EXECUTION;
  315. *(int *) message->buffer = task->combined_workerid;
  316. message->size = sizeof(task->combined_workerid);
  317. /* Append the message to the queue */
  318. _starpu_sink_common_append_message(node, message);
  319. }
  320. /* Append to the message list a "STARPU_EXECUTION_COMPLETED" message
  321. */
  322. static void _starpu_sink_common_execution_completed_message(struct _starpu_mp_node *node, struct mp_task *task)
  323. {
  324. /* Init message to tell the sink that the execution is completed */
  325. struct mp_message * message = mp_message_new();
  326. message->type = STARPU_EXECUTION_COMPLETED;
  327. message->size = sizeof(task->coreid);
  328. *(int*) message->buffer = task->coreid;
  329. /* Append the message to the queue */
  330. _starpu_sink_common_append_message(node, message);
  331. }
  332. /* Bind the thread which is running on the specified core to the combined worker */
  333. static void _starpu_sink_common_bind_to_combined_worker(struct _starpu_mp_node *node, int coreid, struct _starpu_combined_worker * combined_worker)
  334. {
  335. int i;
  336. int * bind_set = malloc(sizeof(int)*combined_worker->worker_size);
  337. for(i=0;i<combined_worker->worker_size;i++)
  338. bind_set[i] = combined_worker->combined_workerid[i] - node->baseworkerid;
  339. node->bind_thread(node, coreid, bind_set, combined_worker->worker_size);
  340. }
  341. /* Get the current rank of the worker in the combined worker
  342. */
  343. static int _starpu_sink_common_get_current_rank(int workerid, struct _starpu_combined_worker * combined_worker)
  344. {
  345. int i;
  346. for(i=0; i<combined_worker->worker_size; i++)
  347. if(workerid == combined_worker->combined_workerid[i])
  348. return i;
  349. STARPU_ASSERT(0);
  350. }
  351. /* Execute the task
  352. */
  353. static void _starpu_sink_common_execute_kernel(struct _starpu_mp_node *node, int coreid, struct _starpu_worker * worker)
  354. {
  355. struct _starpu_combined_worker * combined_worker = NULL;
  356. struct mp_task* task = node->run_table[coreid];
  357. /* If it's a parallel task */
  358. if(task->is_parallel_task)
  359. {
  360. combined_worker = _starpu_get_combined_worker_struct(task->combined_workerid);
  361. worker->current_rank = _starpu_sink_common_get_current_rank(worker->workerid, combined_worker);
  362. worker->combined_workerid = task->combined_workerid;
  363. worker->worker_size = combined_worker->worker_size;
  364. /* Synchronize with others threads of the combined worker*/
  365. STARPU_PTHREAD_BARRIER_WAIT(&task->mp_barrier->before_work_barrier);
  366. /* The first thread of the combined worker */
  367. if(worker->current_rank == 0)
  368. {
  369. /* tell the sink that the execution has begun */
  370. _starpu_sink_common_pre_execution_message(node,task);
  371. /* If the mode is FORKJOIN,
  372. * the first thread binds himself
  373. * on all core of the combined worker*/
  374. if(task->type == STARPU_FORKJOIN)
  375. {
  376. _starpu_sink_common_bind_to_combined_worker(node, coreid, combined_worker);
  377. }
  378. }
  379. }
  380. else
  381. {
  382. worker->current_rank = 0;
  383. worker->combined_workerid = 0;
  384. worker->worker_size = 1;
  385. }
  386. if(task->type != STARPU_FORKJOIN || worker->current_rank == 0)
  387. {
  388. /* execute the task */
  389. task->kernel(task->interfaces,task->cl_arg);
  390. }
  391. /* If it's a parallel task */
  392. if(task->is_parallel_task)
  393. {
  394. /* Synchronize with others threads of the combined worker*/
  395. STARPU_PTHREAD_BARRIER_WAIT(&task->mp_barrier->after_work_barrier);
  396. /* The fisrt thread of the combined */
  397. if(worker->current_rank == 0)
  398. {
  399. /* Erase the barrier from the list */
  400. _starpu_sink_common_erase_barrier(node,task->mp_barrier);
  401. /* If the mode is FORKJOIN,
  402. * the first thread rebinds himself on his own core */
  403. if(task->type == STARPU_FORKJOIN)
  404. node->bind_thread(node, coreid, &coreid, 1);
  405. }
  406. }
  407. node->run_table[coreid] = NULL;
  408. /* tell the sink that the execution is completed */
  409. _starpu_sink_common_execution_completed_message(node,task);
  410. /*free the task*/
  411. unsigned i;
  412. for (i = 0; i < task->nb_interfaces; i++)
  413. free(task->interfaces[i]);
  414. free(task);
  415. }
  416. /* The main function executed by the thread
  417. * thread_arg is a structure containing the information needed by the thread
  418. */
  419. void* _starpu_sink_thread(void * thread_arg)
  420. {
  421. /* Retrieve the information from the structure */
  422. struct _starpu_mp_node *node = ((struct arg_sink_thread *)thread_arg)->node;
  423. int coreid =((struct arg_sink_thread *)thread_arg)->coreid;
  424. /* free the structure */
  425. free(thread_arg);
  426. STARPU_PTHREAD_BARRIER_WAIT(&node->init_completed_barrier);
  427. struct _starpu_worker *worker = &_starpu_get_machine_config()->workers[node->baseworkerid + coreid];
  428. _starpu_set_local_worker_key(worker);
  429. while(node->is_running)
  430. {
  431. /*Wait there is a task available */
  432. sem_wait(&node->sem_run_table[coreid]);
  433. if(node->run_table[coreid] != NULL)
  434. _starpu_sink_common_execute_kernel(node,coreid,worker);
  435. }
  436. pthread_exit(NULL);
  437. }
  438. /* Add the task to the specific thread and wake him up
  439. */
  440. static void _starpu_sink_common_execute_thread(struct _starpu_mp_node *node, struct mp_task *task)
  441. {
  442. /* Add the task to the specific thread */
  443. node->run_table[task->coreid] = task;
  444. /* Unlock the mutex to wake up the thread which will execute the task */
  445. sem_post(&node->sem_run_table[task->coreid]);
  446. }
  447. /* Receive paquet from _starpu_src_common_execute_kernel in the form below :
  448. * [Function pointer on sink, number of interfaces, interfaces
  449. * (union _starpu_interface), cl_arg]
  450. * Then call the function given, passing as argument an array containing the
  451. * addresses of the received interfaces
  452. */
  453. void _starpu_sink_common_execute(struct _starpu_mp_node *node,
  454. void *arg, int arg_size)
  455. {
  456. unsigned i;
  457. void *arg_ptr = arg;
  458. struct mp_task *task = malloc(sizeof(struct mp_task));
  459. task->kernel = *(void(**)(void **, void *)) arg_ptr;
  460. arg_ptr += sizeof(task->kernel);
  461. task->type = *(enum starpu_codelet_type *) arg_ptr;
  462. arg_ptr += sizeof(task->type);
  463. task->is_parallel_task = *(int *) arg_ptr;
  464. arg_ptr += sizeof(task->is_parallel_task);
  465. if(task->is_parallel_task)
  466. {
  467. task->combined_workerid= *(int *) arg_ptr;
  468. arg_ptr += sizeof(task->combined_workerid);
  469. task->mp_barrier = _starpu_sink_common_get_barrier(node,task->combined_workerid,_starpu_get_combined_worker_struct(task->combined_workerid)->worker_size);
  470. }
  471. task->coreid = *(unsigned *) arg_ptr;
  472. arg_ptr += sizeof(task->coreid);
  473. task->nb_interfaces = *(unsigned *) arg_ptr;
  474. arg_ptr += sizeof(task->nb_interfaces);
  475. /* The function needs an array pointing to each interface it needs
  476. * during execution. As in sink-side there is no mean to know which
  477. * kind of interface to expect, the array is composed of unions of
  478. * interfaces, thus we expect the same size anyway */
  479. for (i = 0; i < task->nb_interfaces; i++)
  480. {
  481. union _starpu_interface * interface = malloc(sizeof(union _starpu_interface));
  482. memcpy(interface, arg_ptr,
  483. sizeof(union _starpu_interface));
  484. task->interfaces[i] = interface;
  485. arg_ptr += sizeof(union _starpu_interface);
  486. }
  487. /* Was cl_arg sent ? */
  488. if (arg_size > arg_ptr - arg)
  489. task->cl_arg = arg_ptr;
  490. else
  491. task->cl_arg = NULL;
  492. //_STARPU_DEBUG("telling host that we have submitted the task %p.\n", task->kernel);
  493. _starpu_mp_common_send_command(node, STARPU_EXECUTION_SUBMITTED,
  494. NULL, 0);
  495. //_STARPU_DEBUG("executing the task %p\n", task->kernel);
  496. _starpu_sink_common_execute_thread(node, task);
  497. }