mpi.doxy 27 KB

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