370_online_performance_tools.doxy 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011,2012,2016 Inria
  4. * Copyright (C) 2010-2019 CNRS
  5. * Copyright (C) 2009-2011,2014,2016,2018 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 OnlinePerformanceTools Online Performance Tools
  19. \section On-linePerformanceFeedback On-line Performance Feedback
  20. \subsection EnablingOn-linePerformanceMonitoring Enabling On-line Performance Monitoring
  21. In order to enable online performance monitoring, the application can
  22. call starpu_profiling_status_set() with the parameter
  23. ::STARPU_PROFILING_ENABLE. It is possible to detect whether monitoring
  24. is already enabled or not by calling starpu_profiling_status_get().
  25. Enabling monitoring also reinitialize all previously collected
  26. feedback. The environment variable \ref STARPU_PROFILING can also be
  27. set to <c>1</c> to achieve the same effect. The function
  28. starpu_profiling_init() can also be called during the execution to
  29. reinitialize performance counters and to start the profiling if the
  30. environment variable \ref STARPU_PROFILING is set to <c>1</c>.
  31. Likewise, performance monitoring is stopped by calling
  32. starpu_profiling_status_set() with the parameter
  33. ::STARPU_PROFILING_DISABLE. Note that this does not reset the
  34. performance counters so that the application may consult them later
  35. on.
  36. More details about the performance monitoring API are available in \ref API_Profiling.
  37. \subsection Per-taskFeedback Per-task Feedback
  38. If profiling is enabled, a pointer to a structure
  39. starpu_profiling_task_info is put in the field
  40. starpu_task::profiling_info when a task terminates. This structure is
  41. automatically destroyed when the task structure is destroyed, either
  42. automatically or by calling starpu_task_destroy().
  43. The structure starpu_profiling_task_info indicates the date when the
  44. task was submitted (starpu_profiling_task_info::submit_time), started
  45. (starpu_profiling_task_info::start_time), and terminated
  46. (starpu_profiling_task_info::end_time), relative to the initialization
  47. of StarPU with starpu_init(). It also specifies the identifier of the worker
  48. that has executed the task (starpu_profiling_task_info::workerid).
  49. These date are stored as <c>timespec</c> structures which the user may convert
  50. into micro-seconds using the helper function
  51. starpu_timing_timespec_to_us().
  52. It it worth noting that the application may directly access this structure from
  53. the callback executed at the end of the task. The structure starpu_task
  54. associated to the callback currently being executed is indeed accessible with
  55. the function starpu_task_get_current().
  56. \subsection Per-codeletFeedback Per-codelet Feedback
  57. The field starpu_codelet::per_worker_stats is
  58. an array of counters. The <c>i</c>-th entry of the array is incremented every time a
  59. task implementing the codelet is executed on the <c>i</c>-th worker.
  60. This array is not reinitialized when profiling is enabled or disabled.
  61. \subsection Per-workerFeedback Per-worker Feedback
  62. The second argument returned by the function
  63. starpu_profiling_worker_get_info() is a structure
  64. starpu_profiling_worker_info that gives statistics about the specified
  65. worker. This structure specifies when StarPU started collecting
  66. profiling information for that worker
  67. (starpu_profiling_worker_info::start_time), the
  68. duration of the profiling measurement interval
  69. (starpu_profiling_worker_info::total_time), the time spent executing
  70. kernels (starpu_profiling_worker_info::executing_time), the time
  71. spent sleeping because there is no task to execute at all
  72. (starpu_profiling_worker_info::sleeping_time), and the number of tasks that were executed
  73. while profiling was enabled. These values give an estimation of the
  74. proportion of time spent do real work, and the time spent either
  75. sleeping because there are not enough executable tasks or simply
  76. wasted in pure StarPU overhead.
  77. Calling starpu_profiling_worker_get_info() resets the profiling
  78. information associated to a worker.
  79. To easily display all this information, the environment variable
  80. \ref STARPU_WORKER_STATS can be set to <c>1</c> (in addition to setting
  81. \ref STARPU_PROFILING to 1). A summary will then be displayed at program termination:
  82. \verbatim
  83. Worker stats:
  84. CUDA 0.0 (4.7 GiB)
  85. 480 task(s)
  86. total: 1574.82 ms executing: 1510.72 ms sleeping: 0.00 ms overhead 64.10 ms
  87. 325.217970 GFlop/s
  88. CPU 0
  89. 22 task(s)
  90. total: 1574.82 ms executing: 1364.81 ms sleeping: 0.00 ms overhead 210.01 ms
  91. 7.512057 GFlop/s
  92. CPU 1
  93. 14 task(s)
  94. total: 1574.82 ms executing: 1500.13 ms sleeping: 0.00 ms overhead 74.69 ms
  95. 6.675853 GFlop/s
  96. CPU 2
  97. 14 task(s)
  98. total: 1574.82 ms executing: 1553.12 ms sleeping: 0.00 ms overhead 21.70 ms
  99. 7.152886 GFlop/s
  100. \endverbatim
  101. The number of GFlops is available because the starpu_task::flops field of the
  102. tasks were filled (or \ref STARPU_FLOPS used in starpu_task_insert()).
  103. When an FxT trace is generated (see \ref GeneratingTracesWithFxT), it is also
  104. possible to use the tool <c>starpu_workers_activity</c> (see
  105. \ref MonitoringActivity) to generate a graphic showing the evolution of
  106. these values during the time, for the different workers.
  107. \subsection Bus-relatedFeedback Bus-related Feedback
  108. // how to enable/disable performance monitoring
  109. // what kind of information do we get ?
  110. The bus speed measured by StarPU can be displayed by using the tool
  111. <c>starpu_machine_display</c>, for instance:
  112. \verbatim
  113. StarPU has found:
  114. 3 CUDA devices
  115. CUDA 0 (Tesla C2050 02:00.0)
  116. CUDA 1 (Tesla C2050 03:00.0)
  117. CUDA 2 (Tesla C2050 84:00.0)
  118. from to RAM to CUDA 0 to CUDA 1 to CUDA 2
  119. RAM 0.000000 5176.530428 5176.492994 5191.710722
  120. CUDA 0 4523.732446 0.000000 2414.074751 2417.379201
  121. CUDA 1 4523.718152 2414.078822 0.000000 2417.375119
  122. CUDA 2 4534.229519 2417.069025 2417.060863 0.000000
  123. \endverbatim
  124. Statistics about the data transfers which were performed and temporal average
  125. of bandwidth usage can be obtained by setting the environment variable
  126. \ref STARPU_BUS_STATS to <c>1</c>; a summary will then be displayed at program termination:
  127. \verbatim
  128. Data transfer stats:
  129. RAM 0 -> CUDA 0 319.92 MB 213.10 MB/s (transfers : 91 - avg 3.52 MB)
  130. CUDA 0 -> RAM 0 214.45 MB 142.85 MB/s (transfers : 61 - avg 3.52 MB)
  131. RAM 0 -> CUDA 1 302.34 MB 201.39 MB/s (transfers : 86 - avg 3.52 MB)
  132. CUDA 1 -> RAM 0 133.59 MB 88.99 MB/s (transfers : 38 - avg 3.52 MB)
  133. CUDA 0 -> CUDA 1 144.14 MB 96.01 MB/s (transfers : 41 - avg 3.52 MB)
  134. CUDA 1 -> CUDA 0 130.08 MB 86.64 MB/s (transfers : 37 - avg 3.52 MB)
  135. RAM 0 -> CUDA 2 312.89 MB 208.42 MB/s (transfers : 89 - avg 3.52 MB)
  136. CUDA 2 -> RAM 0 133.59 MB 88.99 MB/s (transfers : 38 - avg 3.52 MB)
  137. CUDA 0 -> CUDA 2 151.17 MB 100.69 MB/s (transfers : 43 - avg 3.52 MB)
  138. CUDA 2 -> CUDA 0 105.47 MB 70.25 MB/s (transfers : 30 - avg 3.52 MB)
  139. CUDA 1 -> CUDA 2 175.78 MB 117.09 MB/s (transfers : 50 - avg 3.52 MB)
  140. CUDA 2 -> CUDA 1 203.91 MB 135.82 MB/s (transfers : 58 - avg 3.52 MB)
  141. Total transfers: 2.27 GB
  142. \endverbatim
  143. \subsection MPI-relatedFeedback MPI-related Feedback
  144. Statistics about the data transfers which were performed over MPI can be
  145. obtained by setting the environment variable \ref STARPU_COMM_STATS to <c>1</c>;
  146. a summary will then be displayed at program termination:
  147. \verbatim
  148. [starpu_comm_stats][0] TOTAL: 4.000000 GB 4.000000 GB
  149. [starpu_comm_stats][0->1] 4.000000 GB 4.000000 GB
  150. [starpu_comm_stats][1] TOTAL: 8.000000 GB 8.000000 GB
  151. [starpu_comm_stats][1->0] 8.000000 GB 8.000000 GB
  152. \endverbatim
  153. \subsection StarPU-TopInterface StarPU-Top Interface
  154. StarPU-Top is an interface which remotely displays the on-line state of a StarPU
  155. application and permits the user to change parameters on the fly.
  156. Variables to be monitored can be registered by calling the functions
  157. starpu_top_add_data_boolean(), starpu_top_add_data_integer(),
  158. starpu_top_add_data_float(), e.g.:
  159. \code{.c}
  160. starpu_top_data *data = starpu_top_add_data_integer("mynum", 0, 100, 1);
  161. \endcode
  162. The application should then call starpu_top_init_and_wait() to give its name
  163. and wait for StarPU-Top to get a start request from the user. The name is used
  164. by StarPU-Top to quickly reload a previously-saved layout of parameter display.
  165. \code{.c}
  166. starpu_top_init_and_wait("the application");
  167. \endcode
  168. The new values can then be provided thanks to
  169. starpu_top_update_data_boolean(), starpu_top_update_data_integer(),
  170. starpu_top_update_data_float(), e.g.:
  171. \code{.c}
  172. starpu_top_update_data_integer(data, mynum);
  173. \endcode
  174. Updateable parameters can be registered thanks to starpu_top_register_parameter_boolean(), starpu_top_register_parameter_integer(), starpu_top_register_parameter_float(), e.g.:
  175. \code{.c}
  176. float alpha;
  177. starpu_top_register_parameter_float("alpha", &alpha, 0, 10, modif_hook);
  178. \endcode
  179. <c>modif_hook</c> is a function which will be called when the parameter is being modified, it can for instance print the new value:
  180. \code{.c}
  181. void modif_hook(struct starpu_top_param *d)
  182. {
  183. fprintf(stderr,"%s has been modified: %f\n", d->name, alpha);
  184. }
  185. \endcode
  186. Task schedulers should notify StarPU-Top when it has decided when a task will be
  187. scheduled, so that it can show it in its Gantt chart, for instance:
  188. \code{.c}
  189. starpu_top_task_prevision(task, workerid, begin, end);
  190. \endcode
  191. Starting StarPU-Top (StarPU-Top is started via the binary
  192. <c>starpu_top</c>) and the application can be done in two ways:
  193. <ul>
  194. <li> The application is started by hand on some machine (and thus already
  195. waiting for the start event). In the Preference dialog of StarPU-Top, the SSH
  196. checkbox should be unchecked, and the hostname and port (default is 2011) on
  197. which the application is already running should be specified. Clicking on the
  198. connection button will thus connect to the already-running application.
  199. </li>
  200. <li> StarPU-Top is started first, and clicking on the connection button will
  201. start the application itself (possibly on a remote machine). The SSH checkbox
  202. should be checked, and a command line provided, e.g.:
  203. \verbatim
  204. $ ssh myserver STARPU_SCHED=dmda ./application
  205. \endverbatim
  206. If port 2011 of the remote machine can not be accessed directly, an ssh port bridge should be added:
  207. \verbatim
  208. $ ssh -L 2011:localhost:2011 myserver STARPU_SCHED=dmda ./application
  209. \endverbatim
  210. and "localhost" should be used as IP Address to connect to.
  211. </li>
  212. </ul>
  213. \section TaskAndWorkerProfiling Task And Worker Profiling
  214. A full example showing how to use the profiling API is available in
  215. the StarPU sources in the directory <c>examples/profiling/</c>.
  216. \code{.c}
  217. struct starpu_task *task = starpu_task_create();
  218. task->cl = &cl;
  219. task->synchronous = 1;
  220. /* We will destroy the task structure by hand so that we can
  221. * query the profiling info before the task is destroyed. */
  222. task->destroy = 0;
  223. /* Submit and wait for completion (since synchronous was set to 1) */
  224. starpu_task_submit(task);
  225. /* The task is finished, get profiling information */
  226. struct starpu_profiling_task_info *info = task->profiling_info;
  227. /* How much time did it take before the task started ? */
  228. double delay += starpu_timing_timespec_delay_us(&info->submit_time, &info->start_time);
  229. /* How long was the task execution ? */
  230. double length += starpu_timing_timespec_delay_us(&info->start_time, &info->end_time);
  231. /* We no longer need the task structure */
  232. starpu_task_destroy(task);
  233. \endcode
  234. \code{.c}
  235. /* Display the occupancy of all workers during the test */
  236. int worker;
  237. for (worker = 0; worker < starpu_worker_get_count(); worker++)
  238. {
  239. struct starpu_profiling_worker_info worker_info;
  240. int ret = starpu_profiling_worker_get_info(worker, &worker_info);
  241. STARPU_ASSERT(!ret);
  242. double total_time = starpu_timing_timespec_to_us(&worker_info.total_time);
  243. double executing_time = starpu_timing_timespec_to_us(&worker_info.executing_time);
  244. double sleeping_time = starpu_timing_timespec_to_us(&worker_info.sleeping_time);
  245. double overhead_time = total_time - executing_time - sleeping_time;
  246. float executing_ratio = 100.0*executing_time/total_time;
  247. float sleeping_ratio = 100.0*sleeping_time/total_time;
  248. float overhead_ratio = 100.0 - executing_ratio - sleeping_ratio;
  249. char workername[128];
  250. starpu_worker_get_name(worker, workername, 128);
  251. fprintf(stderr, "Worker %s:\n", workername);
  252. fprintf(stderr, "\ttotal time: %.2lf ms\n", total_time*1e-3);
  253. fprintf(stderr, "\texec time: %.2lf ms (%.2f %%)\n", executing_time*1e-3, executing_ratio);
  254. fprintf(stderr, "\tblocked time: %.2lf ms (%.2f %%)\n", sleeping_time*1e-3, sleeping_ratio);
  255. fprintf(stderr, "\toverhead time: %.2lf ms (%.2f %%)\n", overhead_time*1e-3, overhead_ratio);
  256. }
  257. \endcode
  258. \section PerformanceModelExample Performance Model Example
  259. To achieve good scheduling, StarPU scheduling policies need to be able to
  260. estimate in advance the duration of a task. This is done by giving to codelets
  261. a performance model, by defining a structure starpu_perfmodel and
  262. providing its address in the field starpu_codelet::model. The fields
  263. starpu_perfmodel::symbol and starpu_perfmodel::type are mandatory, to
  264. give a name to the model, and the type of the model, since there are
  265. several kinds of performance models. For compatibility, make sure to
  266. initialize the whole structure to zero, either by using explicit
  267. memset(), or by letting the compiler implicitly do it as examplified
  268. below.
  269. <ul>
  270. <li>
  271. Measured at runtime (model type ::STARPU_HISTORY_BASED). This assumes that for a
  272. given set of data input/output sizes, the performance will always be about the
  273. same. This is very true for regular kernels on GPUs for instance (<0.1% error),
  274. and just a bit less true on CPUs (~=1% error). This also assumes that there are
  275. few different sets of data input/output sizes. StarPU will then keep record of
  276. the average time of previous executions on the various processing units, and use
  277. it as an estimation. History is done per task size, by using a hash of the input
  278. and ouput sizes as an index.
  279. It will also save it in <c>$STARPU_HOME/.starpu/sampling/codelets</c>
  280. for further executions, and can be observed by using the tool
  281. <c>starpu_perfmodel_display</c>, or drawn by using
  282. the tool <c>starpu_perfmodel_plot</c> (\ref PerformanceModelCalibration). The
  283. models are indexed by machine name. To
  284. share the models between machines (e.g. for a homogeneous cluster), use
  285. <c>export STARPU_HOSTNAME=some_global_name</c>. Measurements are only done
  286. when using a task scheduler which makes use of it, such as
  287. <c>dmda</c>. Measurements can also be provided explicitly by the application, by
  288. using the function starpu_perfmodel_update_history().
  289. The following is a small code example.
  290. If e.g. the code is recompiled with other compilation options, or several
  291. variants of the code are used, the <c>symbol</c> string should be changed to reflect
  292. that, in order to recalibrate a new model from zero. The <c>symbol</c> string can even
  293. be constructed dynamically at execution time, as long as this is done before
  294. submitting any task using it.
  295. \code{.c}
  296. static struct starpu_perfmodel mult_perf_model =
  297. {
  298. .type = STARPU_HISTORY_BASED,
  299. .symbol = "mult_perf_model"
  300. };
  301. struct starpu_codelet cl =
  302. {
  303. .cpu_funcs = { cpu_mult },
  304. .cpu_funcs_name = { "cpu_mult" },
  305. .nbuffers = 3,
  306. .modes = { STARPU_R, STARPU_R, STARPU_W },
  307. /* for the scheduling policy to be able to use performance models */
  308. .model = &mult_perf_model
  309. };
  310. \endcode
  311. </li>
  312. <li>
  313. Measured at runtime and refined by regression (model types
  314. ::STARPU_REGRESSION_BASED and ::STARPU_NL_REGRESSION_BASED). This
  315. still assumes performance regularity, but works
  316. with various data input sizes, by applying regression over observed
  317. execution times. ::STARPU_REGRESSION_BASED uses an <c>a*n^b</c> regression
  318. form, ::STARPU_NL_REGRESSION_BASED uses an <c>a*n^b+c</c> (more precise than
  319. ::STARPU_REGRESSION_BASED, but costs a lot more to compute).
  320. For instance,
  321. <c>tests/perfmodels/regression_based.c</c> uses a regression-based performance
  322. model for the function memset().
  323. Of course, the application has to issue
  324. tasks with varying size so that the regression can be computed. StarPU will not
  325. trust the regression unless there is at least 10% difference between the minimum
  326. and maximum observed input size. It can be useful to set the
  327. environment variable \ref STARPU_CALIBRATE to <c>1</c> and run the application
  328. on varying input sizes with \ref STARPU_SCHED set to <c>dmda</c> scheduler,
  329. so as to feed the performance model for a variety of
  330. inputs. The application can also provide the measurements explictly by
  331. using the function starpu_perfmodel_update_history(). The tools
  332. <c>starpu_perfmodel_display</c> and <c>starpu_perfmodel_plot</c> can
  333. be used to observe how much the performance model is calibrated
  334. (\ref PerformanceModelCalibration); when their output look good,
  335. \ref STARPU_CALIBRATE can be reset to <c>0</c> to let
  336. StarPU use the resulting performance model without recording new measures, and
  337. \ref STARPU_SCHED can be set to <c>dmda</c> to benefit from the performance models. If
  338. the data input sizes vary a lot, it is really important to set
  339. \ref STARPU_CALIBRATE to <c>0</c>, otherwise StarPU will continue adding the
  340. measures, and result with a very big performance model, which will take time a
  341. lot of time to load and save.
  342. For non-linear regression, since computing it
  343. is quite expensive, it is only done at termination of the application. This
  344. means that the first execution of the application will use only history-based
  345. performance model to perform scheduling, without using regression.
  346. </li>
  347. <li>
  348. Another type of model is ::STARPU_MULTIPLE_REGRESSION_BASED, which
  349. is based on multiple linear regression. In this model, the user
  350. defines both the relevant parameters and the equation for computing the
  351. task duration.
  352. \f[
  353. T_{kernel} = a + b(M^{\alpha_1} * N^{\beta_1} * K^{\gamma_1}) + c(M^{\alpha_2} * N^{\beta_2} * K^{\gamma_2}) + ...
  354. \f]
  355. \f$M, N, K\f$ are the parameters of the task, added at the task
  356. creation. These need to be extracted by the <c>cl_perf_func</c>
  357. function, which should be defined by the user. \f$\alpha, \beta,
  358. \gamma\f$ are the exponents defined by the user in
  359. <c>model->combinations</c> table. Finally, coefficients \f$a, b, c\f$
  360. are computed automatically by the StarPU at the end of the execution, using least
  361. squares method of the <c>dgels_</c> LAPACK function.
  362. <c>examples/mlr/mlr.c</c> example provides more details on
  363. the usage of ::STARPU_MULTIPLE_REGRESSION_BASED models.
  364. Coefficients computation is done at the end of the execution, and the
  365. results are stored in standard codelet perfmodel files. Additional
  366. files containing the duration of task together with the value of each
  367. parameter are stored in <c>.starpu/sampling/codelets/tmp/</c>
  368. directory. These files are reused when \ref STARPU_CALIBRATE
  369. environment variable is set to <c>1</c>, to recompute coefficients
  370. based on the current, but also on the previous
  371. executions. Additionally, when multiple linear regression models are
  372. disabled (using \ref disable-mlr "--disable-mlr" configure option) or when the
  373. <c>model->combinations</c> are not defined, StarPU will still write
  374. output files into <c>.starpu/sampling/codelets/tmp/</c> to allow
  375. performing an analysis. This analysis typically aims at finding the
  376. most appropriate equation for the codelet and
  377. <c>tools/starpu_mlr_analysis</c> script provides an example of how to
  378. perform such study.
  379. </li>
  380. <li>
  381. Provided as an estimation from the application itself (model type
  382. ::STARPU_COMMON and field starpu_perfmodel::cost_function),
  383. see for instance
  384. <c>examples/common/blas_model.h</c> and <c>examples/common/blas_model.c</c>.
  385. </li>
  386. <li>
  387. Provided explicitly by the application (model type ::STARPU_PER_ARCH):
  388. either field starpu_perfmodel::arch_cost_function, or
  389. the fields <c>.per_arch[arch][nimpl].cost_function</c> have to be
  390. filled with pointers to functions which return the expected duration
  391. of the task in micro-seconds, one per architecture, see for instance
  392. <c>tests/datawizard/locality.c</c>
  393. </li>
  394. </ul>
  395. For ::STARPU_HISTORY_BASED, ::STARPU_REGRESSION_BASED, and
  396. ::STARPU_NL_REGRESSION_BASED, the dimensions of task data (both input
  397. and output) are used as an index by default. ::STARPU_HISTORY_BASED uses a CRC
  398. hash of the dimensions as an index to distinguish histories, and
  399. ::STARPU_REGRESSION_BASED and ::STARPU_NL_REGRESSION_BASED use the total
  400. size as an index for the regression.
  401. The starpu_perfmodel::size_base and starpu_perfmodel::footprint fields however
  402. permit the application to override that, when for instance some of the data
  403. do not matter for task cost (e.g. mere reference table), or when using sparse
  404. structures (in which case it is the number of non-zeros which matter), or when
  405. there is some hidden parameter such as the number of iterations, or when the
  406. application actually has a very good idea of the complexity of the algorithm,
  407. and just not the speed of the processor, etc. The example in the directory
  408. <c>examples/pi</c> uses this to include the number of iterations in the base
  409. size. starpu_perfmodel::size_base should be used when the variance of the actual
  410. performance is known (i.e. bigger returned value is longer execution
  411. time), and thus particularly useful for ::STARPU_REGRESSION_BASED or
  412. ::STARPU_NL_REGRESSION_BASED. starpu_perfmodel::footprint can be used when the
  413. variance of the actual performance is unknown (irregular performance behavior,
  414. etc.), and thus only useful for ::STARPU_HISTORY_BASED.
  415. starpu_task_data_footprint() can be used as a base and combined with other
  416. parameters through starpu_hash_crc32c_be() for instance.
  417. StarPU will automatically determine when the performance model is calibrated,
  418. or rather, it will assume the performance model is calibrated until the
  419. application submits a task for which the performance can not be predicted. For
  420. ::STARPU_HISTORY_BASED, StarPU will require 10 (STARPU_CALIBRATE_MINIMUM)
  421. measurements for a given size before estimating that an average can be taken as
  422. estimation for further executions with the same size. For
  423. ::STARPU_REGRESSION_BASED and ::STARPU_NL_REGRESSION_BASED, StarPU will require
  424. 10 (STARPU_CALIBRATE_MINIMUM) measurements, and that the minimum measured
  425. data size is smaller than 90% of the maximum measured data size (i.e. the
  426. measurement interval is large enough for a regression to have a meaning).
  427. Calibration can also be forced by setting the \ref STARPU_CALIBRATE environment
  428. variable to <c>1</c>, or even reset by setting it to <c>2</c>.
  429. How to use schedulers which can benefit from such performance model is explained
  430. in \ref TaskSchedulingPolicy.
  431. The same can be done for task energy consumption estimation, by setting
  432. the field starpu_codelet::energy_model the same way as the field
  433. starpu_codelet::model. Note: for now, the application has to give to
  434. the energy consumption performance model a name which is different from
  435. the execution time performance model.
  436. The application can request time estimations from the StarPU performance
  437. models by filling a task structure as usual without actually submitting
  438. it. The data handles can be created by calling any of the functions
  439. <c>starpu_*_data_register</c> with a <c>NULL</c> pointer and <c>-1</c>
  440. node and the desired data sizes, and need to be unregistered as usual.
  441. The functions starpu_task_expected_length() and
  442. starpu_task_expected_energy() can then be called to get an estimation
  443. of the task cost on a given arch. starpu_task_footprint() can also be
  444. used to get the footprint used for indexing history-based performance
  445. models. starpu_task_destroy() needs to be called to destroy the dummy
  446. task afterwards. See <c>tests/perfmodels/regression_based.c</c> for an example.
  447. \section DataTrace Data trace and tasks length
  448. It is possible to get statistics about tasks length and data size by using :
  449. \verbatim
  450. $ starpu_fxt_data_trace filename [codelet1 codelet2 ... codeletn]
  451. \endverbatim
  452. Where filename is the FxT trace file and codeletX the names of the codelets you
  453. want to profile (if no names are specified, <c>starpu_fxt_data_trace</c> will profile them all).
  454. This will create a file, <c>data_trace.gp</c> which
  455. can be executed to get a <c>.eps</c> image of these results. On the image, each point represents a
  456. task, and each color corresponds to a codelet.
  457. \image html data_trace.png
  458. \image latex data_trace.eps "" width=\textwidth
  459. */