470_simgrid.doxy 10 KB

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