mpi.doxy 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2018 CNRS
  4. * Copyright (C) 2011-2012,2016,2017 Inria
  5. * Copyright (C) 2009-2011,2014-2018 Université de Bordeaux
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. /*! \defgroup API_MPI_Support MPI Support
  19. @name Initialisation
  20. \ingroup API_MPI_Support
  21. \def STARPU_USE_MPI
  22. \ingroup API_MPI_Support
  23. Defined when StarPU has been installed with MPI support. It should be
  24. used in your code to detect the availability of MPI.
  25. \fn int starpu_mpi_init_conf(int *argc, char ***argv, int initialize_mpi, MPI_Comm comm, struct starpu_conf *conf)
  26. \ingroup API_MPI_Support
  27. Initialize the StarPU library with the given \p conf, and initialize the
  28. StarPU-MPI library with the given MPI communicator \p comm. \p initialize_mpi
  29. indicates if MPI should be initialized or not by StarPU.
  30. StarPU-MPI takes the opportunity to modify \p conf to either reserve a core for
  31. its MPI thread (by default), or execute MPI calls on the CPU driver 0 between tasks.
  32. \fn int starpu_mpi_init_comm(int *argc, char ***argv, int initialize_mpi, MPI_Comm comm)
  33. \ingroup API_MPI_Support
  34. This is the same as starpu_mpi_init_conf(), except that this does not initialize
  35. the StarPU library. The caller thus has to call starpu_init() before this.
  36. \fn int starpu_mpi_init(int *argc, char ***argv, int initialize_mpi)
  37. \ingroup API_MPI_Support
  38. Call starpu_mpi_init_comm() with the MPI communicator \c MPI_COMM_WORLD.
  39. \fn int starpu_mpi_initialize(void)
  40. \deprecated
  41. \ingroup API_MPI_Support
  42. This function has been made deprecated. One should use instead the
  43. function starpu_mpi_init(). This function does not call \c MPI_Init(), it
  44. should be called beforehand.
  45. \fn int starpu_mpi_initialize_extended(int *rank, int *world_size)
  46. \deprecated
  47. \ingroup API_MPI_Support
  48. This function has been made deprecated. One should use instead the
  49. function starpu_mpi_init(). MPI will be initialized by starpumpi by
  50. calling <c>MPI_Init_Thread(argc, argv, MPI_THREAD_SERIALIZED,
  51. ...)</c>.
  52. \fn int starpu_mpi_shutdown(void)
  53. \ingroup API_MPI_Support
  54. Clean the starpumpi library. This must be called after calling any
  55. \c starpu_mpi functions and before the call to starpu_shutdown(), if any.
  56. \c MPI_Finalize() will be called if StarPU-MPI has been initialized by starpu_mpi_init().
  57. \fn void starpu_mpi_comm_amounts_retrieve(size_t *comm_amounts)
  58. \ingroup API_MPI_Support
  59. Retrieve the current amount of communications from the current node in
  60. the array \p comm_amounts which must have a size greater or equal to
  61. the world size. Communications statistics must be enabled (see
  62. \ref STARPU_COMM_STATS).
  63. \fn int starpu_mpi_comm_size(MPI_Comm comm, int *size)
  64. \ingroup API_MPI_Support
  65. Return in \p size the size of the communicator \p comm
  66. \fn int starpu_mpi_comm_rank(MPI_Comm comm, int *rank)
  67. \ingroup API_MPI_Support
  68. Return in \p rank the rank of the calling process in the communicator \p comm
  69. \fn int starpu_mpi_world_rank(void)
  70. \ingroup API_MPI_Support
  71. Return the rank of the calling process in the communicator \c MPI_COMM_WORLD
  72. \fn int starpu_mpi_world_size(void)
  73. \ingroup API_MPI_Support
  74. Return the size of the communicator \c MPI_COMM_WORLD
  75. @name Communication
  76. \anchor MPIPtpCommunication
  77. \ingroup API_MPI_Support
  78. \fn int starpu_mpi_send(starpu_data_handle_t data_handle, int dest, starpu_mpi_tag_t data_tag, MPI_Comm comm)
  79. \ingroup API_MPI_Support
  80. Perform a standard-mode, blocking send of \p data_handle to the node
  81. \p dest using the message tag \p data_tag within the communicator \p
  82. comm.
  83. \fn int starpu_mpi_send_prio(starpu_data_handle_t data_handle, int dest, starpu_mpi_tag_t data_tag, int prio, MPI_Comm comm)
  84. \ingroup API_MPI_Support
  85. Similar to starpu_mpi_send, but takes a priority \p prio.
  86. \fn int starpu_mpi_recv(starpu_data_handle_t data_handle, int source, starpu_mpi_tag_t data_tag, MPI_Comm comm, MPI_Status *status)
  87. \ingroup API_MPI_Support
  88. Perform a standard-mode, blocking receive in \p data_handle from the
  89. node \p source using the message tag \p data_tag within the
  90. communicator \p comm.
  91. \fn int starpu_mpi_isend(starpu_data_handle_t data_handle, starpu_mpi_req *req, int dest, starpu_mpi_tag_t data_tag, MPI_Comm comm)
  92. \ingroup API_MPI_Support
  93. Post a standard-mode, non blocking send of \p data_handle to the node
  94. \p dest using the message tag \p data_tag within the communicator \p
  95. comm. After the call, the pointer to the request \p req can be used to
  96. test or to wait for the completion of the communication.
  97. \fn int starpu_mpi_isend_prio(starpu_data_handle_t data_handle, starpu_mpi_req *req, int dest, starpu_mpi_tag_t data_tag, int prio, MPI_Comm comm)
  98. \ingroup API_MPI_Support
  99. Similar to starpu_mpi_isend, but takes a priority \p prio.
  100. \fn int starpu_mpi_irecv(starpu_data_handle_t data_handle, starpu_mpi_req *req, int source, starpu_mpi_tag_t data_tag, MPI_Comm comm)
  101. \ingroup API_MPI_Support
  102. Post a nonblocking receive in \p data_handle from the node \p source
  103. using the message tag \p data_tag within the communicator \p comm.
  104. After the call, the pointer to the request \p req can be used to test
  105. or to wait for the completion of the communication.
  106. \fn int starpu_mpi_isend_detached(starpu_data_handle_t data_handle, int dest, starpu_mpi_tag_t data_tag, MPI_Comm comm, void (*callback)(void *), void *arg)
  107. \ingroup API_MPI_Support
  108. Post a standard-mode, non blocking send of \p data_handle to the node
  109. \p dest using the message tag \p data_tag within the communicator \p
  110. comm. On completion, the \p callback function is called with the
  111. argument \p arg.
  112. Similarly to the pthread detached functionality, when a detached
  113. communication completes, its resources are automatically released back
  114. to the system, there is no need to test or to wait for the completion
  115. of the request.
  116. \fn int starpu_mpi_isend_detached_prio(starpu_data_handle_t data_handle, int dest, starpu_mpi_tag_t data_tag, int prio, MPI_Comm comm, void (*callback)(void *), void *arg)
  117. \ingroup API_MPI_Support
  118. Similar to starpu_mpi_isend_detached, but takes a priority \p prio.
  119. \fn int starpu_mpi_irecv_detached(starpu_data_handle_t data_handle, int source, starpu_mpi_tag_t data_tag, MPI_Comm comm, void (*callback)(void *), void *arg)
  120. \ingroup API_MPI_Support
  121. Post a nonblocking receive in \p data_handle from the node \p source
  122. using the message tag \p data_tag within the communicator \p comm. On
  123. completion, the \p callback function is called with the argument \p
  124. arg.
  125. Similarly to the pthread detached functionality, when a detached
  126. communication completes, its resources are automatically released back
  127. to the system, there is no need to test or to wait for the completion
  128. of the request.
  129. \fn int starpu_mpi_irecv_detached_sequential_consistency(starpu_data_handle_t data_handle, int source, starpu_mpi_tag_t data_tag, MPI_Comm comm, void (*callback)(void *), void *arg, int sequential_consistency)
  130. \ingroup API_MPI_Support
  131. Post a nonblocking receive in \p data_handle from the node \p source
  132. using the message tag \p data_tag within the communicator \p comm. On
  133. completion, the \p callback function is called with the argument \p
  134. arg.
  135. The parameter \p sequential_consistency allows to enable or disable
  136. the sequential consistency for \p data handle (sequential consistency
  137. will be enabled or disabled based on the value of the parameter \p
  138. sequential_consistency and the value of the sequential consistency
  139. defined for \p data_handle).
  140. Similarly to the pthread detached functionality, when a detached
  141. communication completes, its resources are automatically released back
  142. to the system, there is no need to test or to wait for the completion
  143. of the request.
  144. \fn int starpu_mpi_issend(starpu_data_handle_t data_handle, starpu_mpi_req *req, int dest, starpu_mpi_tag_t data_tag, MPI_Comm comm)
  145. \ingroup API_MPI_Support
  146. Perform a synchronous-mode, non-blocking send of \p data_handle to the node
  147. \p dest using the message tag \p data_tag within the communicator \p
  148. comm.
  149. \fn int starpu_mpi_issend_prio(starpu_data_handle_t data_handle, starpu_mpi_req *req, int dest, starpu_mpi_tag_t data_tag, int prio, MPI_Comm comm)
  150. \ingroup API_MPI_Support
  151. Similar to starpu_mpi_issend, but takes a priority \p prio.
  152. \fn int starpu_mpi_issend_detached(starpu_data_handle_t data_handle, int dest, starpu_mpi_tag_t data_tag, MPI_Comm comm, void (*callback)(void *), void *arg)
  153. \ingroup API_MPI_Support
  154. Perform a synchronous-mode, non-blocking send of \p data_handle to the node
  155. \p dest using the message tag \p data_tag within the communicator \p
  156. comm. On completion, the \p callback function is called with the argument \p
  157. arg.
  158. Similarly to the pthread detached functionality, when a detached
  159. communication completes, its resources are automatically released back
  160. to the system, there is no need to test or to wait for the completion
  161. of the request.
  162. \fn int starpu_mpi_wait(starpu_mpi_req *req, MPI_Status *status)
  163. \ingroup API_MPI_Support
  164. Return when the operation identified by request \p req is complete.
  165. \fn int starpu_mpi_test(starpu_mpi_req *req, int *flag, MPI_Status *status)
  166. \ingroup API_MPI_Support
  167. If the operation identified by \p req is complete, set \p flag to 1.
  168. The \p status object is set to contain information on the completed
  169. operation.
  170. \fn int starpu_mpi_barrier(MPI_Comm comm)
  171. \ingroup API_MPI_Support
  172. Block the caller until all group members of the communicator \p comm
  173. have called it.
  174. \fn int starpu_mpi_wait_for_all(MPI_Comm comm)
  175. \ingroup API_MPI_Support
  176. Wait until all StarPU tasks and communications for the given communicator are completed.
  177. \fn int starpu_mpi_isend_detached_unlock_tag(starpu_data_handle_t data_handle, int dest, starpu_mpi_tag_t data_tag, MPI_Comm comm, starpu_tag_t tag)
  178. \ingroup API_MPI_Support
  179. Post a standard-mode, non blocking send of \p data_handle to the node
  180. \p dest using the message tag \p data_tag within the communicator \p
  181. comm. On completion, \p tag is unlocked.
  182. \fn int starpu_mpi_isend_detached_unlock_tag_prio(starpu_data_handle_t data_handle, int dest, starpu_mpi_tag_t data_tag, int prio, MPI_Comm comm, starpu_tag_t tag)
  183. \ingroup API_MPI_Support
  184. Similar to starpu_mpi_isend_detached_unlock_tag(), but takes a priority \p prio.
  185. \fn int starpu_mpi_irecv_detached_unlock_tag(starpu_data_handle_t data_handle, int source, starpu_mpi_tag_t data_tag, MPI_Comm comm, starpu_tag_t tag)
  186. \ingroup API_MPI_Support
  187. Post a nonblocking receive in \p data_handle from the node \p source
  188. using the message tag \p data_tag within the communicator \p comm. On
  189. completion, \p tag is unlocked.
  190. \fn int starpu_mpi_isend_array_detached_unlock_tag(unsigned array_size, starpu_data_handle_t *data_handle, int *dest, starpu_mpi_tag_t *data_tag, MPI_Comm *comm, starpu_tag_t tag)
  191. \ingroup API_MPI_Support
  192. Post \p array_size standard-mode, non blocking send. Each post sends
  193. the n-th data of the array \p data_handle to the n-th node of the
  194. array \p dest using the n-th message tag of the array \p data_tag
  195. within the n-th communicator of the array \p comm. On completion of
  196. the all the requests, \p tag is unlocked.
  197. \fn int starpu_mpi_isend_array_detached_unlock_tag_prio(unsigned array_size, starpu_data_handle_t *data_handle, int *dest, starpu_mpi_tag_t *data_tag, int *prio, MPI_Comm *comm, starpu_tag_t tag)
  198. \ingroup API_MPI_Support
  199. Similar to starpu_mpi_isend_array_detached_unlock_tag(), but takes a priority \p prio.
  200. \fn int starpu_mpi_irecv_array_detached_unlock_tag(unsigned array_size, starpu_data_handle_t *data_handle, int *source, starpu_mpi_tag_t *data_tag, MPI_Comm *comm, starpu_tag_t tag)
  201. \ingroup API_MPI_Support
  202. Post \p array_size nonblocking receive. Each post receives in the n-th
  203. data of the array \p data_handle from the n-th node of the array \p
  204. source using the n-th message tag of the array \p data_tag within the
  205. n-th communicator of the array \p comm. On completion of the all the
  206. requests, \p tag is unlocked.
  207. \fn int starpu_mpi_get_communication_tag(void)
  208. \ingroup API_MPI_Support
  209. todo
  210. \fn void starpu_mpi_set_communication_tag(int tag)
  211. \ingroup API_MPI_Support
  212. todo
  213. \fn int starpu_mpi_datatype_register(starpu_data_handle_t handle, starpu_mpi_datatype_allocate_func_t allocate_datatype_func, starpu_mpi_datatype_free_func_t free_datatype_func)
  214. \ingroup API_MPI_Support
  215. Register functions to create and free a MPI datatype for the given handle.
  216. It is important that the function is called before any communication can take place for a data with the given handle. See \ref ExchangingUserDefinedDataInterface for an example.
  217. \fn int starpu_mpi_datatype_unregister(starpu_data_handle_t handle);
  218. \ingroup API_MPI_Support
  219. Unregister the MPI datatype functions stored for the interface of the given handle.
  220. \def STARPU_MPI_TAG_UB
  221. \ingroup API_MPI_Support
  222. When given to the function starpu_mpi_comm_get_attr(), retrieve the
  223. value for the upper bound for tag value.
  224. \fn int starpu_mpi_comm_get_attr(MPI_Comm comm, int keyval, void *attribute_val, int *flag);
  225. \ingroup API_MPI_Support
  226. Retrieve an attribute value by key, similarly to the MPI function \c MPI_comm_get_attr(), except that the value is a pointer to int64_t instead of int.
  227. If an attribute is attached on \p comm to \p keyval, then the call
  228. returns \p flag equal to \c 1, and the attribute value in \p
  229. attribute_val. Otherwise, \p flag is set to \0.
  230. @name Communication Cache
  231. \ingroup API_MPI_Support
  232. \fn int starpu_mpi_cache_is_enabled()
  233. \ingroup API_MPI_Support
  234. Return 1 if the communication cache is enabled, 0 otherwise
  235. \fn int starpu_mpi_cache_set(int enabled)
  236. \ingroup API_MPI_Support
  237. If \p enabled is 1, enable the communication cache. Otherwise, clean the cache if it was enabled and disable it.
  238. \fn void starpu_mpi_cache_flush(MPI_Comm comm, starpu_data_handle_t data_handle)
  239. \ingroup API_MPI_Support
  240. Clear the send and receive communication cache for the data
  241. \p data_handle and invalidate the value. The function has to be called at the
  242. same point of task graph submission by all the MPI nodes on which the handle was
  243. registered. The function does nothing if the cache mechanism is
  244. disabled (see \ref STARPU_MPI_CACHE).
  245. \fn void starpu_mpi_cache_flush_all_data(MPI_Comm comm)
  246. \ingroup API_MPI_Support
  247. Clear the send and receive communication cache for all data and invalidate their values. The
  248. function has to be called at the same point of task graph submission by all the MPI nodes. The
  249. function does nothing if the cache mechanism is disabled (see
  250. \ref STARPU_MPI_CACHE).
  251. \fn int starpu_mpi_cached_receive(starpu_data_handle_t data_handle);
  252. \ingroup API_MPI_Support
  253. Test whether \p data_handle is cached for reception, i.e. the value was
  254. previously received from the owner node, and not flushed since then.
  255. \fn int starpu_mpi_cached_send(starpu_data_handle_t data_handle, int dest);
  256. \ingroup API_MPI_Support
  257. Test whether \p data_handle is cached for emission to node \p dest , i.e. the
  258. value was previously sent to \p dest, and not flushed since then.
  259. @name MPI Insert Task
  260. \anchor MPIInsertTask
  261. \ingroup API_MPI_Support
  262. \fn void starpu_mpi_data_register_comm(starpu_data_handle_t data_handle, starpu_mpi_tag_t data_tag, int rank, MPI_Comm comm)
  263. \ingroup API_MPI_Support
  264. Register to MPI a StarPU data handle with the given tag, rank and MPI communicator.
  265. It also automatically clears the MPI communication cache when unregistering the data.
  266. \def starpu_mpi_data_register(data_handle, data_tag, rank)
  267. \ingroup API_MPI_Support
  268. Register to MPI a StarPU data handle with the given tag, rank and the MPI communicator \c MPI_COMM_WORLD.
  269. It also automatically clears the MPI communication cache when unregistering the data.
  270. \fn void starpu_mpi_data_set_tag(starpu_data_handle_t handle, starpu_mpi_tag_t data_tag)
  271. \ingroup API_MPI_Support
  272. Register to MPI a StarPU data handle with the given tag. No rank will be defined.
  273. It also automatically clears the MPI communication cache when unregistering the data.
  274. \def starpu_data_set_tag
  275. \ingroup API_MPI_Support
  276. Symbol kept for backward compatibility. Calling function starpu_mpi_data_set_tag()
  277. \fn void starpu_mpi_data_set_rank_comm(starpu_data_handle_t handle, int rank, MPI_Comm comm)
  278. \ingroup API_MPI_Support
  279. Register to MPI a StarPU data handle with the given rank and given communicator. No tag will be defined.
  280. It also automatically clears the MPI communication cache when unregistering the data.
  281. \def starpu_mpi_data_set_rank
  282. \ingroup API_MPI_Support
  283. Register to MPI a StarPU data handle with the given rank and the MPI communicator \c MPI_COMM_WORLD. No tag will be defined.
  284. It also automatically clears the MPI communication cache when unregistering the data.
  285. Symbol kept for backward compatibility. Calling function starpu_mpi_data_set_rank()
  286. \def starpu_data_set_rank
  287. \ingroup API_MPI_Support
  288. Register to MPI a StarPU data handle with the given rank and the MPI communicator \c MPI_COMM_WORLD. No tag will be defined.
  289. It also automatically clears the MPI communication cache when unregistering the data.
  290. Symbol kept for backward compatibility. Calling function starpu_mpi_data_set_rank()
  291. \fn int starpu_mpi_data_get_rank(starpu_data_handle_t handle)
  292. \ingroup API_MPI_Support
  293. Return the rank of the given data.
  294. \def starpu_data_get_rank
  295. \ingroup API_MPI_Support
  296. Return the rank of the given data.
  297. Symbol kept for backward compatibility. Calling function starpu_mpi_data_get_rank()
  298. \fn starpu_mpi_tag_t starpu_mpi_data_get_tag(starpu_data_handle_t handle)
  299. \ingroup API_MPI_Support
  300. Return the tag of the given data.
  301. \def starpu_data_get_tag
  302. \ingroup API_MPI_Support
  303. Return the tag of the given data.
  304. Symbol kept for backward compatibility. Calling function starpu_mpi_data_get_tag()
  305. \def STARPU_MPI_PER_NODE
  306. \ingroup API_MPI_Support
  307. Can be used as rank when calling starpu_mpi_data_register() and alike, to
  308. specify that the data is per-node: each node will have its own value. Tasks
  309. writing to such data will be replicated on all nodes (and all parameters then
  310. have to be per-node). Tasks not writing to such data will just take the
  311. node-local value without any MPI communication.
  312. \fn void starpu_mpi_data_migrate(MPI_Comm comm, starpu_data_handle_t handle, int new_rank)
  313. \ingroup API_MPI_Support
  314. Submits migration of the data onto the \p new_rank MPI node. This means both submitting the transfer of
  315. the data to node \p new_rank if it hasn't been submitted already, and setting
  316. the home node of the data to the new node. Further data transfers submitted by
  317. starpu_mpi_task_insert() will be done from that new node. This function thus
  318. needs to be called on all nodes which have registered the data at the same point of tasks submissions. This also
  319. flushes the cache for this data to avoid incoherencies.
  320. \def STARPU_EXECUTE_ON_NODE
  321. \ingroup API_MPI_Support
  322. Used when calling starpu_mpi_task_insert(), must be
  323. followed by a integer value which specified the node on which to
  324. execute the codelet.
  325. \def STARPU_EXECUTE_ON_DATA
  326. \ingroup API_MPI_Support
  327. Used when calling starpu_mpi_task_insert(), must be
  328. followed by a data handle to specify that the node owning the given
  329. data will execute the codelet.
  330. \def STARPU_NODE_SELECTION_POLICY
  331. \ingroup API_MPI_Support
  332. Used when calling starpu_mpi_task_insert(), must be
  333. followed by a identifier to a node selection policy. This is needed when several
  334. nodes own data in ::STARPU_W mode.
  335. \fn int starpu_mpi_insert_task(MPI_Comm comm, struct starpu_codelet *codelet, ...)
  336. \ingroup API_MPI_Support
  337. Call starpu_mpi_task_insert(). Symbol kept for backward compatibility.
  338. \fn int starpu_mpi_task_insert(MPI_Comm comm, struct starpu_codelet *codelet, ...)
  339. \ingroup API_MPI_Support
  340. Create and submit a task corresponding to codelet with the following
  341. arguments. The argument list must be zero-terminated.
  342. The arguments following the codelet are the same types as for the
  343. function starpu_task_insert(). Access modes for data can also be set
  344. with ::STARPU_SSEND to specify the data has to be sent using a
  345. synchronous and non-blocking mode (see starpu_mpi_issend()).
  346. The extra argument
  347. ::STARPU_EXECUTE_ON_NODE followed by an integer allows to specify the
  348. MPI node to execute the codelet. It is also possible to specify that
  349. the node owning a specific data will execute the codelet, by using
  350. ::STARPU_EXECUTE_ON_DATA followed by a data handle.
  351. The internal algorithm is as follows:
  352. <ol>
  353. <li>
  354. Find out which MPI node is going to execute the codelet.
  355. <ul>
  356. <li>If there is only one node owning data in ::STARPU_W mode, it will be selected;
  357. <li>If there is several nodes owning data in ::STARPU_W mode, a node will be selected according to a given node selection policy (see ::STARPU_NODE_SELECTION_POLICY or starpu_mpi_node_selection_set_current_policy())
  358. <li>The argument ::STARPU_EXECUTE_ON_NODE followed by an integer can be used to specify the node;
  359. <li>The argument ::STARPU_EXECUTE_ON_DATA followed by a data handle can be used to specify that the node owing the given data will execute the codelet.
  360. </ul>
  361. </li>
  362. <li>
  363. Send and receive data as requested. Nodes owning data which need to be read by the task are sending them to the MPI node which will execute it. The latter receives them.
  364. </li>
  365. <li>
  366. Execute the codelet. This is done by the MPI node selected in the 1st step of the algorithm.
  367. </li>
  368. <li>
  369. If several MPI nodes own data to be written to, send written data back to their owners.
  370. </li>
  371. </ol>
  372. The algorithm also includes a communication cache mechanism that
  373. allows not to send data twice to the same MPI node, unless the data
  374. has been modified. The cache can be disabled (see \ref STARPU_MPI_CACHE).
  375. \fn struct starpu_task *starpu_mpi_task_build(MPI_Comm comm, struct starpu_codelet *codelet, ...)
  376. \ingroup API_MPI_Support
  377. Create a task corresponding to \p codelet with the following given arguments.
  378. The argument list must be zero-terminated. The function performs the
  379. first two steps of the function starpu_mpi_task_insert(), i.e. submitting the
  380. MPI communications needed before the execution of the task, and the creation of
  381. the task on one node. Only the MPI
  382. node selected in the first step of the algorithm will return a valid
  383. task structure which can then be submitted, others will return <c>NULL</c>. The function
  384. starpu_mpi_task_post_build() MUST be called after that on all nodes, and after the submission of
  385. the task on the node which creates it, with the SAME list of arguments.
  386. \fn int starpu_mpi_task_post_build(MPI_Comm comm, struct starpu_codelet *codelet, ...)
  387. \ingroup API_MPI_Support
  388. MUST be called after a call to starpu_mpi_task_build(),
  389. with the SAME list of arguments. Perform the fourth -- last -- step of
  390. the algorithm described in starpu_mpi_task_insert().
  391. \fn void starpu_mpi_get_data_on_node(MPI_Comm comm, starpu_data_handle_t data_handle, int node)
  392. \ingroup API_MPI_Support
  393. Transfer data \p data_handle to MPI node \p node, sending it from its
  394. owner if needed. At least the target node and the owner have to call
  395. the function.
  396. \fn void starpu_mpi_get_data_on_node_detached(MPI_Comm comm, starpu_data_handle_t data_handle, int node, void (*callback)(void*), void *arg)
  397. \ingroup API_MPI_Support
  398. Transfer data \p data_handle to MPI node \p node, sending it from its
  399. owner if needed. At least the target node and the owner have to call
  400. the function. On reception, the \p callback function is called with
  401. the argument \p arg.
  402. \fn void starpu_mpi_get_data_on_all_nodes_detached(MPI_Comm comm, starpu_data_handle_t data_handle)
  403. \ingroup API_MPI_Support
  404. Transfer data \p data_handle to all MPI nodes, sending it from its
  405. owner if needed. All nodes have to call the function.
  406. @name Node Selection Policy
  407. \anchor MPINodeSelectionPolicy
  408. \ingroup API_MPI_Support
  409. \def STARPU_MPI_NODE_SELECTION_CURRENT_POLICY
  410. \ingroup API_MPI_Support
  411. todo
  412. \def STARPU_MPI_NODE_SELECTION_MOST_R_DATA
  413. \ingroup API_MPI_Support
  414. todo
  415. \fn int starpu_mpi_node_selection_get_current_policy()
  416. \ingroup API_MPI_Support
  417. Return the current policy used to select the node which will execute the codelet
  418. \fn int starpu_mpi_node_selection_set_current_policy(int policy)
  419. \ingroup API_MPI_Support
  420. Set the current policy used to select the node which will
  421. execute the codelet. The policy ::STARPU_MPI_NODE_SELECTION_MOST_R_DATA selects the
  422. node having the most data in ::STARPU_R mode so as to minimize the amount of
  423. data to be transfered.
  424. \fn int starpu_mpi_node_selection_register_policy(starpu_mpi_select_node_policy_func_t policy_func)
  425. \ingroup API_MPI_Support
  426. Register a new policy which can then be used when there is several nodes owning data in ::STARPU_W mode.
  427. Here an example of function defining a node selection policy.
  428. The codelet will be executed on the node owing the first data with a size bigger than 1M, or on the node
  429. 0 if no data fits the given size.
  430. \code{.c}
  431. int my_node_selection_policy(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data)
  432. {
  433. // me is the current MPI rank
  434. // nb_nodes is the number of MPI nodes
  435. // descr is the description of the data specified when calling starpu_mpi_task_insert
  436. // nb_data is the number of data in descr
  437. int i;
  438. for(i= 0 ; i<nb_data ; i++)
  439. {
  440. starpu_data_handle_t data = descr[i].handle;
  441. enum starpu_data_access_mode mode = descr[i].mode;
  442. if (mode & STARPU_R)
  443. {
  444. int rank = starpu_data_get_rank(data);
  445. size_t size = starpu_data_get_size(data);
  446. if (size > 1024*1024) return rank;
  447. }
  448. }
  449. return 0;
  450. }
  451. \endcode
  452. \fn int starpu_mpi_node_selection_unregister_policy(int policy)
  453. \ingroup API_MPI_Support
  454. Unregister a previously registered policy.
  455. @name Collective Operations
  456. \anchor MPICollectiveOperations
  457. \ingroup API_MPI_Support
  458. \fn void starpu_mpi_redux_data(MPI_Comm comm, starpu_data_handle_t data_handle)
  459. \ingroup API_MPI_Support
  460. Perform a reduction on the given data \p handle. All nodes send the data to its
  461. owner node which will perform a reduction.
  462. \fn void starpu_mpi_redux_data_prio(MPI_Comm comm, starpu_data_handle_t data_handle, int prio)
  463. \ingroup API_MPI_Support
  464. Similar to starpu_mpi_redux_data, but takes a priority \p prio.
  465. \fn int starpu_mpi_scatter_detached(starpu_data_handle_t *data_handles, int count, int root, MPI_Comm comm, void (*scallback)(void *), void *sarg, void (*rcallback)(void *), void *rarg)
  466. \ingroup API_MPI_Support
  467. Scatter data among processes of the communicator based on the
  468. ownership of the data. For each data of the array \p data_handles, the
  469. process \p root sends the data to the process owning this data. Processes
  470. receiving data must have valid data handles to receive them. On
  471. completion of the collective communication, the \p scallback function is
  472. called with the argument \p sarg on the process \p root, the \p
  473. rcallback function is called with the argument \p rarg on any other
  474. process.
  475. \fn int starpu_mpi_gather_detached(starpu_data_handle_t *data_handles, int count, int root, MPI_Comm comm, void (*scallback)(void *), void *sarg, void (*rcallback)(void *), void *rarg)
  476. \ingroup API_MPI_Support
  477. Gather data from the different processes of the communicator onto the
  478. process \p root. Each process owning data handle in the array
  479. \p data_handles will send them to the process \p root. The process \p
  480. root must have valid data handles to receive the data. On completion
  481. of the collective communication, the \p rcallback function is called
  482. with the argument \p rarg on the process root, the \p scallback
  483. function is called with the argument \p sarg on any other process.
  484. @name MPI Master Slave
  485. \anchor MPIMasterSlaveSupport
  486. \ingroup API_MPI_Support
  487. \def STARPU_USE_MPI_MASTER_SLAVE
  488. \ingroup API_MPI_Support
  489. Defined when StarPU has been installed with MPI Master Slave
  490. support. It should be used in your code to detect the availability of
  491. MPI Master Slave.
  492. */