410_mpi_support.doxy 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), 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. /*! \page MPISupport MPI Support
  17. The integration of MPI transfers within task parallelism is done in a
  18. very natural way by the means of asynchronous interactions between the
  19. application and StarPU. This is implemented in a separate <c>libstarpumpi</c> library
  20. which basically provides "StarPU" equivalents of <c>MPI_*</c> functions, where
  21. <c>void *</c> buffers are replaced with ::starpu_data_handle_t, and all
  22. GPU-RAM-NIC transfers are handled efficiently by StarPU-MPI. The user has to
  23. use the usual <c>mpirun</c> command of the MPI implementation to start StarPU on
  24. the different MPI nodes.
  25. In case the user wants to run several MPI processes by machine (e.g. one per
  26. NUMA node), \ref STARPU_WORKERS_GETBIND should be used to make StarPU take into
  27. account the binding set by the MPI launcher (otherwise each StarPU instance
  28. would try to bind on all cores of the machine...)
  29. An MPI Insert Task function provides an even more seamless transition to a
  30. distributed application, by automatically issuing all required data transfers
  31. according to the task graph and an application-provided distribution.
  32. \section MPIBuild Building with MPI support
  33. If a <c>mpicc</c> compiler is already in your PATH, StarPU will automatically
  34. enable MPI support in the build. If <c>mpicc</c> is not in PATH, you
  35. can specify its location by passing <c>--with-mpicc=/where/there/is/mpicc</c> to
  36. <c>./configure</c>
  37. It can be useful to enable MPI tests during <c>make check</c> by passing
  38. <c>--enable-mpi-check</c> to <c>./configure</c>. And similarly to
  39. <c>mpicc</c>, if <c>mpiexec</c> in not in PATH, you can specify its location by passing
  40. <c>--with-mpiexec=/where/there/is/mpiexec</c> to <c>./configure</c>, but this is
  41. not needed if it is next to <c>mpicc</c>, configure will look there in addition to PATH.
  42. Similarly, Fortran examples use <c>mpif90</c>, which can be specified manually
  43. with <c>--with-mpifort</c> if it can't be found automatically.
  44. \section ExampleDocumentation Example Used In This Documentation
  45. The example below will be used as the base for this documentation. It
  46. initializes a token on node 0, and the token is passed from node to node,
  47. incremented by one on each step. The code is not using StarPU yet.
  48. \code{.c}
  49. for (loop = 0; loop < nloops; loop++)
  50. {
  51. int tag = loop*size + rank;
  52. if (loop == 0 && rank == 0)
  53. {
  54. token = 0;
  55. fprintf(stdout, "Start with token value %d\n", token);
  56. }
  57. else
  58. {
  59. MPI_Recv(&token, 1, MPI_INT, (rank+size-1)%size, tag, MPI_COMM_WORLD);
  60. }
  61. token++;
  62. if (loop == last_loop && rank == last_rank)
  63. {
  64. fprintf(stdout, "Finished: token value %d\n", token);
  65. }
  66. else
  67. {
  68. MPI_Send(&token, 1, MPI_INT, (rank+1)%size, tag+1, MPI_COMM_WORLD);
  69. }
  70. }
  71. \endcode
  72. \section NotUsingMPISupport About Not Using The MPI Support
  73. Although StarPU provides MPI support, the application programmer may want to
  74. keep his MPI communications as they are for a start, and only delegate task
  75. execution to StarPU. This is possible by just using starpu_data_acquire(), for
  76. instance:
  77. \code{.c}
  78. for (loop = 0; loop < nloops; loop++)
  79. {
  80. int tag = loop*size + rank;
  81. /* Acquire the data to be able to write to it */
  82. starpu_data_acquire(token_handle, STARPU_W);
  83. if (loop == 0 && rank == 0)
  84. {
  85. token = 0;
  86. fprintf(stdout, "Start with token value %d\n", token);
  87. }
  88. else
  89. {
  90. MPI_Recv(&token, 1, MPI_INT, (rank+size-1)%size, tag, MPI_COMM_WORLD);
  91. }
  92. starpu_data_release(token_handle);
  93. /* Task delegation to StarPU to increment the token. The execution might
  94. * be performed on a CPU, a GPU, etc. */
  95. increment_token();
  96. /* Acquire the update data to be able to read from it */
  97. starpu_data_acquire(token_handle, STARPU_R);
  98. if (loop == last_loop && rank == last_rank)
  99. {
  100. fprintf(stdout, "Finished: token value %d\n", token);
  101. }
  102. else
  103. {
  104. MPI_Send(&token, 1, MPI_INT, (rank+1)%size, tag+1, MPI_COMM_WORLD);
  105. }
  106. starpu_data_release(token_handle);
  107. }
  108. \endcode
  109. In that case, <c>libstarpumpi</c> is not needed. One can also use <c>MPI_Isend()</c> and
  110. <c>MPI_Irecv()</c>, by calling starpu_data_release() after <c>MPI_Wait()</c> or <c>MPI_Test()</c>
  111. have notified completion.
  112. It is however better to use <c>libstarpumpi</c>, to save the application from having to
  113. synchronize with starpu_data_acquire(), and instead just submit all tasks and
  114. communications asynchronously, and wait for the overall completion.
  115. \section SimpleExample Simple Example
  116. The flags required to compile or link against the MPI layer are
  117. accessible with the following commands:
  118. \verbatim
  119. $ pkg-config --cflags starpumpi-1.3 # options for the compiler
  120. $ pkg-config --libs starpumpi-1.3 # options for the linker
  121. \endverbatim
  122. \code{.c}
  123. void increment_token(void)
  124. {
  125. struct starpu_task *task = starpu_task_create();
  126. task->cl = &increment_cl;
  127. task->handles[0] = token_handle;
  128. starpu_task_submit(task);
  129. }
  130. int main(int argc, char **argv)
  131. {
  132. int rank, size;
  133. starpu_mpi_init_conf(&argc, &argv, 1, MPI_COMM_WORLD, NULL);
  134. starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
  135. starpu_mpi_comm_size(MPI_COMM_WORLD, &size);
  136. starpu_vector_data_register(&token_handle, STARPU_MAIN_RAM, (uintptr_t)&token, 1, sizeof(unsigned));
  137. unsigned nloops = NITER;
  138. unsigned loop;
  139. unsigned last_loop = nloops - 1;
  140. unsigned last_rank = size - 1;
  141. for (loop = 0; loop < nloops; loop++)
  142. {
  143. int tag = loop*size + rank;
  144. if (loop == 0 && rank == 0)
  145. {
  146. starpu_data_acquire(token_handle, STARPU_W);
  147. token = 0;
  148. fprintf(stdout, "Start with token value %d\n", token);
  149. starpu_data_release(token_handle);
  150. }
  151. else
  152. {
  153. starpu_mpi_irecv_detached(token_handle, (rank+size-1)%size, tag, MPI_COMM_WORLD, NULL, NULL);
  154. }
  155. increment_token();
  156. if (loop == last_loop && rank == last_rank)
  157. {
  158. starpu_data_acquire(token_handle, STARPU_R);
  159. fprintf(stdout, "Finished: token value %d\n", token);
  160. starpu_data_release(token_handle);
  161. }
  162. else
  163. {
  164. starpu_mpi_isend_detached(token_handle, (rank+1)%size, tag+1, MPI_COMM_WORLD, NULL, NULL);
  165. }
  166. }
  167. starpu_task_wait_for_all();
  168. starpu_mpi_shutdown();
  169. if (rank == last_rank)
  170. {
  171. fprintf(stderr, "[%d] token = %d == %d * %d ?\n", rank, token, nloops, size);
  172. STARPU_ASSERT(token == nloops*size);
  173. }
  174. \endcode
  175. We have here replaced <c>MPI_Recv()</c> and <c>MPI_Send()</c> with starpu_mpi_irecv_detached()
  176. and starpu_mpi_isend_detached(), which just submit the communication to be
  177. performed. The implicit sequential consistency dependencies provide
  178. synchronization between mpi reception and emission and the corresponding tasks.
  179. The only remaining synchronization with starpu_data_acquire() is at
  180. the beginning and the end.
  181. \section MPIInitialization How to Initialize StarPU-MPI
  182. As seen in the previous example, one has to call starpu_mpi_init_conf() to
  183. initialize StarPU-MPI. The third parameter of the function indicates
  184. if MPI should be initialized by StarPU or if the application did it
  185. itself. If the application initializes MPI itself, it must call
  186. <c>MPI_Init_thread()</c> with <c>MPI_THREAD_SERIALIZED</c> or
  187. <c>MPI_THREAD_MULTIPLE</c>, since StarPU-MPI uses a separate thread to
  188. perform the communications. <c>MPI_THREAD_MULTIPLE</c> is necessary if
  189. the application also performs some MPI communications.
  190. \section PointToPointCommunication Point To Point Communication
  191. The standard point to point communications of MPI have been
  192. implemented. The semantic is similar to the MPI one, but adapted to
  193. the DSM provided by StarPU. A MPI request will only be submitted when
  194. the data is available in the main memory of the node submitting the
  195. request.
  196. There are two types of asynchronous communications: the classic
  197. asynchronous communications and the detached communications. The
  198. classic asynchronous communications (starpu_mpi_isend() and
  199. starpu_mpi_irecv()) need to be followed by a call to
  200. starpu_mpi_wait() or to starpu_mpi_test() to wait for or to
  201. test the completion of the communication. Waiting for or testing the
  202. completion of detached communications is not possible, this is done
  203. internally by StarPU-MPI, on completion, the resources are
  204. automatically released. This mechanism is similar to the pthread
  205. detach state attribute which determines whether a thread will be
  206. created in a joinable or a detached state.
  207. For send communications, data is acquired with the mode ::STARPU_R.
  208. When using the \c configure option
  209. \ref enable-mpi-pedantic-isend "--enable-mpi-pedantic-isend", the mode
  210. ::STARPU_RW is used to make sure there is no more than 1 concurrent
  211. \c MPI_Isend() call accessing a data
  212. and StarPU does not read from it from tasks during the communication.
  213. Internally, all communication are divided in 2 communications, a first
  214. message is used to exchange an envelope describing the data (i.e its
  215. tag and its size), the data itself is sent in a second message. All
  216. MPI communications submitted by StarPU uses a unique tag which has a
  217. default value, and can be accessed with the functions
  218. starpu_mpi_get_communication_tag() and
  219. starpu_mpi_set_communication_tag(). The matching of tags with
  220. corresponding requests is done within StarPU-MPI.
  221. For any userland communication, the call of the corresponding function
  222. (e.g starpu_mpi_isend()) will result in the creation of a StarPU-MPI
  223. request, the function starpu_data_acquire_cb() is then called to
  224. asynchronously request StarPU to fetch the data in main memory; when
  225. the data is ready and the corresponding buffer has already been
  226. received by MPI, it will be copied in the memory of the data,
  227. otherwise the request is stored in the <em>early requests list</em>. Sending
  228. requests are stored in the <em>ready requests list</em>.
  229. While requests need to be processed, the StarPU-MPI progression thread
  230. does the following:
  231. <ol>
  232. <li> it polls the <em>ready requests list</em>. For all the ready
  233. requests, the appropriate function is called to post the corresponding
  234. MPI call. For example, an initial call to starpu_mpi_isend() will
  235. result in a call to <c>MPI_Isend()</c>. If the request is marked as
  236. detached, the request will then be added in the <em>detached requests
  237. list</em>.
  238. </li>
  239. <li> it posts a <c>MPI_Irecv()</c> to retrieve a data envelope.
  240. </li>
  241. <li> it polls the <em>detached requests list</em>. For all the detached
  242. requests, it tests its completion of the MPI request by calling
  243. <c>MPI_Test()</c>. On completion, the data handle is released, and if a
  244. callback was defined, it is called.
  245. </li>
  246. <li> finally, it checks if a data envelope has been received. If so,
  247. if the data envelope matches a request in the <em>early requests list</em> (i.e
  248. the request has already been posted by the application), the
  249. corresponding MPI call is posted (similarly to the first step above).
  250. If the data envelope does not match any application request, a
  251. temporary handle is created to receive the data, a StarPU-MPI request
  252. is created and added into the <em>ready requests list</em>, and thus will be
  253. processed in the first step of the next loop.
  254. </li>
  255. </ol>
  256. \ref MPIPtpCommunication gives the list of all the
  257. point to point communications defined in StarPU-MPI.
  258. \section ExchangingUserDefinedDataInterface Exchanging User Defined Data Interface
  259. New data interfaces defined as explained in \ref DefiningANewDataInterface
  260. can also be used within StarPU-MPI and
  261. exchanged between nodes. Two functions needs to be defined through the
  262. type starpu_data_interface_ops. The function
  263. starpu_data_interface_ops::pack_data takes a handle and returns a
  264. contiguous memory buffer allocated with
  265. \code{.c}
  266. starpu_malloc_flags(ptr, size, 0)
  267. \endcode
  268. along with its size where data to be conveyed
  269. to another node should be copied. The reversed operation is
  270. implemented in the function starpu_data_interface_ops::unpack_data which
  271. takes a contiguous memory buffer and recreates the data handle.
  272. \code{.c}
  273. static int complex_pack_data(starpu_data_handle_t handle, unsigned node, void **ptr, ssize_t *count)
  274. {
  275. STARPU_ASSERT(starpu_data_test_if_allocated_on_node(handle, node));
  276. struct starpu_complex_interface *complex_interface = (struct starpu_complex_interface *) starpu_data_get_interface_on_node(handle, node);
  277. *count = complex_get_size(handle);
  278. *ptr = starpu_malloc_on_node_flags(node, *count, 0);
  279. memcpy(*ptr, complex_interface->real, complex_interface->nx*sizeof(double));
  280. memcpy(*ptr+complex_interface->nx*sizeof(double), complex_interface->imaginary, complex_interface->nx*sizeof(double));
  281. return 0;
  282. }
  283. static int complex_unpack_data(starpu_data_handle_t handle, unsigned node, void *ptr, size_t count)
  284. {
  285. STARPU_ASSERT(starpu_data_test_if_allocated_on_node(handle, node));
  286. struct starpu_complex_interface *complex_interface = (struct starpu_complex_interface *) starpu_data_get_interface_on_node(handle, node);
  287. memcpy(complex_interface->real, ptr, complex_interface->nx*sizeof(double));
  288. memcpy(complex_interface->imaginary, ptr+complex_interface->nx*sizeof(double), complex_interface->nx*sizeof(double));
  289. return 0;
  290. }
  291. static struct starpu_data_interface_ops interface_complex_ops =
  292. {
  293. ...
  294. .pack_data = complex_pack_data,
  295. .unpack_data = complex_unpack_data
  296. };
  297. \endcode
  298. Instead of defining pack and unpack operations, users may want to attach a MPI type to their user defined data interface. The function starpu_mpi_datatype_register() allows to do so. This function takes 3 parameters: the data handle for which the MPI datatype is going to be defined, a function's pointer that will create the MPI datatype, and a function's pointer that will free the MPI datatype. If for some data an MPI datatype can not be built (e.g. complex data structure), the creation function can return -1, StarPU-MPI will then fallback to using pack/unpack.
  299. \code{.c}
  300. starpu_data_interface handle;
  301. starpu_complex_data_register(&handle, STARPU_MAIN_RAM, real, imaginary, 2);
  302. starpu_mpi_datatype_register(handle, starpu_complex_interface_datatype_allocate, starpu_complex_interface_datatype_free);
  303. \endcode
  304. The functions to create and free the MPI datatype are defined as follows.
  305. \code{.c}
  306. void starpu_complex_interface_datatype_allocate(starpu_data_handle_t handle, MPI_Datatype *mpi_datatype)
  307. {
  308. int ret;
  309. int blocklengths[2];
  310. MPI_Aint displacements[2];
  311. MPI_Datatype types[2] = {MPI_DOUBLE, MPI_DOUBLE};
  312. struct starpu_complex_interface *complex_interface = (struct starpu_complex_interface *) starpu_data_get_interface_on_node(handle, STARPU_MAIN_RAM);
  313. MPI_Get_address(complex_interface, displacements);
  314. MPI_Get_address(&complex_interface->imaginary, displacements+1);
  315. displacements[1] -= displacements[0];
  316. displacements[0] = 0;
  317. blocklengths[0] = complex_interface->nx;
  318. blocklengths[1] = complex_interface->nx;
  319. ret = MPI_Type_create_struct(2, blocklengths, displacements, types, mpi_datatype);
  320. STARPU_ASSERT_MSG(ret == MPI_SUCCESS, "MPI_Type_contiguous failed");
  321. ret = MPI_Type_commit(mpi_datatype);
  322. STARPU_ASSERT_MSG(ret == MPI_SUCCESS, "MPI_Type_commit failed");
  323. }
  324. void starpu_complex_interface_datatype_free(MPI_Datatype *mpi_datatype)
  325. {
  326. MPI_Type_free(mpi_datatype);
  327. }
  328. \endcode
  329. Note that it is important to make sure no communication is going to occur before the function starpu_mpi_datatype_register() is called. This would produce an undefined result as the data may be received before the function is called, and so the MPI datatype would not be known by the StarPU-MPI communication engine, and the data would be processed with the pack and unpack operations.
  330. \code{.c}
  331. starpu_data_interface handle;
  332. starpu_complex_data_register(&handle, STARPU_MAIN_RAM, real, imaginary, 2);
  333. starpu_mpi_datatype_register(handle, starpu_complex_interface_datatype_allocate, starpu_complex_interface_datatype_free);
  334. starpu_mpi_barrier(MPI_COMM_WORLD);
  335. \endcode
  336. \section MPIInsertTaskUtility MPI Insert Task Utility
  337. To save the programmer from having to explicit all communications, StarPU
  338. provides an "MPI Insert Task Utility". The principe is that the application
  339. decides a distribution of the data over the MPI nodes by allocating it and
  340. notifying StarPU of this decision, i.e. tell StarPU which MPI node "owns"
  341. which data. It also decides, for each handle, an MPI tag which will be used to
  342. exchange the content of the handle. All MPI nodes then process the whole task
  343. graph, and StarPU automatically determines which node actually execute which
  344. task, and trigger the required MPI transfers.
  345. The list of functions is described in \ref MPIInsertTask.
  346. Here an stencil example showing how to use starpu_mpi_task_insert(). One
  347. first needs to define a distribution function which specifies the
  348. locality of the data. Note that the data needs to be registered to MPI
  349. by calling starpu_mpi_data_register(). This function allows to set
  350. the distribution information and the MPI tag which should be used when
  351. communicating the data. It also allows to automatically clear the MPI
  352. communication cache when unregistering the data.
  353. \code{.c}
  354. /* Returns the MPI node number where data is */
  355. int my_distrib(int x, int y, int nb_nodes)
  356. {
  357. /* Block distrib */
  358. return ((int)(x / sqrt(nb_nodes) + (y / sqrt(nb_nodes)) * sqrt(nb_nodes))) % nb_nodes;
  359. // /* Other examples useful for other kinds of computations */
  360. // /* / distrib */
  361. // return (x+y) % nb_nodes;
  362. // /* Block cyclic distrib */
  363. // unsigned side = sqrt(nb_nodes);
  364. // return x % side + (y % side) * size;
  365. }
  366. \endcode
  367. Now the data can be registered within StarPU. Data which are not
  368. owned but will be needed for computations can be registered through
  369. the lazy allocation mechanism, i.e. with a <c>home_node</c> set to <c>-1</c>.
  370. StarPU will automatically allocate the memory when it is used for the
  371. first time.
  372. One can note an optimization here (the <c>else if</c> test): we only register
  373. data which will be needed by the tasks that we will execute.
  374. \code{.c}
  375. unsigned matrix[X][Y];
  376. starpu_data_handle_t data_handles[X][Y];
  377. for(x = 0; x < X; x++)
  378. {
  379. for (y = 0; y < Y; y++)
  380. {
  381. int mpi_rank = my_distrib(x, y, size);
  382. if (mpi_rank == my_rank)
  383. /* Owning data */
  384. starpu_variable_data_register(&data_handles[x][y], STARPU_MAIN_RAM, (uintptr_t)&(matrix[x][y]), sizeof(unsigned));
  385. else if (my_rank == my_distrib(x+1, y, size) || my_rank == my_distrib(x-1, y, size)
  386. || my_rank == my_distrib(x, y+1, size) || my_rank == my_distrib(x, y-1, size))
  387. /* I don't own this index, but will need it for my computations */
  388. starpu_variable_data_register(&data_handles[x][y], -1, (uintptr_t)NULL, sizeof(unsigned));
  389. else
  390. /* I know it's useless to allocate anything for this */
  391. data_handles[x][y] = NULL;
  392. if (data_handles[x][y])
  393. {
  394. starpu_mpi_data_register(data_handles[x][y], x*X+y, mpi_rank);
  395. }
  396. }
  397. }
  398. \endcode
  399. Now starpu_mpi_task_insert() can be called for the different
  400. steps of the application.
  401. \code{.c}
  402. for(loop=0 ; loop<niter; loop++)
  403. for (x = 1; x < X-1; x++)
  404. for (y = 1; y < Y-1; y++)
  405. starpu_mpi_task_insert(MPI_COMM_WORLD, &stencil5_cl,
  406. STARPU_RW, data_handles[x][y],
  407. STARPU_R, data_handles[x-1][y],
  408. STARPU_R, data_handles[x+1][y],
  409. STARPU_R, data_handles[x][y-1],
  410. STARPU_R, data_handles[x][y+1],
  411. 0);
  412. starpu_task_wait_for_all();
  413. \endcode
  414. I.e. all MPI nodes process the whole task graph, but as mentioned above, for
  415. each task, only the MPI node which owns the data being written to (here,
  416. <c>data_handles[x][y]</c>) will actually run the task. The other MPI nodes will
  417. automatically send the required data.
  418. To tune the placement of tasks among MPI nodes, one can use
  419. ::STARPU_EXECUTE_ON_NODE or ::STARPU_EXECUTE_ON_DATA to specify an explicit
  420. node, or the node of a given data (e.g. one of the parameters), or use
  421. starpu_mpi_node_selection_register_policy() and ::STARPU_NODE_SELECTION_POLICY
  422. to provide a dynamic policy.
  423. A function starpu_mpi_task_build() is also provided with the aim to
  424. only construct the task structure. All MPI nodes need to call the
  425. function, which posts the required send/recv on the various nodes which have to.
  426. Only the node which is to execute the task will then return a
  427. valid task structure, others will return <c>NULL</c>. This node must submit the task.
  428. All nodes then need to call the function starpu_mpi_task_post_build() -- with the same
  429. list of arguments as starpu_mpi_task_build() -- to post all the
  430. necessary data communications meant to happen after the task execution.
  431. \code{.c}
  432. struct starpu_task *task;
  433. task = starpu_mpi_task_build(MPI_COMM_WORLD, &cl,
  434. STARPU_RW, data_handles[0],
  435. STARPU_R, data_handles[1],
  436. 0);
  437. if (task) starpu_task_submit(task);
  438. starpu_mpi_task_post_build(MPI_COMM_WORLD, &cl,
  439. STARPU_RW, data_handles[0],
  440. STARPU_R, data_handles[1],
  441. 0);
  442. \endcode
  443. \section MPIInsertPruning Pruning MPI Task Insertion
  444. Making all MPI nodes process the whole graph can be a concern with a growing
  445. number of nodes. To avoid this, the
  446. application can prune the task for loops according to the data distribution,
  447. so as to only submit tasks on nodes which have to care about them (either to
  448. execute them, or to send the required data).
  449. A way to do some of this quite easily can be to just add an <c>if</c> like this:
  450. \code{.c}
  451. for(loop=0 ; loop<niter; loop++)
  452. for (x = 1; x < X-1; x++)
  453. for (y = 1; y < Y-1; y++)
  454. if (my_distrib(x,y,size) == my_rank
  455. || my_distrib(x-1,y,size) == my_rank
  456. || my_distrib(x+1,y,size) == my_rank
  457. || my_distrib(x,y-1,size) == my_rank
  458. || my_distrib(x,y+1,size) == my_rank)
  459. starpu_mpi_task_insert(MPI_COMM_WORLD, &stencil5_cl,
  460. STARPU_RW, data_handles[x][y],
  461. STARPU_R, data_handles[x-1][y],
  462. STARPU_R, data_handles[x+1][y],
  463. STARPU_R, data_handles[x][y-1],
  464. STARPU_R, data_handles[x][y+1],
  465. 0);
  466. starpu_task_wait_for_all();
  467. \endcode
  468. This permits to drop the cost of function call argument passing and parsing.
  469. If the <c>my_distrib</c> function can be inlined by the compiler, the latter can
  470. improve the test.
  471. If the <c>size</c> can be made a compile-time constant, the compiler can
  472. considerably improve the test further.
  473. If the distribution function is not too complex and the compiler is very good,
  474. the latter can even optimize the <c>for</c> loops, thus dramatically reducing
  475. the cost of task submission.
  476. To estimate quickly how long task submission takes, and notably how much pruning
  477. saves, a quick and easy way is to measure the submission time of just one of the
  478. MPI nodes. This can be achieved by running the application on just one MPI node
  479. with the following environment variables:
  480. \code
  481. export STARPU_DISABLE_KERNELS=1
  482. export STARPU_MPI_FAKE_RANK=2
  483. export STARPU_MPI_FAKE_SIZE=1024
  484. \endcode
  485. Here we have disabled the kernel function call to skip the actual computation
  486. time and only keep submission time, and we have asked StarPU to fake running on
  487. MPI node 2 out of 1024 nodes.
  488. \section MPITemporaryData Temporary Data
  489. To be able to use starpu_mpi_task_insert(), one has to call
  490. starpu_mpi_data_register(), so that StarPU-MPI can know what it needs to do for
  491. each data. Parameters of starpu_mpi_data_register() are normally the same on all
  492. nodes for a given data, so that all nodes agree on which node owns the data, and
  493. which tag is used to transfer its value.
  494. It can however be useful to register e.g. some temporary data on just one node,
  495. without having to register a dumb handle on all nodes, while only one node will
  496. actually need to know about it. In this case, nodes which will not need the data
  497. can just pass \c NULL to starpu_mpi_task_insert():
  498. \code{.c}
  499. starpu_data_handle_t data0 = NULL;
  500. if (rank == 0)
  501. {
  502. starpu_variable_data_register(&data0, STARPU_MAIN_RAM, (uintptr_t) &val0, sizeof(val0));
  503. starpu_mpi_data_register(data0, 0, rank);
  504. }
  505. starpu_mpi_task_insert(MPI_COMM_WORLD, &cl, STARPU_W, data0, 0); /* Executes on node 0 */
  506. \endcode
  507. Here, nodes whose rank is not \c 0 will simply not take care of the data, and consider it to be on another node.
  508. This can be mixed various way, for instance here node \c 1 determines that it does
  509. not have to care about \c data0, but knows that it should send the value of its
  510. \c data1 to node \c 0, which owns data and thus will need the value of \c data1 to execute the task:
  511. \code{.c}
  512. starpu_data_handle_t data0 = NULL, data1, data;
  513. if (rank == 0)
  514. {
  515. starpu_variable_data_register(&data0, STARPU_MAIN_RAM, (uintptr_t) &val0, sizeof(val0));
  516. starpu_mpi_data_register(data0, -1, rank);
  517. starpu_variable_data_register(&data1, -1, 0, sizeof(val1));
  518. starpu_variable_data_register(&data, STARPU_MAIN_RAM, (uintptr_t) &val, sizeof(val));
  519. }
  520. else if (rank == 1)
  521. {
  522. starpu_variable_data_register(&data1, STARPU_MAIN_RAM, (uintptr_t) &val1, sizeof(val1));
  523. starpu_variable_data_register(&data, -1, 0, sizeof(val));
  524. }
  525. starpu_mpi_data_register(data, 42, 0);
  526. starpu_mpi_data_register(data1, 43, 1);
  527. starpu_mpi_task_insert(MPI_COMM_WORLD, &cl, STARPU_W, data, STARPU_R, data0, STARPU_R, data1, 0); /* Executes on node 0 */
  528. \endcode
  529. \section MPIPerNodeData Per-node Data
  530. Further than temporary data on just one node, one may want per-node data,
  531. to e.g. replicate some computation because that is less expensive than
  532. communicating the value over MPI:
  533. \code{.c}
  534. starpu_data_handle pernode, data0, data1;
  535. starpu_variable_data_register(&pernode, -1, 0, sizeof(val));
  536. starpu_mpi_data_register(pernode, -1, STARPU_MPI_PER_NODE);
  537. /* Normal data: one on node0, one on node1 */
  538. if (rank == 0)
  539. {
  540. starpu_variable_data_register(&data0, STARPU_MAIN_RAM, (uintptr_t) &val0, sizeof(val0));
  541. starpu_variable_data_register(&data1, -1, 0, sizeof(val1));
  542. }
  543. else if (rank == 1)
  544. {
  545. starpu_variable_data_register(&data0, -1, 0, sizeof(val1));
  546. starpu_variable_data_register(&data1, STARPU_MAIN_RAM, (uintptr_t) &val1, sizeof(val1));
  547. }
  548. starpu_mpi_data_register(data0, 42, 0);
  549. starpu_mpi_data_register(data1, 43, 1);
  550. starpu_mpi_task_insert(MPI_COMM_WORLD, &cl, STARPU_W, pernode, 0); /* Will be replicated on all nodes */
  551. starpu_mpi_task_insert(MPI_COMM_WORLD, &cl2, STARPU_RW, data0, STARPU_R, pernode); /* Will execute on node 0, using its own pernode*/
  552. starpu_mpi_task_insert(MPI_COMM_WORLD, &cl2, STARPU_RW, data1, STARPU_R, pernode); /* Will execute on node 1, using its own pernode*/
  553. \endcode
  554. One can turn a normal data into pernode data, by first broadcasting it to all nodes:
  555. \code{.c}
  556. starpu_data_handle data;
  557. starpu_variable_data_register(&data, -1, 0, sizeof(val));
  558. starpu_mpi_data_register(data, 42, 0);
  559. /* Compute some value */
  560. starpu_mpi_task_insert(MPI_COMM_WORLD, &cl, STARPU_W, data, 0); /* Node 0 computes it */
  561. /* Get it on all nodes */
  562. starpu_mpi_get_data_on_all_nodes_detached(MPI_COMM_WORLD, data);
  563. /* And turn it per-node */
  564. starpu_mpi_data_set_rank(data, STARPU_MPI_PER_NODE);
  565. \endcode
  566. The data can then be used just like pernode above.
  567. \section MPIPriorities Priorities
  568. All send functions have a <c>_prio</c> variant which takes an additional
  569. priority parameter, which allows to make StarPU-MPI change the order of MPI
  570. requests before submitting them to MPI. The default priority is \c 0.
  571. When using the starpu_mpi_task_insert() helper, ::STARPU_PRIORITY defines both the
  572. task priority and the MPI requests priority.
  573. To test how much MPI priorities have a good effect on performance, you can
  574. set the environment variable \ref STARPU_MPI_PRIORITIES to \c 0 to disable the use of
  575. priorities in StarPU-MPI.
  576. \section MPICache MPI Cache Support
  577. StarPU-MPI automatically optimizes duplicate data transmissions: if an MPI
  578. node \c B needs a piece of data \c D from MPI node \c A for several tasks, only one
  579. transmission of \c D will take place from \c A to \c B, and the value of \c D will be kept
  580. on \c B as long as no task modifies \c D.
  581. If a task modifies \c D, \c B will wait for all tasks which need the previous value of
  582. \c D, before invalidating the value of \c D. As a consequence, it releases the memory
  583. occupied by \c D. Whenever a task running on \c B needs the new value of \c D, allocation
  584. will take place again to receive it.
  585. Since tasks can be submitted dynamically, StarPU-MPI can not know whether the
  586. current value of data \c D will again be used by a newly-submitted task before
  587. being modified by another newly-submitted task, so until a task is submitted to
  588. modify the current value, it can not decide by itself whether to flush the cache
  589. or not. The application can however explicitly tell StarPU-MPI to flush the
  590. cache by calling starpu_mpi_cache_flush() or starpu_mpi_cache_flush_all_data(),
  591. for instance in case the data will not be used at all any more (see for instance
  592. the cholesky example in <c>mpi/examples/matrix_decomposition</c>), or at least not in
  593. the close future. If a newly-submitted task actually needs the value again,
  594. another transmission of \c D will be initiated from \c A to \c B. A mere
  595. starpu_mpi_cache_flush_all_data() can for instance be added at the end of the whole
  596. algorithm, to express that no data will be reused after this (or at least that
  597. it is not interesting to keep them in cache). It may however be interesting to
  598. add fine-graph starpu_mpi_cache_flush() calls during the algorithm; the effect
  599. for the data deallocation will be the same, but it will additionally release some
  600. pressure from the StarPU-MPI cache hash table during task submission.
  601. One can determine whether a piece of is cached with starpu_mpi_cached_receive()
  602. and starpu_mpi_cached_send().
  603. The whole caching behavior can be disabled thanks to the \ref STARPU_MPI_CACHE
  604. environment variable. The variable \ref STARPU_MPI_CACHE_STATS can be set to <c>1</c>
  605. to enable the runtime to display messages when data are added or removed
  606. from the cache holding the received data.
  607. \section MPIMigration MPI Data Migration
  608. The application can dynamically change its mind about the data distribution, to
  609. balance the load over MPI nodes for instance. This can be done very simply by
  610. requesting an explicit move and then change the registered rank. For instance,
  611. we here switch to a new distribution function <c>my_distrib2</c>: we first
  612. register any data which wasn't registered already and will be needed, then
  613. migrate the data, and register the new location.
  614. \code{.c}
  615. for(x = 0; x < X; x++)
  616. {
  617. for (y = 0; y < Y; y++)
  618. {
  619. int mpi_rank = my_distrib2(x, y, size);
  620. if (!data_handles[x][y] && (mpi_rank == my_rank
  621. || my_rank == my_distrib(x+1, y, size) || my_rank == my_distrib(x-1, y, size)
  622. || my_rank == my_distrib(x, y+1, size) || my_rank == my_distrib(x, y-1, size)))
  623. /* Register newly-needed data */
  624. starpu_variable_data_register(&data_handles[x][y], -1, (uintptr_t)NULL, sizeof(unsigned));
  625. if (data_handles[x][y])
  626. {
  627. /* Migrate the data */
  628. starpu_mpi_data_migrate(MPI_COMM_WORLD, data_handles[x][y], mpi_rank);
  629. }
  630. }
  631. }
  632. \endcode
  633. From then on, further tasks submissions will use the new data distribution,
  634. which will thus change both MPI communications and task assignments.
  635. Very importantly, since all nodes have to agree on which node owns which data
  636. so as to determine MPI communications and task assignments the same way, all
  637. nodes have to perform the same data migration, and at the same point among task
  638. submissions. It thus does not require a strict synchronization, just a clear
  639. separation of task submissions before and after the data redistribution.
  640. Before data unregistration, it has to be migrated back to its original home
  641. node (the value, at least), since that is where the user-provided buffer
  642. resides. Otherwise the unregistration will complain that it does not have the
  643. latest value on the original home node.
  644. \code{.c}
  645. for(x = 0; x < X; x++)
  646. {
  647. for (y = 0; y < Y; y++)
  648. {
  649. if (data_handles[x][y])
  650. {
  651. int mpi_rank = my_distrib(x, y, size);
  652. /* Get back data to original place where the user-provided buffer is. */
  653. starpu_mpi_get_data_on_node_detached(MPI_COMM_WORLD, data_handles[x][y], mpi_rank, NULL, NULL);
  654. /* And unregister it */
  655. starpu_data_unregister(data_handles[x][y]);
  656. }
  657. }
  658. }
  659. \endcode
  660. \section MPICollective MPI Collective Operations
  661. The functions are described in \ref MPICollectiveOperations.
  662. \code{.c}
  663. if (rank == root)
  664. {
  665. /* Allocate the vector */
  666. vector = malloc(nblocks * sizeof(float *));
  667. for(x=0 ; x<nblocks ; x++)
  668. {
  669. starpu_malloc((void **)&vector[x], block_size*sizeof(float));
  670. }
  671. }
  672. /* Allocate data handles and register data to StarPU */
  673. data_handles = malloc(nblocks*sizeof(starpu_data_handle_t *));
  674. for(x = 0; x < nblocks ; x++)
  675. {
  676. int mpi_rank = my_distrib(x, nodes);
  677. if (rank == root)
  678. {
  679. starpu_vector_data_register(&data_handles[x], STARPU_MAIN_RAM, (uintptr_t)vector[x], blocks_size, sizeof(float));
  680. }
  681. else if ((mpi_rank == rank) || ((rank == mpi_rank+1 || rank == mpi_rank-1)))
  682. {
  683. /* I own this index, or i will need it for my computations */
  684. starpu_vector_data_register(&data_handles[x], -1, (uintptr_t)NULL, block_size, sizeof(float));
  685. }
  686. else
  687. {
  688. /* I know it's useless to allocate anything for this */
  689. data_handles[x] = NULL;
  690. }
  691. if (data_handles[x])
  692. {
  693. starpu_mpi_data_register(data_handles[x], x*nblocks+y, mpi_rank);
  694. }
  695. }
  696. /* Scatter the matrix among the nodes */
  697. starpu_mpi_scatter_detached(data_handles, nblocks, root, MPI_COMM_WORLD, NULL, NULL, NULL, NULL);
  698. /* Calculation */
  699. for(x = 0; x < nblocks ; x++)
  700. {
  701. if (data_handles[x])
  702. {
  703. int owner = starpu_data_get_rank(data_handles[x]);
  704. if (owner == rank)
  705. {
  706. starpu_task_insert(&cl, STARPU_RW, data_handles[x], 0);
  707. }
  708. }
  709. }
  710. /* Gather the matrix on main node */
  711. starpu_mpi_gather_detached(data_handles, nblocks, 0, MPI_COMM_WORLD, NULL, NULL, NULL, NULL);
  712. \endcode
  713. Other collective operations would be easy to define, just ask starpu-devel for
  714. them!
  715. \section MPIDriver Make StarPU-MPI Progression Thread Execute Tasks
  716. The default behaviour of StarPU-MPI is to spawn an MPI thread to take care only
  717. of MPI communications in an active fashion (i.e the StarPU-MPI thread sleeps
  718. only when there is no active request submitted by the application), with the
  719. goal of being as reactive as possible to communications. Knowing that, users
  720. usually leave one free core for the MPI thread when starting a distributed
  721. execution with StarPU-MPI. However, this could result in a loss of performance
  722. for applications that does not require an extreme reactivity to MPI
  723. communications.
  724. The starpu_mpi_init_conf() routine allows the user to give the
  725. starpu_conf configuration structure of StarPU (usually given to the
  726. starpu_init() routine) to StarPU-MPI, so that StarPU-MPI reserves for its own
  727. use one of the CPU drivers of the current computing node, or one of the CPU
  728. cores, and then calls starpu_init() internally.
  729. This allows the MPI communication thread to call a StarPU CPU driver to run
  730. tasks when there is no active requests to take care of, and thus recover the
  731. computational power of the "lost" core. Since there is a trade-off between
  732. executing tasks and polling MPI requests, which is how much the application
  733. wants to lose in reactivity to MPI communications to get back the computing
  734. power of the core dedicated to the StarPU-MPI thread, there are two environment
  735. variables to pilot the behaviour of the MPI thread so that users can tune
  736. this trade-off depending of the behaviour of the application.
  737. The \ref STARPU_MPI_DRIVER_CALL_FREQUENCY environment variable sets how many times
  738. the MPI progression thread goes through the MPI_Test() loop on each active communication request
  739. (and thus try to make communications progress by going into the MPI layer)
  740. before executing tasks. The default value for this environment variable is 0,
  741. which means that the support for interleaving task execution and communication
  742. polling is deactivated, thus returning the MPI progression thread to its
  743. original behaviour.
  744. The \ref STARPU_MPI_DRIVER_TASK_FREQUENCY environment variable sets how many tasks
  745. are executed by the MPI communication thread before checking all active
  746. requests again. While this environment variable allows a better use of the core
  747. dedicated to StarPU-MPI for computations, it also decreases the reactivity of
  748. the MPI communication thread as much.
  749. \section MPIDebug Debugging MPI
  750. Communication trace will be enabled when the environment variable
  751. \ref STARPU_MPI_COMM is set to \c 1, and StarPU has been configured with the
  752. option \ref enable-verbose "--enable-verbose".
  753. Statistics will be enabled for the communication cache when the
  754. environment variable \ref STARPU_MPI_CACHE_STATS is set to \c 1. It
  755. prints messages on the standard output when data are added or removed
  756. from the received communication cache.
  757. When the environment variable \ref STARPU_COMM_STATS is set to \c 1,
  758. StarPU will display at the end of the execution for each node the
  759. volume and the bandwidth of data sent to all the other nodes.
  760. Here an example of such a trace.
  761. \verbatim
  762. [starpu_comm_stats][3] TOTAL: 476.000000 B 0.000454 MB 0.000098 B/s 0.000000 MB/s
  763. [starpu_comm_stats][3:0] 248.000000 B 0.000237 MB 0.000051 B/s 0.000000 MB/s
  764. [starpu_comm_stats][3:2] 50.000000 B 0.000217 MB 0.000047 B/s 0.000000 MB/s
  765. [starpu_comm_stats][2] TOTAL: 288.000000 B 0.000275 MB 0.000059 B/s 0.000000 MB/s
  766. [starpu_comm_stats][2:1] 70.000000 B 0.000103 MB 0.000022 B/s 0.000000 MB/s
  767. [starpu_comm_stats][2:3] 288.000000 B 0.000172 MB 0.000037 B/s 0.000000 MB/s
  768. [starpu_comm_stats][1] TOTAL: 188.000000 B 0.000179 MB 0.000038 B/s 0.000000 MB/s
  769. [starpu_comm_stats][1:0] 80.000000 B 0.000114 MB 0.000025 B/s 0.000000 MB/s
  770. [starpu_comm_stats][1:2] 188.000000 B 0.000065 MB 0.000014 B/s 0.000000 MB/s
  771. [starpu_comm_stats][0] TOTAL: 376.000000 B 0.000359 MB 0.000077 B/s 0.000000 MB/s
  772. [starpu_comm_stats][0:1] 376.000000 B 0.000141 MB 0.000030 B/s 0.000000 MB/s
  773. [starpu_comm_stats][0:3] 10.000000 B 0.000217 MB 0.000047 B/s 0.000000 MB/s
  774. \endverbatim
  775. These statistics can be plotted as heatmaps using StarPU tool <c>starpu_mpi_comm_matrix.py</c>, this will produce 2 PDF files, one plot for the bandwidth, and one plot for the data volume.
  776. \image latex trace_bw_heatmap.pdf "Bandwidth Heatmap" width=0.5\textwidth
  777. \image html trace_bw_heatmap.png "Bandwidth Heatmap"
  778. \image latex trace_volume_heatmap.pdf "Data Volume Heatmap" width=0.5\textwidth
  779. \image html trace_volume_heatmap.png "Data Bandwidth Heatmap"
  780. \section MPIExamples More MPI examples
  781. MPI examples are available in the StarPU source code in mpi/examples:
  782. <ul>
  783. <li>
  784. <c>comm</c> shows how to use communicators with StarPU-MPI
  785. </li>
  786. <li>
  787. <c>complex</c> is a simple example using a user-define data interface over
  788. MPI (complex numbers),
  789. </li>
  790. <li>
  791. <c>stencil5</c> is a simple stencil example using starpu_mpi_task_insert(),
  792. </li>
  793. <li>
  794. <c>matrix_decomposition</c> is a cholesky decomposition example using
  795. starpu_mpi_task_insert(). The non-distributed version can check for
  796. <algorithm correctness in 1-node configuration, the distributed version uses
  797. exactly the same source code, to be used over MPI,
  798. </li>
  799. <li>
  800. <c>mpi_lu</c> is an LU decomposition example, provided in three versions:
  801. <c>plu_example</c> uses explicit MPI data transfers, <c>plu_implicit_example</c>
  802. uses implicit MPI data transfers, <c>plu_outofcore_example</c> uses implicit MPI
  803. data transfers and supports data matrices which do not fit in memory (out-of-core).
  804. </li>
  805. </ul>
  806. \section MPIImplementation Notes about the Implementation
  807. StarPU-MPI is implemented directly on top of MPI.
  808. Since the release 1.3.0, an implementation on top of NewMadeleine, an
  809. optimizing communication library for high-performance networks, is
  810. also provided. To use it, one needs to install NewMadeleine (see
  811. http://pm2.gforge.inria.fr/newmadeleine/) and enable the \c configure
  812. option \ref enable-nmad "--enable-nmad".
  813. Both implementations provide the same public API.
  814. \section MPIMasterSlave MPI Master Slave Support
  815. StarPU provides an other way to execute applications across many
  816. nodes. The Master Slave support permits to use remote cores without
  817. thinking about data distribution. This support can be activated with
  818. the \c configure option \ref enable-mpi-master-slave
  819. "--enable-mpi-master-slave". However, you should not activate both MPI
  820. support and MPI Master-Slave support.
  821. The existing kernels for CPU devices can be used as such. They only have to be
  822. exposed through the name of the function in the \ref starpu_codelet::cpu_funcs_name field.
  823. Functions have to be globally-visible (i.e. not static) for StarPU to
  824. be able to look them up, and <c>-rdynamic</c> must be passed to gcc (or
  825. <c>-export-dynamic</c> to ld) so that symbols of the main program are visible.
  826. Optionally, you can choose the use of another function on slaves thanks to
  827. the field \ref starpu_codelet::mpi_ms_funcs.
  828. By default, one core is dedicated on the master node to manage the
  829. entire set of slaves. If the implementation of MPI you are using has a
  830. good multiple threads support, you can use the \c configure option
  831. \ref with-mpi-master-slave-multiple-thread "--with-mpi-master-slave-multiple-thread"
  832. to dedicate one core per slave.
  833. Choosing the number of cores on each slave device is done by setting
  834. the environment variable \ref STARPU_NMPIMSTHREADS "STARPU_NMPIMSTHREADS=\<number\>"
  835. with <c>\<number\></c> being the requested number of cores. By default
  836. all the slave's cores are used.
  837. Setting the number of slaves nodes is done by changing the <c>-n</c>
  838. parameter when executing the application with mpirun or mpiexec.
  839. The master node is by default the node with the MPI rank equal to 0.
  840. To select another node, use the environment variable \ref
  841. STARPU_MPI_MASTER_NODE "STARPU_MPI_MASTER_NODE=\<number\>" with
  842. <c>\<number\></c> being the requested MPI rank node.
  843. */