470_simgrid.doxy 10 KB

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