380_offline_performance_tools.doxy 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. * Copyright (C) 2020 Federal University of Rio Grande do Sul (UFRGS)
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. /*! \page OfflinePerformanceTools Offline Performance Tools
  18. To get an idea of what is happening, a lot of performance feedback is available,
  19. detailed in this chapter. The various informations should be checked for.
  20. <ul>
  21. <li>
  22. What does the Gantt diagram look like? (see \ref CreatingAGanttDiagram)
  23. <ul>
  24. <li> If it's mostly green (tasks running in the initial context) or context specific
  25. color prevailing, then the machine is properly
  26. utilized, and perhaps the codelets are just slow. Check their performance, see
  27. \ref PerformanceOfCodelets.
  28. </li>
  29. <li> If it's mostly purple (FetchingInput), tasks keep waiting for data
  30. transfers, do you perhaps have far more communication than computation? Did
  31. you properly use CUDA streams to make sure communication can be
  32. overlapped? Did you use data-locality aware schedulers to avoid transfers as
  33. much as possible?
  34. </li>
  35. <li> If it's mostly red (Blocked), tasks keep waiting for dependencies,
  36. do you have enough parallelism? It might be a good idea to check what the DAG
  37. looks like (see \ref CreatingADAGWithGraphviz).
  38. </li>
  39. <li> If only some workers are completely red (Blocked), for some reason the
  40. scheduler didn't assign tasks to them. Perhaps the performance model is bogus,
  41. check it (see \ref PerformanceOfCodelets). Do all your codelets have a
  42. performance model? When some of them don't, the schedulers switches to a
  43. greedy algorithm which thus performs badly.
  44. </li>
  45. </ul>
  46. </li>
  47. </ul>
  48. You can also use the Temanejo task debugger (see \ref UsingTheTemanejoTaskDebugger) to
  49. visualize the task graph more easily.
  50. \section Off-linePerformanceFeedback Off-line Performance Feedback
  51. \subsection GeneratingTracesWithFxT Generating Traces With FxT
  52. StarPU can use the FxT library (see
  53. https://savannah.nongnu.org/projects/fkt/) to generate traces
  54. with a limited runtime overhead.
  55. You can get a tarball from http://download.savannah.gnu.org/releases/fkt/
  56. Compiling and installing the FxT library in the <c>$FXTDIR</c> path is
  57. done following the standard procedure:
  58. \verbatim
  59. $ ./configure --prefix=$FXTDIR
  60. $ make
  61. $ make install
  62. \endverbatim
  63. In order to have StarPU to generate traces, StarPU should be configured with
  64. the option \ref with-fxt "--with-fxt" :
  65. \verbatim
  66. $ ./configure --with-fxt=$FXTDIR
  67. \endverbatim
  68. Or you can simply point the <c>PKG_CONFIG_PATH</c> to
  69. <c>$FXTDIR/lib/pkgconfig</c> and pass
  70. \ref with-fxt "--with-fxt" to <c>configure</c>
  71. When FxT is enabled, a trace is generated when StarPU is terminated by calling
  72. starpu_shutdown(). The trace is a binary file whose name has the form
  73. <c>prof_file_XXX_YYY</c> where <c>XXX</c> is the user name, and
  74. <c>YYY</c> is the pid of the process that used StarPU. This file is saved in the
  75. <c>/tmp/</c> directory by default, or by the directory specified by
  76. the environment variable \ref STARPU_FXT_PREFIX.
  77. The additional \c configure option \ref enable-fxt-lock "--enable-fxt-lock" can
  78. be used to generate trace events which describes the locks behaviour during
  79. the execution. It is however very heavy and should not be used unless debugging
  80. StarPU's internal locking.
  81. The environment variable \ref STARPU_FXT_TRACE can be set to 0 to disable the
  82. generation of the <c>prof_file_XXX_YYY</c> file.
  83. When the FxT trace file <c>prof_file_something</c> has been generated,
  84. it is possible to generate different trace formats by calling:
  85. \verbatim
  86. $ starpu_fxt_tool -i /tmp/prof_file_something
  87. \endverbatim
  88. Or alternatively, setting the environment variable \ref STARPU_GENERATE_TRACE
  89. to <c>1</c> before application execution will make StarPU do it automatically at
  90. application shutdown.
  91. One can also set the environment variable \ref
  92. STARPU_GENERATE_TRACE_OPTIONS to specify options, see
  93. <c>starpu_fxt_tool --help</c>, for example:
  94. \verbatim
  95. $ export STARPU_GENERATE_TRACE=1
  96. $ export STARPU_GENERATE_TRACE_OPTIONS="-no-acquire"
  97. \endverbatim
  98. When running a MPI application, \ref STARPU_GENERATE_TRACE will not
  99. work as expected (each node will try to generate trace files, thus
  100. mixing outputs...), you have to collect the trace files from the MPI
  101. nodes, and specify them all on the command <c>starpu_fxt_tool</c>, for
  102. instance:
  103. \verbatim
  104. $ starpu_fxt_tool -i /tmp/prof_file_something*
  105. \endverbatim
  106. By default, the generated trace contains all informations. To reduce
  107. the trace size, various <c>-no-foo</c> options can be passed to
  108. <c>starpu_fxt_tool</c>, see <c>starpu_fxt_tool --help</c> .
  109. \subsubsection CreatingAGanttDiagram Creating a Gantt Diagram
  110. One of the generated files is a trace in the Paje format. The file,
  111. located in the current directory, is named <c>paje.trace</c>. It can
  112. be viewed with ViTE (http://vite.gforge.inria.fr/) a trace
  113. visualizing open-source tool. To open the file <c>paje.trace</c> with
  114. ViTE, use the following command:
  115. \verbatim
  116. $ vite paje.trace
  117. \endverbatim
  118. Tasks can be assigned a name (instead of the default \c unknown) by
  119. filling the optional starpu_codelet::name, or assigning them a
  120. performance model. The name can also be set with the field
  121. starpu_task::name or by using \ref STARPU_NAME when calling
  122. starpu_task_insert().
  123. Tasks are assigned default colors based on the worker which executed
  124. them (green for CPUs, yellow/orange/red for CUDAs, blue for OpenCLs,
  125. red for MICs, ...). To use a different color for every type of task,
  126. one can specify the option <c>-c</c> to <c>starpu_fxt_tool</c> or in
  127. \ref STARPU_GENERATE_TRACE_OPTIONS. Tasks can also be given a specific
  128. color by setting the field starpu_codelet::color or the
  129. starpu_task::color. Colors are expressed with the following format
  130. \c 0xRRGGBB (e.g \c 0xFF0000 for red). See
  131. <c>basic_examples/task_insert_color</c> for examples on how to assign
  132. colors.
  133. To get statistics on the time spend in runtime overhead, one can use the
  134. statistics plugin of ViTE. In Preferences, select Plugins. In "States Type",
  135. select "Worker State". Then click on "Reload" to update the histogram. The red
  136. "Idle" percentages are due to lack of parallelism, while the brown "Overhead"
  137. and "Scheduling" percentages are due to the overhead of the runtime and of the
  138. scheduler.
  139. To identify tasks precisely, the application can also set the field
  140. starpu_task::tag_id or setting \ref STARPU_TAG_ONLY when calling
  141. starpu_task_insert(). The value of the tag will then show up in the
  142. trace.
  143. One can also introduce user-defined events in the diagram thanks to the
  144. starpu_fxt_trace_user_event_string() function.
  145. One can also set the iteration number, by just calling starpu_iteration_push()
  146. at the beginning of submission loops and starpu_iteration_pop() at the end of
  147. submission loops. These iteration numbers will show up in traces for all tasks
  148. submitted from there.
  149. Coordinates can also be given to data with the starpu_data_set_coordinates() or
  150. starpu_data_set_coordinates_array() function. In the trace, tasks will then be
  151. assigned the coordinates of the first data they write to.
  152. Traces can also be inspected by hand by using the tool <c>fxt_print</c>, for instance:
  153. \verbatim
  154. $ fxt_print -o -f /tmp/prof_file_something
  155. \endverbatim
  156. Timings are in nanoseconds (while timings as seen in ViTE are in milliseconds).
  157. \subsubsection CreatingADAGWithGraphviz Creating a DAG With Graphviz
  158. Another generated trace file is a task graph described using the DOT
  159. language. The file, created in the current directory, is named
  160. <c>dag.dot</c> file in the current directory.
  161. It is possible to get a graphical output of the graph by using the
  162. <c>graphviz</c> library:
  163. \verbatim
  164. $ dot -Tpdf dag.dot -o output.pdf
  165. \endverbatim
  166. \subsubsection TraceTaskDetails Getting Task Details
  167. Another generated trace file gives details on the executed tasks. The
  168. file, created in the current directory, is named <c>tasks.rec</c>. This file
  169. is in the recutils format, i.e. <c>Field: value</c> lines, and empty lines are used to
  170. separate each task. This can be used as a convenient input for various ad-hoc
  171. analysis tools. By default it only contains information about the actual
  172. execution. Performance models can be obtained by running
  173. <c>starpu_tasks_rec_complete</c> on it:
  174. \verbatim
  175. $ starpu_tasks_rec_complete tasks.rec tasks2.rec
  176. \endverbatim
  177. which will add <c>EstimatedTime</c> lines which contain the performance
  178. model-estimated time (in µs) for each worker starting from 0. Since it needs
  179. the performance models, it needs to be run the same way as the application
  180. execution, or at least with <c>STARPU_HOSTNAME</c> set to the hostname of the
  181. machine used for execution, to get the performance models of that machine.
  182. Another possibility is to obtain the performance models as an auxiliary <c>perfmodel.rec</c> file, by using the <c>starpu_perfmodel_recdump</c> utility:
  183. \verbatim
  184. $ starpu_perfmodel_recdump tasks.rec -o perfmodel.rec
  185. \endverbatim
  186. \subsubsection TraceSchedTaskDetails Getting Scheduling Task Details
  187. The file, <c>sched_tasks.rec</c>, created in the current directory,
  188. and in the recutils format, gives information about the tasks
  189. scheduling, and lists the push and pop actions of the scheduler. For
  190. each action, it gives the timestamp, the job priority and the job id.
  191. Each action is separated from the next one by empty lines.
  192. \subsubsection MonitoringActivity Monitoring Activity
  193. Another generated trace file is an activity trace. The file, created
  194. in the current directory, is named <c>activity.data</c>. A profile of
  195. the application showing the activity of StarPU during the execution of
  196. the program can be generated:
  197. \verbatim
  198. $ starpu_workers_activity activity.data
  199. \endverbatim
  200. This will create a file named <c>activity.eps</c> in the current directory.
  201. This picture is composed of two parts.
  202. The first part shows the activity of the different workers. The green sections
  203. indicate which proportion of the time was spent executed kernels on the
  204. processing unit. The red sections indicate the proportion of time spent in
  205. StartPU: an important overhead may indicate that the granularity may be too
  206. low, and that bigger tasks may be appropriate to use the processing unit more
  207. efficiently. The black sections indicate that the processing unit was blocked
  208. because there was no task to process: this may indicate a lack of parallelism
  209. which may be alleviated by creating more tasks when it is possible.
  210. The second part of the picture <c>activity.eps</c> is a graph showing the
  211. evolution of the number of tasks available in the system during the execution.
  212. Ready tasks are shown in black, and tasks that are submitted but not
  213. schedulable yet are shown in grey.
  214. \subsubsection Animation Getting Modular Schedular Animation
  215. When using modular schedulers (i.e. schedulers which use a modular architecture,
  216. and whose name start with "modular-"), the call to
  217. <c>starpu_fxt_tool</c> will also produce a <c>trace.html</c> file
  218. which can be viewed in a javascript-enabled web browser. It shows the
  219. flow of tasks between the components of the modular scheduler.
  220. \subsubsection TimeBetweenSendRecvDataUse Analyzing Time Between MPI Data Transfer and Use by Tasks
  221. <c>starpu_fxt_tool</c> produces a file called <c>comms.rec</c> which describes all
  222. MPI communications. The script <c>starpu_send_recv_data_use.py</c> uses this file
  223. and <c>tasks.rec</c> in order to produce two graphs: the first one shows durations
  224. between the reception of data and their usage by a task and the second one plots the
  225. same graph but with elapsed time between send and usage of a data by the sender.
  226. \image html trace_recv_use.png
  227. \image latex trace_recv_use.eps "" width=\textwidth
  228. \image html trace_send_use.png
  229. \image latex trace_send_use.eps "" width=\textwidth
  230. \subsubsection NumberEvents Number of events in trace files
  231. When launched with the option <c>-number-events</c>, <c>starpu_fxt_tool</c> will
  232. produce a file named <c>number_events.data</c>. This file contains the number of
  233. events for each event type. Events are represented with their key. To convert
  234. event keys to event names, you can use the <c>starpu_fxt_number_events_to_names.py</c>
  235. script:
  236. \verbatim
  237. $ starpu_fxt_number_events_to_names.py number_events.data
  238. \endverbatim
  239. \subsection LimitingScopeTrace Limiting The Scope Of The Trace
  240. For computing statistics, it is useful to limit the trace to a given portion of
  241. the time of the whole execution. This can be achieved by calling
  242. \code{.c}
  243. starpu_fxt_autostart_profiling(0)
  244. \endcode
  245. before calling starpu_init(), to
  246. prevent tracing from starting immediately. Then
  247. \code{.c}
  248. starpu_fxt_start_profiling();
  249. \endcode
  250. and
  251. \code{.c}
  252. starpu_fxt_stop_profiling();
  253. \endcode
  254. can be used around the portion of code to be traced. This will show up as marks
  255. in the trace, and states of workers will only show up for that portion.
  256. \section PerformanceOfCodelets Performance Of Codelets
  257. The performance model of codelets (see \ref PerformanceModelExample)
  258. can be examined by using the tool <c>starpu_perfmodel_display</c>:
  259. \verbatim
  260. $ starpu_perfmodel_display -l
  261. file: <malloc_pinned.hannibal>
  262. file: <starpu_slu_lu_model_21.hannibal>
  263. file: <starpu_slu_lu_model_11.hannibal>
  264. file: <starpu_slu_lu_model_22.hannibal>
  265. file: <starpu_slu_lu_model_12.hannibal>
  266. \endverbatim
  267. Here, the codelets of the example <c>lu</c> are available. We can examine the
  268. performance of the kernel <c>22</c> (in micro-seconds), which is history-based:
  269. \verbatim
  270. $ starpu_perfmodel_display -s starpu_slu_lu_model_22
  271. performance model for cpu
  272. # hash size mean dev n
  273. 57618ab0 19660800 2.851069e+05 1.829369e+04 109
  274. performance model for cuda_0
  275. # hash size mean dev n
  276. 57618ab0 19660800 1.164144e+04 1.556094e+01 315
  277. performance model for cuda_1
  278. # hash size mean dev n
  279. 57618ab0 19660800 1.164271e+04 1.330628e+01 360
  280. performance model for cuda_2
  281. # hash size mean dev n
  282. 57618ab0 19660800 1.166730e+04 3.390395e+02 456
  283. \endverbatim
  284. We can see that for the given size, over a sample of a few hundreds of
  285. execution, the GPUs are about 20 times faster than the CPUs (numbers are in
  286. us). The standard deviation is extremely low for the GPUs, and less than 10% for
  287. CPUs.
  288. This tool can also be used for regression-based performance models. It will then
  289. display the regression formula, and in the case of non-linear regression, the
  290. same performance log as for history-based performance models:
  291. \verbatim
  292. $ starpu_perfmodel_display -s non_linear_memset_regression_based
  293. performance model for cpu_impl_0
  294. Regression : #sample = 1400
  295. Linear: y = alpha size ^ beta
  296. alpha = 1.335973e-03
  297. beta = 8.024020e-01
  298. Non-Linear: y = a size ^b + c
  299. a = 5.429195e-04
  300. b = 8.654899e-01
  301. c = 9.009313e-01
  302. # hash size mean stddev n
  303. a3d3725e 4096 4.763200e+00 7.650928e-01 100
  304. 870a30aa 8192 1.827970e+00 2.037181e-01 100
  305. 48e988e9 16384 2.652800e+00 1.876459e-01 100
  306. 961e65d2 32768 4.255530e+00 3.518025e-01 100
  307. ...
  308. \endverbatim
  309. The same can also be achieved by using StarPU's library API, see
  310. \ref API_Performance_Model and notably the function
  311. starpu_perfmodel_load_symbol(). The source code of the tool
  312. <c>starpu_perfmodel_display</c> can be a useful example.
  313. An XML output can also be printed by using the <c>-x</c> option:
  314. \verbatim
  315. tools/starpu_perfmodel_display -x -s non_linear_memset_regression_based
  316. <?xml version="1.0" encoding="UTF-8"?>
  317. <!DOCTYPE StarPUPerfmodel SYSTEM "starpu-perfmodel.dtd">
  318. <!-- symbol non_linear_memset_regression_based -->
  319. <!-- All times in us -->
  320. <perfmodel version="45">
  321. <combination>
  322. <device type="CPU" id="0" ncores="1"/>
  323. <implementation id="0">
  324. <!-- cpu0_impl0 (Comb0) -->
  325. <!-- time = a size ^b + c -->
  326. <nl_regression a="5.429195e-04" b="8.654899e-01" c="9.009313e-01"/>
  327. <entry footprint="a3d3725e" size="4096" flops="0.000000e+00" mean="4.763200e+00" deviation="7.650928e-01" nsample="100"/>
  328. <entry footprint="870a30aa" size="8192" flops="0.000000e+00" mean="1.827970e+00" deviation="2.037181e-01" nsample="100"/>
  329. <entry footprint="48e988e9" size="16384" flops="0.000000e+00" mean="2.652800e+00" deviation="1.876459e-01" nsample="100"/>
  330. <entry footprint="961e65d2" size="32768" flops="0.000000e+00" mean="4.255530e+00" deviation="3.518025e-01" nsample="100"/>
  331. </implementation>
  332. </combination>
  333. </perfmodel>
  334. \endverbatim
  335. The tool <c>starpu_perfmodel_plot</c> can be used to draw performance
  336. models. It writes a <c>.gp</c> file in the current directory, to be
  337. run with the tool <c>gnuplot</c>, which shows the corresponding curve.
  338. \image html starpu_non_linear_memset_regression_based.png
  339. \image latex starpu_non_linear_memset_regression_based.eps "" width=\textwidth
  340. When the field starpu_task::flops is set (or \ref STARPU_FLOPS is passed to
  341. starpu_task_insert()), <c>starpu_perfmodel_plot</c> can directly draw a GFlops
  342. curve, by simply adding the <c>-f</c> option:
  343. \verbatim
  344. $ starpu_perfmodel_plot -f -s chol_model_11
  345. \endverbatim
  346. This will however disable displaying the regression model, for which we can not
  347. compute GFlops.
  348. \image html starpu_chol_model_11_type.png
  349. \image latex starpu_chol_model_11_type.eps "" width=\textwidth
  350. When the FxT trace file <c>prof_file_something</c> has been generated, it is possible to
  351. get a profiling of each codelet by calling:
  352. \verbatim
  353. $ starpu_fxt_tool -i /tmp/prof_file_something
  354. $ starpu_codelet_profile distrib.data codelet_name
  355. \endverbatim
  356. This will create profiling data files, and a <c>distrib.data.gp</c> file in the current
  357. directory, which draws the distribution of codelet time over the application
  358. execution, according to data input size.
  359. \image html distrib_data.png
  360. \image latex distrib_data.eps "" width=\textwidth
  361. This is also available in the tool <c>starpu_perfmodel_plot</c>, by passing it
  362. the fxt trace:
  363. \verbatim
  364. $ starpu_perfmodel_plot -s non_linear_memset_regression_based -i /tmp/prof_file_foo_0
  365. \endverbatim
  366. It will produce a <c>.gp</c> file which contains both the performance model
  367. curves, and the profiling measurements.
  368. \image html starpu_non_linear_memset_regression_based_2.png
  369. \image latex starpu_non_linear_memset_regression_based_2.eps "" width=\textwidth
  370. If you have the statistical tool <c>R</c> installed, you can additionally use
  371. \verbatim
  372. $ starpu_codelet_histo_profile distrib.data
  373. \endverbatim
  374. Which will create one <c>.pdf</c> file per codelet and per input size, showing a
  375. histogram of the codelet execution time distribution.
  376. \image html distrib_data_histo.png
  377. \image latex distrib_data_histo.eps "" width=\textwidth
  378. \section DataTrace Data trace and tasks length
  379. It is possible to get statistics about tasks length and data size by using :
  380. \verbatim
  381. $ starpu_fxt_data_trace filename [codelet1 codelet2 ... codeletn]
  382. \endverbatim
  383. Where filename is the FxT trace file and codeletX the names of the codelets you
  384. want to profile (if no names are specified, <c>starpu_fxt_data_trace</c> will profile them all).
  385. This will create a file, <c>data_trace.gp</c> which
  386. can be executed to get a <c>.eps</c> image of these results. On the image, each point represents a
  387. task, and each color corresponds to a codelet.
  388. \image html data_trace.png
  389. \image latex data_trace.eps "" width=\textwidth
  390. \section TraceStatistics Trace Statistics
  391. More than just codelet performance, it is interesting to get statistics over all
  392. kinds of StarPU states (allocations, data transfers, etc.). This is particularly
  393. useful to check what may have gone wrong in the accurracy of the SimGrid
  394. simulation.
  395. This requires the <c>R</c> statistical tool, with the <c>plyr</c>,
  396. <c>ggplot2</c> and <c>data.table</c> packages. If your system
  397. distribution does not have packages for these, one can fetch them from
  398. <c>CRAN</c>:
  399. \verbatim
  400. $ R
  401. > install.packages("plyr")
  402. > install.packages("ggplot2")
  403. > install.packages("data.table")
  404. > install.packages("knitr")
  405. \endverbatim
  406. The <c>pj_dump</c> tool from <c>pajeng</c> is also needed (see
  407. https://github.com/schnorr/pajeng)
  408. One can then get textual or <c>.csv</c> statistics over the trace states:
  409. \verbatim
  410. $ starpu_paje_state_stats -v native.trace simgrid.trace
  411. "Value" "Events_native.csv" "Duration_native.csv" "Events_simgrid.csv" "Duration_simgrid.csv"
  412. "Callback" 220 0.075978 220 0
  413. "chol_model_11" 10 565.176 10 572.8695
  414. "chol_model_21" 45 9184.828 45 9170.719
  415. "chol_model_22" 165 64712.07 165 64299.203
  416. $ starpu_paje_state_stats native.trace simgrid.trace
  417. \endverbatim
  418. An other way to get statistics of StarPU states (without installing <c>R</c> and
  419. <c>pj_dump</c>) is to use the <c>starpu_trace_state_stats.py</c> script which parses the
  420. generated <c>trace.rec</c> file instead of the <c>paje.trace</c> file. The output is similar
  421. to the previous script but it doesn't need any dependencies.
  422. The different prefixes used in <c>trace.rec</c> are:
  423. \verbatim
  424. E: Event type
  425. N: Event name
  426. C: Event category
  427. W: Worker ID
  428. T: Thread ID
  429. S: Start time
  430. \endverbatim
  431. Here's an example on how to use it:
  432. \verbatim
  433. $ python starpu_trace_state_stats.py trace.rec | column -t -s ","
  434. "Name" "Count" "Type" "Duration"
  435. "Callback" 220 Runtime 0.075978
  436. "chol_model_11" 10 Task 565.176
  437. "chol_model_21" 45 Task 9184.828
  438. "chol_model_22" 165 Task 64712.07
  439. \endverbatim
  440. <c>starpu_trace_state_stats.py</c> can also be used to compute the different
  441. efficiencies. Refer to the usage description to show some examples.
  442. And one can plot histograms of execution times, of several states for instance:
  443. \verbatim
  444. $ starpu_paje_draw_histogram -n chol_model_11,chol_model_21,chol_model_22 native.trace simgrid.trace
  445. \endverbatim
  446. and see the resulting pdf file:
  447. \image html paje_draw_histogram.png
  448. \image latex paje_draw_histogram.eps "" width=\textwidth
  449. A quick statistical report can be generated by using:
  450. \verbatim
  451. $ starpu_paje_summary native.trace simgrid.trace
  452. \endverbatim
  453. it includes gantt charts, execution summaries, as well as state duration charts
  454. and time distribution histograms.
  455. Other external Paje analysis tools can be used on these traces, one just needs
  456. to sort the traces by timestamp order (which not guaranteed to make recording
  457. more efficient):
  458. \verbatim
  459. $ starpu_paje_sort paje.trace
  460. \endverbatim
  461. \section PapiCounters PAPI counters
  462. Performance counter values could be obtained from the PAPI framework if
  463. <c>./configure</c> detected the libpapi. One has to set the \ref STARPU_PROFILING
  464. environment variable to 1 and then specify which events to record with the
  465. \ref STARPU_PROF_PAPI_EVENTS environment variable. For instance:
  466. \verbatim
  467. export STARPU_PROFILING=1 STARPU_PROF_PAPI_EVENTS="PAPI_TOT_INS PAPI_TOT_CYC"
  468. \endverbatim
  469. In the current simple implementation, only CPU tasks have their events measured
  470. and require CPUs that support the PAPI events. All events that PAPI support are
  471. available from their documentation (https://icl.cs.utk.edu/projects/papi/wiki/PAPIC:Preset_Event_Definitions).
  472. It is important to note that not all events are available on all systems, and
  473. general PAPI recommendations should be followed.
  474. The counter values can be accessed using the profiling interface:
  475. \code{.c}
  476. task->profiling_info->papi_values
  477. \endcode
  478. Also, it can be accessed and/or saved with tracing when using \ref STARPU_FXT_TRACE. With the use of <c>starpu_fxt_tool</c>
  479. the file <c>papi.rec</c> is generated containing the following triple:
  480. \verbatim
  481. Task Id
  482. Event Id
  483. Value
  484. \endverbatim
  485. External tools like <c>rec2csv</c> can be used to convert this rec file to a <c>csv</c>, where each
  486. line represents a value for an event for a task.
  487. \section TheoreticalLowerBoundOnExecutionTime Theoretical Lower Bound On Execution Time
  488. StarPU can record a trace of what tasks are needed to complete the
  489. application, and then, by using a linear system, provide a theoretical lower
  490. bound of the execution time (i.e. with an ideal scheduling).
  491. The computed bound is not really correct when not taking into account
  492. dependencies, but for an application which have enough parallelism, it is very
  493. near to the bound computed with dependencies enabled (which takes a huge lot
  494. more time to compute), and thus provides a good-enough estimation of the ideal
  495. execution time.
  496. \ref TheoreticalLowerBoundOnExecutionTimeExample provides an example on how to
  497. use this.
  498. \section TheoreticalLowerBoundOnExecutionTimeExample Theoretical Lower Bound On Execution Time Example
  499. For kernels with history-based performance models (and provided that
  500. they are completely calibrated), StarPU can very easily provide a
  501. theoretical lower bound for the execution time of a whole set of
  502. tasks. See for instance <c>examples/lu/lu_example.c</c>: before
  503. submitting tasks, call the function starpu_bound_start(), and after
  504. complete execution, call starpu_bound_stop().
  505. starpu_bound_print_lp() or starpu_bound_print_mps() can then be used
  506. to output a Linear Programming problem corresponding to the schedule
  507. of your tasks. Run it through <c>lp_solve</c> or any other linear
  508. programming solver, and that will give you a lower bound for the total
  509. execution time of your tasks. If StarPU was compiled with the library
  510. <c>glpk</c> installed, starpu_bound_compute() can be used to solve it
  511. immediately and get the optimized minimum, in ms. Its parameter
  512. <c>integer</c> allows to decide whether integer resolution should be
  513. computed and returned
  514. The <c>deps</c> parameter tells StarPU whether to take tasks, implicit
  515. data, and tag dependencies into account. Tags released in a callback
  516. or similar are not taken into account, only tags associated with a task are.
  517. It must be understood that the linear programming
  518. problem size is quadratic with the number of tasks and thus the time to solve it
  519. will be very long, it could be minutes for just a few dozen tasks. You should
  520. probably use <c>lp_solve -timeout 1 test.pl -wmps test.mps</c> to convert the
  521. problem to MPS format and then use a better solver, <c>glpsol</c> might be
  522. better than <c>lp_solve</c> for instance (the <c>--pcost</c> option may be
  523. useful), but sometimes doesn't manage to converge. <c>cbc</c> might look
  524. slower, but it is parallel. For <c>lp_solve</c>, be sure to try at least all the
  525. <c>-B</c> options. For instance, we often just use <c>lp_solve -cc -B1 -Bb
  526. -Bg -Bp -Bf -Br -BG -Bd -Bs -BB -Bo -Bc -Bi</c> , and the <c>-gr</c> option can
  527. also be quite useful. The resulting schedule can be observed by using
  528. the tool <c>starpu_lp2paje</c>, which converts it into the Paje
  529. format.
  530. Data transfer time can only be taken into account when <c>deps</c> is set. Only
  531. data transfers inferred from implicit data dependencies between tasks are taken
  532. into account. Other data transfers are assumed to be completely overlapped.
  533. Setting <c>deps</c> to 0 will only take into account the actual computations
  534. on processing units. It however still properly takes into account the varying
  535. performances of kernels and processing units, which is quite more accurate than
  536. just comparing StarPU performances with the fastest of the kernels being used.
  537. The <c>prio</c> parameter tells StarPU whether to simulate taking into account
  538. the priorities as the StarPU scheduler would, i.e. schedule prioritized
  539. tasks before less prioritized tasks, to check to which extend this results
  540. to a less optimal solution. This increases even more computation time.
  541. \section starvz Trace visualization with StarVZ
  542. Creating views with StarVZ (see: https://github.com/schnorr/starvz) is made up of two steps. The initial
  543. stage consists of a pre-processing of the traces generated by the application.
  544. The second step consists of the analysis itself and is carried out with the
  545. aid of R packages. To download and install StarVZ, it is necessary to have R,
  546. pajeng and the following packages:
  547. \verbatim
  548. # For pajeng
  549. apt install -y git cmake build-essential libboost-dev asciidoc flex bison
  550. git clone git://github.com/schnorr/pajeng.git
  551. mkdir -p pajeng/b ; cd pajeng/b
  552. cmake ..
  553. make
  554. # For R tidyverse
  555. apt install -y r-base libxml2-dev libssl-dev libcurl4-openssl-dev libgit2-dev libboost-dev
  556. \endverbatim
  557. To install the StarVZ the following commands can be used:
  558. \verbatim
  559. git clone https://github.com/schnorr/starvz.git
  560. echo "install.packages(c('tidyverse', 'devtools'), repos = 'https://cloud.r-project.org')" | R --vanilla
  561. echo "library(devtools); devtools::install_local(path='./starvz/R_package')" | R --vanilla
  562. \endverbatim
  563. To generate traces from an application, it is necessary to set \ref STARPU_GENERATE_TRACE.
  564. and build StarPU with FxT. Then, Step 1 of StarVZ can be used on a folder with
  565. StarPU FxT traces:
  566. \verbatim
  567. export PATH=starvz/:$PATH
  568. export PATH=pajeng/b:$PATH
  569. export PATH=$STARPU_HOME/bin:$PATH
  570. ./starvz/src/phase1-workflow.sh /tmp/ ""
  571. \endverbatim
  572. Then the second step can be executed directly in R, StarVZ enables a set of
  573. different plots that can be configured on a .yaml file. A default file is provided
  574. <c>full_config.yaml</c>; also the options can be changed directly in R.
  575. \verbatim
  576. library(starvz)
  577. dtrace <- the_fast_reader_function("./")
  578. pajer <- config::get(file = "starvz/full_config.yaml")
  579. pajer$starpu$active = TRUE
  580. pajer$submitted$active = TRUE
  581. pajer$st$abe$active = TRUE
  582. plot <- the_master_function(dtrace)
  583. \endverbatim
  584. An example of visualization follows:
  585. \image html starvz_visu.png
  586. \image latex starvz_visu.eps "" width=\textwidth
  587. \section MemoryFeedback Memory Feedback
  588. It is possible to enable memory statistics. To do so, you need to pass
  589. the option \ref enable-memory-stats "--enable-memory-stats" when running <c>configure</c>. It is then
  590. possible to call the function starpu_data_display_memory_stats() to
  591. display statistics about the current data handles registered within StarPU.
  592. Moreover, statistics will be displayed at the end of the execution on
  593. data handles which have not been cleared out. This can be disabled by
  594. setting the environment variable \ref STARPU_MEMORY_STATS to <c>0</c>.
  595. For example, by adding a call to the function
  596. starpu_data_display_memory_stats() in the fblock example before
  597. unpartitioning the data, one will get something
  598. similar to:
  599. \verbatim
  600. $ STARPU_MEMORY_STATS=1 ./examples/filters/fblock
  601. ...
  602. #---------------------
  603. Memory stats :
  604. #-------
  605. Data on Node #2
  606. #-----
  607. Data : 0x5562074e8670
  608. Size : 144
  609. #--
  610. Data access stats
  611. /!\ Work Underway
  612. Node #0
  613. Direct access : 0
  614. Loaded (Owner) : 0
  615. Loaded (Shared) : 0
  616. Invalidated (was Owner) : 1
  617. Node #2
  618. Direct access : 0
  619. Loaded (Owner) : 1
  620. Loaded (Shared) : 0
  621. Invalidated (was Owner) : 0
  622. #-------
  623. Data on Node #3
  624. #-----
  625. Data : 0x5562074e9338
  626. Size : 96
  627. #--
  628. Data access stats
  629. /!\ Work Underway
  630. Node #0
  631. Direct access : 0
  632. Loaded (Owner) : 0
  633. Loaded (Shared) : 0
  634. Invalidated (was Owner) : 1
  635. Node #3
  636. Direct access : 0
  637. Loaded (Owner) : 1
  638. Loaded (Shared) : 0
  639. Invalidated (was Owner) : 0
  640. #---------------------
  641. ...
  642. \endverbatim
  643. \section DataStatistics Data Statistics
  644. Different data statistics can be displayed at the end of the execution
  645. of the application. To enable them, you need to define the environment
  646. variable \ref STARPU_ENABLE_STATS. When calling
  647. starpu_shutdown() various statistics will be displayed,
  648. execution, MSI cache statistics, allocation cache statistics, and data
  649. transfer statistics. The display can be disabled by setting the
  650. environment variable \ref STARPU_STATS to <c>0</c>.
  651. \verbatim
  652. $ ./examples/cholesky/cholesky_tag
  653. Computation took (in ms)
  654. 518.16
  655. Synthetic GFlops : 44.21
  656. #---------------------
  657. MSI cache stats :
  658. TOTAL MSI stats hit 1622 (66.23 %) miss 827 (33.77 %)
  659. ...
  660. \endverbatim
  661. \verbatim
  662. $ STARPU_STATS=0 ./examples/cholesky/cholesky_tag
  663. Computation took (in ms)
  664. 518.16
  665. Synthetic GFlops : 44.21
  666. \endverbatim
  667. // TODO: data transfer stats are similar to the ones displayed when
  668. // setting STARPU_BUS_STATS
  669. */