21simgrid.doxy 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 CNRS
  5. * Copyright (C) 2011, 2012 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.
  11. \section Preparing Preparing your application for simulation.
  12. There are a few technical details which need to be handled for an application to
  13. be simulated through Simgrid.
  14. If the application uses <c>gettimeofday</c> to make its
  15. performance measurements, the real time will be used, which will be bogus. To
  16. get the simulated time, it has to use starpu_timing_now() which returns the
  17. virtual timestamp in us.
  18. For some technical reason, the application's .c file which contains main() has
  19. to be recompiled with starpu_simgrid_wrap.h, which in the simgrid case will # define main()
  20. into starpu_main(), and it is libstarpu which will provide the real main() and
  21. will call the application's main().
  22. To be able to test with crazy data sizes, one may want to only allocate
  23. application data if STARPU_SIMGRID is not defined. Passing a NULL pointer to
  24. starpu_data_register functions is fine, data will never be read/written to by
  25. StarPU in Simgrid mode anyway.
  26. To be able to run the application with e.g. CUDA simulation on a system which
  27. does not have CUDA installed, one can fill the cuda_funcs with (void*)1, to
  28. express that there is a CUDA implementation, even if one does not actually
  29. provide it. StarPU will never actually run it in Simgrid mode anyway.
  30. \section Calibration Calibration
  31. The idea is to first compile StarPU normally, and run the application,
  32. so as to automatically benchmark the bus and the codelets.
  33. \verbatim
  34. $ ./configure && make
  35. $ STARPU_SCHED=dmda ./examples/matvecmult/matvecmult
  36. [starpu][_starpu_load_history_based_model] Warning: model matvecmult
  37. is not calibrated, forcing calibration for this run. Use the
  38. STARPU_CALIBRATE environment variable to control this.
  39. $ ...
  40. $ STARPU_SCHED=dmda ./examples/matvecmult/matvecmult
  41. TEST PASSED
  42. \endverbatim
  43. Note that we force to use the scheduler <c>dmda</c> to generate
  44. performance models for the application. The application may need to be
  45. run several times before the model is calibrated.
  46. \section Simulation Simulation
  47. Then, recompile StarPU, passing \ref enable-simgrid "--enable-simgrid"
  48. to <c>./configure</c>.
  49. \verbatim
  50. $ ./configure --enable-simgrid
  51. \endverbatim
  52. To specify the location of SimGrid, you can either set the environment
  53. variables SIMGRID_CFLAGS and SIMGRID_LIBS, or use the configure
  54. options \ref with-simgrid-dir "--with-simgrid-dir",
  55. \ref with-simgrid-include-dir "--with-simgrid-include-dir" and
  56. \ref with-simgrid-lib-dir "--with-simgrid-lib-dir", for example
  57. \verbatim
  58. $ ./configure --with-simgrid-dir=/opt/local/simgrid
  59. \endverbatim
  60. You can then re-run the application.
  61. \verbatim
  62. $ make
  63. $ STARPU_SCHED=dmda ./examples/matvecmult/matvecmult
  64. TEST FAILED !!!
  65. \endverbatim
  66. It is normal that the test fails: since the computation are not actually done
  67. (that is the whole point of simgrid), the result is wrong, of course.
  68. If the performance model is not calibrated enough, the following error
  69. message will be displayed
  70. \verbatim
  71. $ STARPU_SCHED=dmda ./examples/matvecmult/matvecmult
  72. [starpu][_starpu_load_history_based_model] Warning: model matvecmult
  73. is not calibrated, forcing calibration for this run. Use the
  74. STARPU_CALIBRATE environment variable to control this.
  75. [starpu][_starpu_simgrid_execute_job][assert failure] Codelet
  76. matvecmult does not have a perfmodel, or is not calibrated enough
  77. \endverbatim
  78. The number of devices can be chosen as usual with \ref STARPU_NCPU, \ref
  79. STARPU_NCUDA, and \ref STARPU_NOPENCL, and the amount of GPU memory
  80. with \ref STARPU_LIMIT_CUDA_MEM, \ref STARPU_LIMIT_CUDA_devid_MEM, \ref
  81. STARPU_LIMIT_OPENCL_MEM, and \ref STARPU_LIMIT_OPENCL_devid_MEM.
  82. \section SimulationOnAnotherMachine Simulation On Another Machine
  83. The simgrid support even permits to perform simulations on another machine, your
  84. desktop, typically. To achieve this, one still needs to perform the Calibration
  85. step on the actual machine to be simulated, then copy them to your desktop
  86. machine (the <c>$STARPU_HOME/.starpu</c> directory). One can then perform the
  87. Simulation step on the desktop machine, by setting the environment
  88. variable \ref STARPU_HOSTNAME to the name of the actual machine, to
  89. make StarPU use the performance models of the simulated machine even
  90. on the desktop machine.
  91. If the desktop machine does not have CUDA or OpenCL, StarPU is still able to
  92. use simgrid to simulate execution with CUDA/OpenCL devices, but the application
  93. source code will probably disable the CUDA and OpenCL codelets in thatcd sc
  94. case. Since during simgrid execution, the functions of the codelet are actually
  95. not called, one can use dummy functions such as the following to still permit
  96. CUDA or OpenCL execution:
  97. \section SimulationExamples Simulation examples
  98. StarPU ships a few performance models for a couple of systems: attila and
  99. mirage. See section \ref SimulatedBenchmarks for the details.
  100. \section Tweaking simulation
  101. The simulation can be tweaked, to be able to tune it between a very accurate
  102. simulation and a very simple simulation (which is thus close to scheduling
  103. theory results), see the \ref STARPU_SIMGRID_CUDA_MALLOC_COST and \ref
  104. STARPU_SIMGRID_CUDA_QUEUE_COST environment variables.
  105. \section MPI applications
  106. StarPU-MPI applications can also be run in simgrid mode. It needs to be compiled
  107. with smpicc, and run using the starpu_smpirun script, for instance:
  108. \verbatim
  109. $ STARPU_SCHED=dmda starpu_smpirun -platform cluster.xml -hostfile hostfile ./mpi/tests/pingpong
  110. \endverbatim
  111. Where cluster.xml is a Simgrid-MPI platform description, and hostfile the
  112. list of MPI nodes to be used. StarPU currently only supports homogeneous MPI
  113. clusters: for each MPI node it will just replicate the architecture referred by
  114. \ref STARPU_HOSTNAME.
  115. \section Debugging applications
  116. By default, simgrid uses its own implementation of threads, which prevents gdb
  117. from being able to inspect stacks of all threads. To be able to fully debug an
  118. application running with simgrid, pass the <c>--cfg=contexts/factory:thread</c>
  119. option to the application, to make simgrid use system threads, which gdb will be
  120. able to manipulate as usual.
  121. \snippet simgrid.c To be included. You should update doxygen if you see this text.
  122. */