05check_list_performance.doxy 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * This file is part of the StarPU Handbook.
  3. * Copyright (C) 2009--2011 Universit@'e de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012, 2013, 2014 Centre National de la Recherche Scientifique
  5. * Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
  6. * See the file version.doxy for copying conditions.
  7. */
  8. /*! \page CheckListWhenPerformanceAreNotThere Check List When Performance Are Not There
  9. TODO: improve!
  10. Simply encapsulating application kernels into tasks already permits to
  11. seamlessly support CPU and GPUs at the same time. To achieve good
  12. performance, we give below a list of features which should be checked.
  13. \section DataRelatedFeaturesToImprovePerformance Data Related Features That May Improve Performance
  14. link to \ref DataManagement
  15. link to \ref DataPrefetch
  16. \section TaskRelatedFeaturesToImprovePerformance Task Related Features That May Improve Performance
  17. link to \ref TaskGranularity
  18. link to \ref TaskSubmission
  19. link to \ref TaskPriorities
  20. \section SchedulingRelatedFeaturesToImprovePerformance Scheduling Related Features That May Improve Performance
  21. link to \ref TaskSchedulingPolicy
  22. link to \ref TaskDistributionVsDataTransfer
  23. link to \ref Power-basedScheduling
  24. link to \ref StaticScheduling
  25. \section CUDA-specificOptimizations CUDA-specific Optimizations
  26. Due to CUDA limitations, StarPU will have a hard time overlapping its own
  27. communications and the codelet computations if the application does not use a
  28. dedicated CUDA stream for its computations instead of the default stream,
  29. which synchronizes all operations of the GPU. StarPU provides one by the use
  30. of starpu_cuda_get_local_stream() which can be used by all CUDA codelet
  31. operations to avoid this issue. For instance:
  32. \code{.c}
  33. func <<<grid,block,0,starpu_cuda_get_local_stream()>>> (foo, bar);
  34. cudaStreamSynchronize(starpu_cuda_get_local_stream());
  35. \endcode
  36. StarPU already does appropriate calls for the CUBLAS library.
  37. Unfortunately, some CUDA libraries do not have stream variants of
  38. kernels. That will lower the potential for overlapping.
  39. \section DetectionStuckConditions Detection Stuck Conditions
  40. It may happen that for some reason, StarPU does not make progress for a long
  41. period of time. Reason are sometimes due to contention inside StarPU, but
  42. sometimes this is due to external reasons, such as stuck MPI driver, or CUDA
  43. driver, etc.
  44. <c>export STARPU_WATCHDOG_TIMEOUT=10000</c>
  45. allows to make StarPU print an error message whenever StarPU does not terminate
  46. any task for 10ms. In addition to that,
  47. <c>export STARPU_WATCHDOG_CRASH=1</c>
  48. triggers a crash in that condition, thus allowing to catch the situation in gdb
  49. etc.
  50. \section HowToLimitMemoryPerNode How to limit memory per node
  51. TODO
  52. Talk about
  53. \ref STARPU_LIMIT_CUDA_devid_MEM, \ref STARPU_LIMIT_CUDA_MEM,
  54. \ref STARPU_LIMIT_OPENCL_devid_MEM, \ref STARPU_LIMIT_OPENCL_MEM
  55. and \ref STARPU_LIMIT_CPU_MEM
  56. starpu_memory_get_available()
  57. \section PerformanceModelCalibration Performance Model Calibration
  58. Most schedulers are based on an estimation of codelet duration on each kind
  59. of processing unit. For this to be possible, the application programmer needs
  60. to configure a performance model for the codelets of the application (see
  61. \ref PerformanceModelExample for instance). History-based performance models
  62. use on-line calibration. StarPU will automatically calibrate codelets
  63. which have never been calibrated yet, and save the result in
  64. <c>$STARPU_HOME/.starpu/sampling/codelets</c>.
  65. The models are indexed by machine name. To share the models between
  66. machines (e.g. for a homogeneous cluster), use <c>export
  67. STARPU_HOSTNAME=some_global_name</c>. To force continuing calibration,
  68. use <c>export STARPU_CALIBRATE=1</c> . This may be necessary if your application
  69. has not-so-stable performance. StarPU will force calibration (and thus ignore
  70. the current result) until 10 (<c>_STARPU_CALIBRATION_MINIMUM</c>) measurements have been
  71. made on each architecture, to avoid badly scheduling tasks just because the
  72. first measurements were not so good. Details on the current performance model status
  73. can be obtained from the command <c>starpu_perfmodel_display</c>: the <c>-l</c>
  74. option lists the available performance models, and the <c>-s</c> option permits
  75. to choose the performance model to be displayed. The result looks like:
  76. \verbatim
  77. $ starpu_perfmodel_display -s starpu_slu_lu_model_11
  78. performance model for cpu_impl_0
  79. # hash size flops mean dev n
  80. 914f3bef 1048576 0.000000e+00 2.503577e+04 1.982465e+02 8
  81. 3e921964 65536 0.000000e+00 5.527003e+02 1.848114e+01 7
  82. e5a07e31 4096 0.000000e+00 1.717457e+01 5.190038e+00 14
  83. ...
  84. \endverbatim
  85. Which shows that for the LU 11 kernel with a 1MiB matrix, the average
  86. execution time on CPUs was about 25ms, with a 0.2ms standard deviation, over
  87. 8 samples. It is a good idea to check this before doing actual performance
  88. measurements.
  89. A graph can be drawn by using the tool <c>starpu_perfmodel_plot</c>:
  90. \verbatim
  91. $ starpu_perfmodel_plot -s starpu_slu_lu_model_11
  92. 4096 16384 65536 262144 1048576 4194304
  93. $ gnuplot starpu_starpu_slu_lu_model_11.gp
  94. $ gv starpu_starpu_slu_lu_model_11.eps
  95. \endverbatim
  96. \image html starpu_starpu_slu_lu_model_11.png
  97. \image latex starpu_starpu_slu_lu_model_11.eps "" width=\textwidth
  98. If a kernel source code was modified (e.g. performance improvement), the
  99. calibration information is stale and should be dropped, to re-calibrate from
  100. start. This can be done by using <c>export STARPU_CALIBRATE=2</c>.
  101. Note: due to CUDA limitations, to be able to measure kernel duration,
  102. calibration mode needs to disable asynchronous data transfers. Calibration thus
  103. disables data transfer / computation overlapping, and should thus not be used
  104. for eventual benchmarks. Note 2: history-based performance models get calibrated
  105. only if a performance-model-based scheduler is chosen.
  106. The history-based performance models can also be explicitly filled by the
  107. application without execution, if e.g. the application already has a series of
  108. measurements. This can be done by using starpu_perfmodel_update_history(),
  109. for instance:
  110. \code{.c}
  111. static struct starpu_perfmodel perf_model = {
  112. .type = STARPU_HISTORY_BASED,
  113. .symbol = "my_perfmodel",
  114. };
  115. struct starpu_codelet cl = {
  116. .where = STARPU_CUDA,
  117. .cuda_funcs = { cuda_func1, cuda_func2, NULL },
  118. .nbuffers = 1,
  119. .modes = {STARPU_W},
  120. .model = &perf_model
  121. };
  122. void feed(void) {
  123. struct my_measure *measure;
  124. struct starpu_task task;
  125. starpu_task_init(&task);
  126. task.cl = &cl;
  127. for (measure = &measures[0]; measure < measures[last]; measure++) {
  128. starpu_data_handle_t handle;
  129. starpu_vector_data_register(&handle, -1, 0, measure->size, sizeof(float));
  130. task.handles[0] = handle;
  131. starpu_perfmodel_update_history(&perf_model, &task,
  132. STARPU_CUDA_DEFAULT + measure->cudadev, 0,
  133. measure->implementation, measure->time);
  134. starpu_task_clean(&task);
  135. starpu_data_unregister(handle);
  136. }
  137. }
  138. \endcode
  139. Measurement has to be provided in milliseconds for the completion time models,
  140. and in Joules for the energy consumption models.
  141. \section Profiling Profiling
  142. A quick view of how many tasks each worker has executed can be obtained by setting
  143. <c>export STARPU_WORKER_STATS=1</c> This is a convenient way to check that
  144. execution did happen on accelerators without penalizing performance with
  145. the profiling overhead.
  146. A quick view of how much data transfers have been issued can be obtained by setting
  147. <c>export STARPU_BUS_STATS=1</c> .
  148. More detailed profiling information can be enabled by using <c>export STARPU_PROFILING=1</c> or by
  149. calling starpu_profiling_status_set() from the source code.
  150. Statistics on the execution can then be obtained by using <c>export
  151. STARPU_BUS_STATS=1</c> and <c>export STARPU_WORKER_STATS=1</c> .
  152. More details on performance feedback are provided by the next chapter.
  153. */