mpi.doxy 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /*
  2. * This file is part of the StarPU Handbook.
  3. * Copyright (C) 2009--2011 Universit@'e de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
  5. * Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
  6. * See the file version.doxy for copying conditions.
  7. */
  8. /*! \defgroup API_MPI_Support MPI Support
  9. @name Initialisation
  10. \ingroup API_MPI_Support
  11. \fn int starpu_mpi_init (int *argc, char ***argv, int initialize_mpi)
  12. \ingroup API_MPI_Support
  13. Initializes the starpumpi library. \p initialize_mpi indicates if MPI
  14. should be initialized or not by StarPU. If the value is not 0, MPI
  15. will be initialized by calling <c>MPI_Init_Thread(argc, argv,
  16. MPI_THREAD_SERIALIZED, ...)</c>.
  17. \fn int starpu_mpi_initialize (void)
  18. \deprecated
  19. \ingroup API_MPI_Support
  20. This function has been made deprecated. One should use instead the
  21. function starpu_mpi_init(). This function does not call MPI_Init(), it
  22. should be called beforehand.
  23. \fn int starpu_mpi_initialize_extended (int *rank, int *world_size)
  24. \deprecated
  25. \ingroup API_MPI_Support
  26. This function has been made deprecated. One should use instead the
  27. function starpu_mpi_init(). MPI will be initialized by starpumpi by
  28. calling <c>MPI_Init_Thread(argc, argv, MPI_THREAD_SERIALIZED,
  29. ...)</c>.
  30. \fn int starpu_mpi_shutdown (void)
  31. \ingroup API_MPI_Support
  32. Cleans the starpumpi library. This must be called between calling
  33. starpu_mpi functions and starpu_shutdown(). MPI_Finalize() will be
  34. called if StarPU-MPI has been initialized by starpu_mpi_init().
  35. \fn void starpu_mpi_comm_amounts_retrieve (size_t *comm_amounts)
  36. \ingroup API_MPI_Support
  37. Retrieve the current amount of communications from the current node in
  38. the array \p comm_amounts which must have a size greater or equal to
  39. the world size. Communications statistics must be enabled (see
  40. \ref STARPU_COMM_STATS).
  41. @name Communication
  42. \anchor MPIPtpCommunication
  43. \ingroup API_MPI_Support
  44. \fn int starpu_mpi_send (starpu_data_handle_t data_handle, int dest, int mpi_tag, MPI_Comm comm)
  45. \ingroup API_MPI_Support
  46. Performs a standard-mode, blocking send of \p data_handle to the node
  47. \p dest using the message tag \p mpi_tag within the communicator \p
  48. comm.
  49. \fn int starpu_mpi_recv (starpu_data_handle_t data_handle, int source, int mpi_tag, MPI_Comm comm, MPI_Status *status)
  50. \ingroup API_MPI_Support
  51. Performs a standard-mode, blocking receive in \p data_handle from the
  52. node \p source using the message tag \p mpi_tag within the
  53. communicator \p comm.
  54. \fn int starpu_mpi_isend (starpu_data_handle_t data_handle, starpu_mpi_req *req, int dest, int mpi_tag, MPI_Comm comm)
  55. \ingroup API_MPI_Support
  56. Posts a standard-mode, non blocking send of \p data_handle to the node
  57. \p dest using the message tag \p mpi_tag within the communicator \p
  58. comm. After the call, the pointer to the request \p req can be used to
  59. test or to wait for the completion of the communication.
  60. \fn int starpu_mpi_irecv (starpu_data_handle_t data_handle, starpu_mpi_req *req, int source, int mpi_tag, MPI_Comm comm)
  61. \ingroup API_MPI_Support
  62. Posts a nonblocking receive in \p data_handle from the node \p source
  63. using the message tag \p mpi_tag within the communicator \p comm.
  64. After the call, the pointer to the request \p req can be used to test
  65. or to wait for the completion of the communication.
  66. \fn int starpu_mpi_isend_detached (starpu_data_handle_t data_handle, int dest, int mpi_tag, MPI_Comm comm, void (*callback)(void *), void *arg)
  67. \ingroup API_MPI_Support
  68. Posts a standard-mode, non blocking send of \p data_handle to the node
  69. \p dest using the message tag \p mpi_tag within the communicator \p
  70. comm. On completion, the \p callback function is called with the
  71. argument \p arg.
  72. Similarly to the pthread detached functionality, when a detached
  73. communication completes, its resources are automatically released back
  74. to the system, there is no need to test or to wait for the completion
  75. of the request.
  76. \fn int starpu_mpi_irecv_detached (starpu_data_handle_t data_handle, int source, int mpi_tag, MPI_Comm comm, void (*callback)(void *), void *arg)
  77. \ingroup API_MPI_Support
  78. Posts a nonblocking receive in \p data_handle from the node \p source
  79. using the message tag \p mpi_tag within the communicator \p comm. On
  80. completion, the \p callback function is called with the argument \p
  81. arg.
  82. Similarly to the pthread detached functionality, when a detached
  83. communication completes, its resources are automatically released back
  84. to the system, there is no need to test or to wait for the completion
  85. of the request.
  86. \fn int starpu_mpi_wait (starpu_mpi_req *req, MPI_Status *status)
  87. \ingroup API_MPI_Support
  88. Returns when the operation identified by request \p req is complete.
  89. \fn int starpu_mpi_test (starpu_mpi_req *req, int *flag, MPI_Status *status)
  90. \ingroup API_MPI_Support
  91. If the operation identified by \p req is complete, set \p flag to 1.
  92. The \p status object is set to contain information on the completed
  93. operation.
  94. \fn int starpu_mpi_barrier (MPI_Comm comm)
  95. \ingroup API_MPI_Support
  96. Blocks the caller until all group members of the communicator \p comm
  97. have called it.
  98. \fn int starpu_mpi_isend_detached_unlock_tag (starpu_data_handle_t data_handle, int dest, int mpi_tag, MPI_Comm comm, starpu_tag_t tag)
  99. \ingroup API_MPI_Support
  100. Posts a standard-mode, non blocking send of \p data_handle to the node
  101. \p dest using the message tag \p mpi_tag within the communicator \p
  102. comm. On completion, \p tag is unlocked.
  103. \fn int starpu_mpi_irecv_detached_unlock_tag (starpu_data_handle_t data_handle, int source, int mpi_tag, MPI_Comm comm, starpu_tag_t tag)
  104. \ingroup API_MPI_Support
  105. Posts a nonblocking receive in \p data_handle from the node \p source
  106. using the message tag \p mpi_tag within the communicator \p comm. On
  107. completion, \p tag is unlocked.
  108. \fn int starpu_mpi_isend_array_detached_unlock_tag (unsigned array_size, starpu_data_handle_t *data_handle, int *dest, int *mpi_tag, MPI_Comm *comm, starpu_tag_t tag)
  109. \ingroup API_MPI_Support
  110. Posts \p array_size standard-mode, non blocking send. Each post sends
  111. the n-th data of the array \p data_handle to the n-th node of the
  112. array \p dest using the n-th message tag of the array \p mpi_tag
  113. within the n-th communicator of the array \p comm. On completion of
  114. the all the requests, \p tag is unlocked.
  115. \fn int starpu_mpi_irecv_array_detached_unlock_tag (unsigned array_size, starpu_data_handle_t *data_handle, int *source, int *mpi_tag, MPI_Comm *comm, starpu_tag_t tag)
  116. \ingroup API_MPI_Support
  117. Posts \p array_size nonblocking receive. Each post receives in the n-th
  118. data of the array \p data_handle from the n-th node of the array \p
  119. source using the n-th message tag of the array \p mpi_tag within the
  120. n-th communicator of the array \p comm. On completion of the all the
  121. requests, \p tag is unlocked.
  122. @name Communication Cache
  123. \ingroup API_MPI_Support
  124. \fn void starpu_mpi_cache_flush (MPI_Comm comm, starpu_data_handle_t data_handle)
  125. \ingroup API_MPI_Support
  126. Clear the send and receive communication cache for the data
  127. \p data_handle. The function has to be called synchronously by all the
  128. MPI nodes. The function does nothing if the cache mechanism is
  129. disabled (see \ref STARPU_MPI_CACHE).
  130. \fn void starpu_mpi_cache_flush_all_data (MPI_Comm comm)
  131. \ingroup API_MPI_Support
  132. Clear the send and receive communication cache for all data. The
  133. function has to be called synchronously by all the MPI nodes. The
  134. function does nothing if the cache mechanism is disabled (see
  135. \ref STARPU_MPI_CACHE).
  136. @name MPI Insert Task
  137. \anchor MPIInsertTask
  138. \ingroup API_MPI_Support
  139. \fn int starpu_data_set_tag (starpu_data_handle_t handle, int tag)
  140. \ingroup API_MPI_Support
  141. Tell StarPU-MPI which MPI tag to use when exchanging the data.
  142. \fn int starpu_data_get_tag (starpu_data_handle_t handle)
  143. \ingroup API_MPI_Support
  144. Returns the MPI tag to be used when exchanging the data.
  145. \fn int starpu_data_set_rank (starpu_data_handle_t handle, int rank)
  146. \ingroup API_MPI_Support
  147. Tell StarPU-MPI which MPI node "owns" a given data, that is, the node
  148. which will always keep an up-to-date value, and will by default
  149. execute tasks which write to it.
  150. \fn int starpu_data_get_rank (starpu_data_handle_t handle)
  151. \ingroup API_MPI_Support
  152. Returns the last value set by starpu_data_set_rank().
  153. \def STARPU_EXECUTE_ON_NODE
  154. \ingroup API_MPI_Support
  155. this macro is used when calling starpu_mpi_insert_task(), and must be
  156. followed by a integer value which specified the node on which to
  157. execute the codelet.
  158. \def STARPU_EXECUTE_ON_DATA
  159. \ingroup API_MPI_Support
  160. this macro is used when calling starpu_mpi_insert_task(), and must be
  161. followed by a data handle to specify that the node owning the given
  162. data will execute the codelet.
  163. \fn int starpu_mpi_insert_task (MPI_Comm comm, struct starpu_codelet *codelet, ...)
  164. \ingroup API_MPI_Support
  165. Create and submit a task corresponding to codelet with the following
  166. arguments. The argument list must be zero-terminated.
  167. The arguments following the codelets are the same types as for the
  168. function starpu_insert_task(). The extra argument
  169. ::STARPU_EXECUTE_ON_NODE followed by an integer allows to specify the
  170. MPI node to execute the codelet. It is also possible to specify that
  171. the node owning a specific data will execute the codelet, by using
  172. ::STARPU_EXECUTE_ON_DATA followed by a data handle.
  173. The internal algorithm is as follows:
  174. <ol>
  175. <li>
  176. Find out which MPI node is going to execute the codelet.
  177. <ul>
  178. <li>If there is only one node owning data in ::STARPU_W mode, it will be selected;
  179. <li>If there is several nodes owning data in ::STARPU_W node, the one selected will be the one having the least data in R mode so as to minimize the amount of data to be transfered;
  180. <li>The argument ::STARPU_EXECUTE_ON_NODE followed by an integer can be used to specify the node;
  181. <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.
  182. </ul>
  183. </li>
  184. <li>
  185. 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.
  186. </li>
  187. <li>
  188. Execute the codelet. This is done by the MPI node selected in the 1st step of the algorithm.
  189. </li>
  190. <li>
  191. If several MPI nodes own data to be written to, send written data back to their owners.
  192. </li>
  193. </ol>
  194. The algorithm also includes a communication cache mechanism that
  195. allows not to send data twice to the same MPI node, unless the data
  196. has been modified. The cache can be disabled (see \ref STARPU_MPI_CACHE).
  197. \fn void starpu_mpi_get_data_on_node (MPI_Comm comm, starpu_data_handle_t data_handle, int node)
  198. \ingroup API_MPI_Support
  199. Transfer data \p data_handle to MPI node \p node, sending it from its
  200. owner if needed. At least the target node and the owner have to call
  201. the function.
  202. \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)
  203. \ingroup API_MPI_Support
  204. Transfer data \p data_handle to MPI node \p node, sending it from its
  205. owner if needed. At least the target node and the owner have to call
  206. the function. On reception, the \p callback function is called with
  207. the argument \p arg.
  208. @name Collective Operations
  209. \anchor MPICollectiveOperations
  210. \ingroup API_MPI_Support
  211. \fn void starpu_mpi_redux_data (MPI_Comm comm, starpu_data_handle_t data_handle)
  212. \ingroup API_MPI_Support
  213. Perform a reduction on the given data. All nodes send the data to its
  214. owner node which will perform a reduction.
  215. \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)
  216. \ingroup API_MPI_Support
  217. Scatter data among processes of the communicator based on the
  218. ownership of the data. For each data of the array \p data_handles, the
  219. process \p root sends the data to the process owning this data. Processes
  220. receiving data must have valid data handles to receive them. On
  221. completion of the collective communication, the \p scallback function is
  222. called with the argument \p sarg on the process \p root, the \p
  223. rcallback function is called with the argument \p rarg on any other
  224. process.
  225. \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)
  226. \ingroup API_MPI_Support
  227. Gather data from the different processes of the communicator onto the
  228. process \p root. Each process owning data handle in the array
  229. \p data_handles will send them to the process \p root. The process \p
  230. root must have valid data handles to receive the data. On completion
  231. of the collective communication, the \p rcallback function is called
  232. with the argument \p rarg on the process root, the \p scallback
  233. function is called with the argument \p sarg on any other process.
  234. */