370_online_performance_tools.doxy 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  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][1] TOTAL: 456.000000 B 0.000435 MB 0.000188 B/s 0.000000 MB/s
  149. [starpu_comm_stats][1:0] 456.000000 B 0.000435 MB 0.000188 B/s 0.000000 MB/s
  150. [starpu_comm_stats][0] TOTAL: 456.000000 B 0.000435 MB 0.000188 B/s 0.000000 MB/s
  151. [starpu_comm_stats][0:1] 456.000000 B 0.000435 MB 0.000188 B/s 0.000000 MB/s
  152. \endverbatim
  153. These statistics can be plotted as heatmaps using StarPU tool <c>starpu_mpi_comm_matrix.py</c>
  154. \subsection StarPU-TopInterface StarPU-Top Interface
  155. StarPU-Top is an interface which remotely displays the on-line state of a StarPU
  156. application and permits the user to change parameters on the fly.
  157. Variables to be monitored can be registered by calling the functions
  158. starpu_top_add_data_boolean(), starpu_top_add_data_integer(),
  159. starpu_top_add_data_float(), e.g.:
  160. \code{.c}
  161. starpu_top_data *data = starpu_top_add_data_integer("mynum", 0, 100, 1);
  162. \endcode
  163. The application should then call starpu_top_init_and_wait() to give its name
  164. and wait for StarPU-Top to get a start request from the user. The name is used
  165. by StarPU-Top to quickly reload a previously-saved layout of parameter display.
  166. \code{.c}
  167. starpu_top_init_and_wait("the application");
  168. \endcode
  169. The new values can then be provided thanks to
  170. starpu_top_update_data_boolean(), starpu_top_update_data_integer(),
  171. starpu_top_update_data_float(), e.g.:
  172. \code{.c}
  173. starpu_top_update_data_integer(data, mynum);
  174. \endcode
  175. Updateable parameters can be registered thanks to starpu_top_register_parameter_boolean(), starpu_top_register_parameter_integer(), starpu_top_register_parameter_float(), e.g.:
  176. \code{.c}
  177. float alpha;
  178. starpu_top_register_parameter_float("alpha", &alpha, 0, 10, modif_hook);
  179. \endcode
  180. <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:
  181. \code{.c}
  182. void modif_hook(struct starpu_top_param *d)
  183. {
  184. fprintf(stderr,"%s has been modified: %f\n", d->name, alpha);
  185. }
  186. \endcode
  187. Task schedulers should notify StarPU-Top when it has decided when a task will be
  188. scheduled, so that it can show it in its Gantt chart, for instance:
  189. \code{.c}
  190. starpu_top_task_prevision(task, workerid, begin, end);
  191. \endcode
  192. Starting StarPU-Top (StarPU-Top is started via the binary
  193. <c>starpu_top</c>) and the application can be done in two ways:
  194. <ul>
  195. <li> The application is started by hand on some machine (and thus already
  196. waiting for the start event). In the Preference dialog of StarPU-Top, the SSH
  197. checkbox should be unchecked, and the hostname and port (default is 2011) on
  198. which the application is already running should be specified. Clicking on the
  199. connection button will thus connect to the already-running application.
  200. </li>
  201. <li> StarPU-Top is started first, and clicking on the connection button will
  202. start the application itself (possibly on a remote machine). The SSH checkbox
  203. should be checked, and a command line provided, e.g.:
  204. \verbatim
  205. $ ssh myserver STARPU_SCHED=dmda ./application
  206. \endverbatim
  207. If port 2011 of the remote machine can not be accessed directly, an ssh port bridge should be added:
  208. \verbatim
  209. $ ssh -L 2011:localhost:2011 myserver STARPU_SCHED=dmda ./application
  210. \endverbatim
  211. and "localhost" should be used as IP Address to connect to.
  212. </li>
  213. </ul>
  214. \section TaskAndWorkerProfiling Task And Worker Profiling
  215. A full example showing how to use the profiling API is available in
  216. the StarPU sources in the directory <c>examples/profiling/</c>.
  217. \code{.c}
  218. struct starpu_task *task = starpu_task_create();
  219. task->cl = &cl;
  220. task->synchronous = 1;
  221. /* We will destroy the task structure by hand so that we can
  222. * query the profiling info before the task is destroyed. */
  223. task->destroy = 0;
  224. /* Submit and wait for completion (since synchronous was set to 1) */
  225. starpu_task_submit(task);
  226. /* The task is finished, get profiling information */
  227. struct starpu_profiling_task_info *info = task->profiling_info;
  228. /* How much time did it take before the task started ? */
  229. double delay += starpu_timing_timespec_delay_us(&info->submit_time, &info->start_time);
  230. /* How long was the task execution ? */
  231. double length += starpu_timing_timespec_delay_us(&info->start_time, &info->end_time);
  232. /* We no longer need the task structure */
  233. starpu_task_destroy(task);
  234. \endcode
  235. \code{.c}
  236. /* Display the occupancy of all workers during the test */
  237. int worker;
  238. for (worker = 0; worker < starpu_worker_get_count(); worker++)
  239. {
  240. struct starpu_profiling_worker_info worker_info;
  241. int ret = starpu_profiling_worker_get_info(worker, &worker_info);
  242. STARPU_ASSERT(!ret);
  243. double total_time = starpu_timing_timespec_to_us(&worker_info.total_time);
  244. double executing_time = starpu_timing_timespec_to_us(&worker_info.executing_time);
  245. double sleeping_time = starpu_timing_timespec_to_us(&worker_info.sleeping_time);
  246. double overhead_time = total_time - executing_time - sleeping_time;
  247. float executing_ratio = 100.0*executing_time/total_time;
  248. float sleeping_ratio = 100.0*sleeping_time/total_time;
  249. float overhead_ratio = 100.0 - executing_ratio - sleeping_ratio;
  250. char workername[128];
  251. starpu_worker_get_name(worker, workername, 128);
  252. fprintf(stderr, "Worker %s:\n", workername);
  253. fprintf(stderr, "\ttotal time: %.2lf ms\n", total_time*1e-3);
  254. fprintf(stderr, "\texec time: %.2lf ms (%.2f %%)\n", executing_time*1e-3, executing_ratio);
  255. fprintf(stderr, "\tblocked time: %.2lf ms (%.2f %%)\n", sleeping_time*1e-3, sleeping_ratio);
  256. fprintf(stderr, "\toverhead time: %.2lf ms (%.2f %%)\n", overhead_time*1e-3, overhead_ratio);
  257. }
  258. \endcode
  259. \section PerformanceModelExample Performance Model Example
  260. To achieve good scheduling, StarPU scheduling policies need to be able to
  261. estimate in advance the duration of a task. This is done by giving to codelets
  262. a performance model, by defining a structure starpu_perfmodel and
  263. providing its address in the field starpu_codelet::model. The fields
  264. starpu_perfmodel::symbol and starpu_perfmodel::type are mandatory, to
  265. give a name to the model, and the type of the model, since there are
  266. several kinds of performance models. For compatibility, make sure to
  267. initialize the whole structure to zero, either by using explicit
  268. memset(), or by letting the compiler implicitly do it as examplified
  269. below.
  270. <ul>
  271. <li>
  272. Measured at runtime (model type ::STARPU_HISTORY_BASED). This assumes that for a
  273. given set of data input/output sizes, the performance will always be about the
  274. same. This is very true for regular kernels on GPUs for instance (<0.1% error),
  275. and just a bit less true on CPUs (~=1% error). This also assumes that there are
  276. few different sets of data input/output sizes. StarPU will then keep record of
  277. the average time of previous executions on the various processing units, and use
  278. it as an estimation. History is done per task size, by using a hash of the input
  279. and ouput sizes as an index.
  280. It will also save it in <c>$STARPU_HOME/.starpu/sampling/codelets</c>
  281. for further executions, and can be observed by using the tool
  282. <c>starpu_perfmodel_display</c>, or drawn by using
  283. the tool <c>starpu_perfmodel_plot</c> (\ref PerformanceModelCalibration). The
  284. models are indexed by machine name. To
  285. share the models between machines (e.g. for a homogeneous cluster), use
  286. <c>export STARPU_HOSTNAME=some_global_name</c>. Measurements are only done
  287. when using a task scheduler which makes use of it, such as
  288. <c>dmda</c>. Measurements can also be provided explicitly by the application, by
  289. using the function starpu_perfmodel_update_history().
  290. The following is a small code example.
  291. If e.g. the code is recompiled with other compilation options, or several
  292. variants of the code are used, the <c>symbol</c> string should be changed to reflect
  293. that, in order to recalibrate a new model from zero. The <c>symbol</c> string can even
  294. be constructed dynamically at execution time, as long as this is done before
  295. submitting any task using it.
  296. \code{.c}
  297. static struct starpu_perfmodel mult_perf_model =
  298. {
  299. .type = STARPU_HISTORY_BASED,
  300. .symbol = "mult_perf_model"
  301. };
  302. struct starpu_codelet cl =
  303. {
  304. .cpu_funcs = { cpu_mult },
  305. .cpu_funcs_name = { "cpu_mult" },
  306. .nbuffers = 3,
  307. .modes = { STARPU_R, STARPU_R, STARPU_W },
  308. /* for the scheduling policy to be able to use performance models */
  309. .model = &mult_perf_model
  310. };
  311. \endcode
  312. </li>
  313. <li>
  314. Measured at runtime and refined by regression (model types
  315. ::STARPU_REGRESSION_BASED and ::STARPU_NL_REGRESSION_BASED). This
  316. still assumes performance regularity, but works
  317. with various data input sizes, by applying regression over observed
  318. execution times. ::STARPU_REGRESSION_BASED uses an <c>a*n^b</c> regression
  319. form, ::STARPU_NL_REGRESSION_BASED uses an <c>a*n^b+c</c> (more precise than
  320. ::STARPU_REGRESSION_BASED, but costs a lot more to compute).
  321. For instance,
  322. <c>tests/perfmodels/regression_based.c</c> uses a regression-based performance
  323. model for the function memset().
  324. Of course, the application has to issue
  325. tasks with varying size so that the regression can be computed. StarPU will not
  326. trust the regression unless there is at least 10% difference between the minimum
  327. and maximum observed input size. It can be useful to set the
  328. environment variable \ref STARPU_CALIBRATE to <c>1</c> and run the application
  329. on varying input sizes with \ref STARPU_SCHED set to <c>dmda</c> scheduler,
  330. so as to feed the performance model for a variety of
  331. inputs. The application can also provide the measurements explictly by
  332. using the function starpu_perfmodel_update_history(). The tools
  333. <c>starpu_perfmodel_display</c> and <c>starpu_perfmodel_plot</c> can
  334. be used to observe how much the performance model is calibrated
  335. (\ref PerformanceModelCalibration); when their output look good,
  336. \ref STARPU_CALIBRATE can be reset to <c>0</c> to let
  337. StarPU use the resulting performance model without recording new measures, and
  338. \ref STARPU_SCHED can be set to <c>dmda</c> to benefit from the performance models. If
  339. the data input sizes vary a lot, it is really important to set
  340. \ref STARPU_CALIBRATE to <c>0</c>, otherwise StarPU will continue adding the
  341. measures, and result with a very big performance model, which will take time a
  342. lot of time to load and save.
  343. For non-linear regression, since computing it
  344. is quite expensive, it is only done at termination of the application. This
  345. means that the first execution of the application will use only history-based
  346. performance model to perform scheduling, without using regression.
  347. </li>
  348. <li>
  349. Another type of model is ::STARPU_MULTIPLE_REGRESSION_BASED, which
  350. is based on multiple linear regression. In this model, the user
  351. defines both the relevant parameters and the equation for computing the
  352. task duration.
  353. \f[
  354. T_{kernel} = a + b(M^{\alpha_1} * N^{\beta_1} * K^{\gamma_1}) + c(M^{\alpha_2} * N^{\beta_2} * K^{\gamma_2}) + ...
  355. \f]
  356. \f$M, N, K\f$ are the parameters of the task, added at the task
  357. creation. These need to be extracted by the <c>cl_perf_func</c>
  358. function, which should be defined by the user. \f$\alpha, \beta,
  359. \gamma\f$ are the exponents defined by the user in
  360. <c>model->combinations</c> table. Finally, coefficients \f$a, b, c\f$
  361. are computed automatically by the StarPU at the end of the execution, using least
  362. squares method of the <c>dgels_</c> LAPACK function.
  363. <c>examples/mlr/mlr.c</c> example provides more details on
  364. the usage of ::STARPU_MULTIPLE_REGRESSION_BASED models.
  365. Coefficients computation is done at the end of the execution, and the
  366. results are stored in standard codelet perfmodel files. Additional
  367. files containing the duration of task together with the value of each
  368. parameter are stored in <c>.starpu/sampling/codelets/tmp/</c>
  369. directory. These files are reused when \ref STARPU_CALIBRATE
  370. environment variable is set to <c>1</c>, to recompute coefficients
  371. based on the current, but also on the previous
  372. executions. Additionally, when multiple linear regression models are
  373. disabled (using \ref disable-mlr "--disable-mlr" configure option) or when the
  374. <c>model->combinations</c> are not defined, StarPU will still write
  375. output files into <c>.starpu/sampling/codelets/tmp/</c> to allow
  376. performing an analysis. This analysis typically aims at finding the
  377. most appropriate equation for the codelet and
  378. <c>tools/starpu_mlr_analysis</c> script provides an example of how to
  379. perform such study.
  380. </li>
  381. <li>
  382. Provided as an estimation from the application itself (model type
  383. ::STARPU_COMMON and field starpu_perfmodel::cost_function),
  384. see for instance
  385. <c>examples/common/blas_model.h</c> and <c>examples/common/blas_model.c</c>.
  386. </li>
  387. <li>
  388. Provided explicitly by the application (model type ::STARPU_PER_ARCH):
  389. either field starpu_perfmodel::arch_cost_function, or
  390. the fields <c>.per_arch[arch][nimpl].cost_function</c> have to be
  391. filled with pointers to functions which return the expected duration
  392. of the task in micro-seconds, one per architecture, see for instance
  393. <c>tests/datawizard/locality.c</c>
  394. </li>
  395. </ul>
  396. For ::STARPU_HISTORY_BASED, ::STARPU_REGRESSION_BASED, and
  397. ::STARPU_NL_REGRESSION_BASED, the dimensions of task data (both input
  398. and output) are used as an index by default. ::STARPU_HISTORY_BASED uses a CRC
  399. hash of the dimensions as an index to distinguish histories, and
  400. ::STARPU_REGRESSION_BASED and ::STARPU_NL_REGRESSION_BASED use the total
  401. size as an index for the regression.
  402. The starpu_perfmodel::size_base and starpu_perfmodel::footprint fields however
  403. permit the application to override that, when for instance some of the data
  404. do not matter for task cost (e.g. mere reference table), or when using sparse
  405. structures (in which case it is the number of non-zeros which matter), or when
  406. there is some hidden parameter such as the number of iterations, or when the
  407. application actually has a very good idea of the complexity of the algorithm,
  408. and just not the speed of the processor, etc. The example in the directory
  409. <c>examples/pi</c> uses this to include the number of iterations in the base
  410. size. starpu_perfmodel::size_base should be used when the variance of the actual
  411. performance is known (i.e. bigger return value is longer execution
  412. time), and thus particularly useful for ::STARPU_REGRESSION_BASED or
  413. ::STARPU_NL_REGRESSION_BASED. starpu_perfmodel::footprint can be used when the
  414. variance of the actual performance is unknown (irregular performance behavior,
  415. etc.), and thus only useful for ::STARPU_HISTORY_BASED.
  416. starpu_task_data_footprint() can be used as a base and combined with other
  417. parameters through starpu_hash_crc32c_be() for instance.
  418. StarPU will automatically determine when the performance model is calibrated,
  419. or rather, it will assume the performance model is calibrated until the
  420. application submits a task for which the performance can not be predicted. For
  421. ::STARPU_HISTORY_BASED, StarPU will require 10 (STARPU_CALIBRATE_MINIMUM)
  422. measurements for a given size before estimating that an average can be taken as
  423. estimation for further executions with the same size. For
  424. ::STARPU_REGRESSION_BASED and ::STARPU_NL_REGRESSION_BASED, StarPU will require
  425. 10 (STARPU_CALIBRATE_MINIMUM) measurements, and that the minimum measured
  426. data size is smaller than 90% of the maximum measured data size (i.e. the
  427. measurement interval is large enough for a regression to have a meaning).
  428. Calibration can also be forced by setting the \ref STARPU_CALIBRATE environment
  429. variable to <c>1</c>, or even reset by setting it to <c>2</c>.
  430. How to use schedulers which can benefit from such performance model is explained
  431. in \ref TaskSchedulingPolicy.
  432. The same can be done for task energy consumption estimation, by setting
  433. the field starpu_codelet::energy_model the same way as the field
  434. starpu_codelet::model. Note: for now, the application has to give to
  435. the energy consumption performance model a name which is different from
  436. the execution time performance model.
  437. The application can request time estimations from the StarPU performance
  438. models by filling a task structure as usual without actually submitting
  439. it. The data handles can be created by calling any of the functions
  440. <c>starpu_*_data_register</c> with a <c>NULL</c> pointer and <c>-1</c>
  441. node and the desired data sizes, and need to be unregistered as usual.
  442. The functions starpu_task_expected_length() and
  443. starpu_task_expected_energy() can then be called to get an estimation
  444. of the task cost on a given arch. starpu_task_footprint() can also be
  445. used to get the footprint used for indexing history-based performance
  446. models. starpu_task_destroy() needs to be called to destroy the dummy
  447. task afterwards. See <c>tests/perfmodels/regression_based.c</c> for an example.
  448. \section DataTrace Data trace and tasks length
  449. It is possible to get statistics about tasks length and data size by using :
  450. \verbatim
  451. $ starpu_fxt_data_trace filename [codelet1 codelet2 ... codeletn]
  452. \endverbatim
  453. Where filename is the FxT trace file and codeletX the names of the codelets you
  454. want to profile (if no names are specified, <c>starpu_fxt_data_trace</c> will profile them all).
  455. This will create a file, <c>data_trace.gp</c> which
  456. can be executed to get a <c>.eps</c> image of these results. On the image, each point represents a
  457. task, and each color corresponds to a codelet.
  458. \image html data_trace.png
  459. \image latex data_trace.eps "" width=\textwidth
  460. */