470_simgrid.doxy 9.2 KB

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