470_simgrid.doxy 10 KB

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