470_simgrid.doxy 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011,2012,2014,2016,2017 Inria
  4. * Copyright (C) 2010-2019 CNRS
  5. * Copyright (C) 2009-2011,2014-2020 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. /*
  19. * NOTE: XXX: also update simgrid versions in 101_building.doxy !!
  20. */
  21. /*! \page SimGridSupport SimGrid Support
  22. StarPU can use Simgrid in order to simulate execution on an arbitrary
  23. platform. This was tested with SimGrid from 3.11 to 3.16, and 3.18 to
  24. 3.25. SimGrid versions 3.25 and above need to be configured with -Denable_msg=ON .
  25. Other versions may have compatibility issues. 3.17 notably does not build at
  26. all. MPI simulation does not work with version 3.22.
  27. \section Preparing Preparing Your Application For Simulation
  28. There are a few technical details which need to be handled for an application to
  29. be simulated through SimGrid.
  30. If the application uses <c>gettimeofday</c> to make its
  31. performance measurements, the real time will be used, which will be bogus. To
  32. get the simulated time, it has to use starpu_timing_now() which returns the
  33. virtual timestamp in us.
  34. For some technical reason, the application's .c file which contains \c main() has
  35. to be recompiled with \c starpu_simgrid_wrap.h, which in the SimGrid case will <c># define main()</c>
  36. into <c>starpu_main()</c>, and it is \c libstarpu which will provide the real \c main() and
  37. will call the application's \c main().
  38. To be able to test with crazy data sizes, one may want to only allocate
  39. application data if the macro \c STARPU_SIMGRID is not defined. Passing a <c>NULL</c> pointer to
  40. \c starpu_data_register functions is fine, data will never be read/written to by
  41. StarPU in SimGrid mode anyway.
  42. To be able to run the application with e.g. CUDA simulation on a system which
  43. does not have CUDA installed, one can fill the starpu_codelet::cuda_funcs with \c (void*)1, to
  44. express that there is a CUDA implementation, even if one does not actually
  45. provide it. StarPU will not actually run it in SimGrid mode anyway by default
  46. (unless the ::STARPU_CODELET_SIMGRID_EXECUTE or ::STARPU_CODELET_SIMGRID_EXECUTE_AND_INJECT
  47. flags are set in the codelet)
  48. \snippet simgrid.c To be included. You should update doxygen if you see this text.
  49. \section Calibration Calibration
  50. The idea is to first compile StarPU normally, and run the application,
  51. so as to automatically benchmark the bus and the codelets.
  52. \verbatim
  53. $ ./configure && make
  54. $ STARPU_SCHED=dmda ./examples/matvecmult/matvecmult
  55. [starpu][_starpu_load_history_based_model] Warning: model matvecmult
  56. is not calibrated, forcing calibration for this run. Use the
  57. STARPU_CALIBRATE environment variable to control this.
  58. $ ...
  59. $ STARPU_SCHED=dmda ./examples/matvecmult/matvecmult
  60. TEST PASSED
  61. \endverbatim
  62. Note that we force to use the scheduler <c>dmda</c> to generate
  63. performance models for the application. The application may need to be
  64. run several times before the model is calibrated.
  65. \section Simulation Simulation
  66. Then, recompile StarPU, passing \ref enable-simgrid "--enable-simgrid"
  67. to <c>configure</c>. Make sure to keep all other <c>configure</c> options
  68. the same, and notably options such as <c>--enable-maxcudadev</c>.
  69. \verbatim
  70. $ ./configure --enable-simgrid
  71. \endverbatim
  72. To specify the location of SimGrid, you can either set the environment
  73. variables \c SIMGRID_CFLAGS and \c SIMGRID_LIBS, or use the \c configure
  74. options \ref with-simgrid-dir "--with-simgrid-dir",
  75. \ref with-simgrid-include-dir "--with-simgrid-include-dir" and
  76. \ref with-simgrid-lib-dir "--with-simgrid-lib-dir", for example
  77. \verbatim
  78. $ ./configure --with-simgrid-dir=/opt/local/simgrid
  79. \endverbatim
  80. You can then re-run the application.
  81. \verbatim
  82. $ make
  83. $ STARPU_SCHED=dmda ./examples/matvecmult/matvecmult
  84. TEST FAILED !!!
  85. \endverbatim
  86. It is normal that the test fails: since the computation are not actually done
  87. (that is the whole point of SimGrid), the result is wrong, of course.
  88. If the performance model is not calibrated enough, the following error
  89. message will be displayed
  90. \verbatim
  91. $ STARPU_SCHED=dmda ./examples/matvecmult/matvecmult
  92. [starpu][_starpu_load_history_based_model] Warning: model matvecmult
  93. is not calibrated, forcing calibration for this run. Use the
  94. STARPU_CALIBRATE environment variable to control this.
  95. [starpu][_starpu_simgrid_execute_job][assert failure] Codelet
  96. matvecmult does not have a perfmodel, or is not calibrated enough
  97. \endverbatim
  98. The number of devices can be chosen as usual with \ref STARPU_NCPU,
  99. \ref STARPU_NCUDA, and \ref STARPU_NOPENCL, and the amount of GPU memory
  100. with \ref STARPU_LIMIT_CUDA_MEM, \ref STARPU_LIMIT_CUDA_devid_MEM,
  101. \ref STARPU_LIMIT_OPENCL_MEM, and \ref STARPU_LIMIT_OPENCL_devid_MEM.
  102. \section SimulationOnAnotherMachine Simulation On Another Machine
  103. The SimGrid support even permits to perform simulations on another machine, your
  104. desktop, typically. To achieve this, one still needs to perform the Calibration
  105. step on the actual machine to be simulated, then copy them to your desktop
  106. machine (the <c>$STARPU_HOME/.starpu</c> directory). One can then perform the
  107. Simulation step on the desktop machine, by setting the environment
  108. variable \ref STARPU_HOSTNAME to the name of the actual machine, to
  109. make StarPU use the performance models of the simulated machine even
  110. on the desktop machine.
  111. If the desktop machine does not have CUDA or OpenCL, StarPU is still able to
  112. use SimGrid to simulate execution with CUDA/OpenCL devices, but the application
  113. source code will probably disable the CUDA and OpenCL codelets in that
  114. case. Since during SimGrid execution, the functions of the codelet are actually
  115. not called by default, one can use dummy functions such as the following to
  116. still permit CUDA or OpenCL execution.
  117. \section SimulationExamples Simulation Examples
  118. StarPU ships a few performance models for a couple of systems: \c attila,
  119. \c mirage, \c idgraf, and \c sirocco. See Section \ref SimulatedBenchmarks for the details.
  120. \section FakeSimulations Simulations On Fake Machines
  121. It is possible to build fake machines which do not exist, by modifying the
  122. platform file in <c>$STARPU_HOME/.starpu/sampling/bus/machine.platform.xml</c>
  123. by hand: one can add more CPUs, add GPUs (but the performance model file has to
  124. be extended as well), change the available GPU memory size, PCI memory bandwidth, etc.
  125. \section TweakingSimulation Tweaking Simulation
  126. The simulation can be tweaked, to be able to tune it between a very accurate
  127. simulation and a very simple simulation (which is thus close to scheduling
  128. theory results), see the \ref STARPU_SIMGRID_TRANSFER_COST, \ref STARPU_SIMGRID_CUDA_MALLOC_COST,
  129. \ref STARPU_SIMGRID_CUDA_QUEUE_COST, \ref STARPU_SIMGRID_TASK_SUBMIT_COST,
  130. \ref STARPU_SIMGRID_FETCHING_INPUT_COST and \ref STARPU_SIMGRID_SCHED_COST environment variables.
  131. \section SimulationMPIApplications MPI Applications
  132. StarPU-MPI applications can also be run in SimGrid mode. It needs to be compiled
  133. with \c smpicc, and run using the <c>starpu_smpirun</c> script, for instance:
  134. \verbatim
  135. $ STARPU_SCHED=dmda starpu_smpirun -platform cluster.xml -hostfile hostfile ./mpi/tests/pingpong
  136. \endverbatim
  137. Where \c cluster.xml is a SimGrid-MPI platform description, and \c hostfile the
  138. list of MPI nodes to be used. StarPU currently only supports homogeneous MPI
  139. clusters: for each MPI node it will just replicate the architecture referred by
  140. \ref STARPU_HOSTNAME.
  141. \section SimulationDebuggingApplications Debugging Applications
  142. By default, SimGrid uses its own implementation of threads, which prevents \c gdb
  143. from being able to inspect stacks of all threads. To be able to fully debug an
  144. application running with SimGrid, pass the <c>--cfg=contexts/factory:thread</c>
  145. option to the application, to make SimGrid use system threads, which \c gdb will be
  146. able to manipulate as usual.
  147. It is also worth noting SimGrid 3.21's new parameter
  148. <c>--cfg=simix/breakpoint</c> which allows to put a breakpoint at a precise
  149. (deterministic!) timing of the execution. If for instance in an execution
  150. trace we see that something odd is happening at time 19000ms, we can use
  151. <c>--cfg=simix/breakpoint:19.000</c> and \c SIGTRAP will be raised at that point,
  152. which will thus interrupt execution within \c gdb, allowing to inspect e.g.
  153. scheduler state, etc.
  154. \section SimulationMemoryUsage Memory Usage
  155. Since kernels are not actually run and data transfers are not actually
  156. performed, the data memory does not actually need to be allocated. This allows
  157. for instance to simulate the execution of applications processing very big data
  158. on a small laptop.
  159. The application can for instance pass <c>1</c> (or whatever bogus pointer)
  160. to starpu data registration functions, instead of allocating data. This will
  161. however require the application to take care of not trying to access the data,
  162. and will not work in MPI mode, which performs transfers.
  163. Another way is to pass the \ref STARPU_MALLOC_SIMULATION_FOLDED flag to the
  164. starpu_malloc_flags() function. This will make it allocate a memory area which
  165. one can read/write, but optimized so that this does not actually consume
  166. memory. Of course, the values read from such area will be bogus, but this allows
  167. the application to keep e.g. data load, store, initialization as it is, and also
  168. work in MPI mode.
  169. Note however that notably Linux kernels refuse obvious memory overcommitting by
  170. default, so a single allocation can typically not be bigger than the amount of
  171. physical memory, see https://www.kernel.org/doc/Documentation/vm/overcommit-accounting
  172. This prevents for instance from allocating a single huge matrix. Allocating a
  173. huge matrix in several tiles is not a problem, however. <c>sysctl
  174. vm.overcommit_memory=1</c> can also be used to allow such overcommit.
  175. Note however that this folding is done by remapping the same file several times,
  176. and Linux kernels will also refuse to create too many memory areas. <c>sysctl
  177. vm.max_map_count</c> can be used to check and change the default (65535). By
  178. default, StarPU uses a 1MiB file, so it hopefully fits in the CPU cache. This
  179. however limits the amount of such folded memory to a bit below 64GiB. The
  180. \ref STARPU_MALLOC_SIMULATION_FOLD environment variable can be used to increase the
  181. size of the file.
  182. */