320_scheduling.doxy 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. /*! \page Scheduling Scheduling
  17. \section TaskSchedulingPolicy Task Scheduling Policies
  18. The basics of the scheduling policy are the following:
  19. <ul>
  20. <li>The scheduler gets to schedule tasks (<c>push</c> operation) when they become
  21. ready to be executed, i.e. they are not waiting for some tags, data dependencies
  22. or task dependencies.</li>
  23. <li>Workers pull tasks (<c>pop</c> operation) one by one from the scheduler.
  24. </ul>
  25. This means scheduling policies usually contain at least one queue of tasks to
  26. store them between the time when they become available, and the time when a
  27. worker gets to grab them.
  28. By default, StarPU uses the work-stealing scheduler \b lws. This is
  29. because it provides correct load balance and locality even if the application codelets do
  30. not have performance models. Other non-modelling scheduling policies can be
  31. selected among the list below, thanks to the environment variable \ref
  32. STARPU_SCHED. For instance <c>export STARPU_SCHED=dmda</c> . Use <c>help</c> to
  33. get the list of available schedulers.
  34. \subsection NonPerformanceModelingPolicies Non Performance Modelling Policies
  35. - The <b>eager</b> scheduler uses a central task queue, from which all workers draw tasks
  36. to work on concurrently. This however does not permit to prefetch data since the scheduling
  37. decision is taken late. If a task has a non-0 priority, it is put at the front of the queue.
  38. - The <b>random</b> scheduler uses a queue per worker, and distributes tasks randomly according to assumed worker
  39. overall performance.
  40. - The <b>ws</b> (work stealing) scheduler uses a queue per worker, and schedules
  41. a task on the worker which released it by
  42. default. When a worker becomes idle, it steals a task from the most loaded
  43. worker.
  44. - The <b>lws</b> (locality work stealing) scheduler uses a queue per worker, and schedules
  45. a task on the worker which released it by
  46. default. When a worker becomes idle, it steals a task from neighbour workers. It
  47. also takes into account priorities.
  48. - The <b>prio</b> scheduler also uses a central task queue, but sorts tasks by
  49. priority specified by the programmer.
  50. - The <b>heteroprio</b> scheduler uses different priorities for the different processing units.
  51. This scheduler must be configured to work correclty and to expect high-performance
  52. as described in the corresponding section.
  53. \subsection DMTaskSchedulingPolicy Performance Model-Based Task Scheduling Policies
  54. If (<b>and only if</b>) your application <b>codelets have performance models</b> (\ref
  55. PerformanceModelExample), you should change the scheduler thanks to the
  56. environment variable \ref STARPU_SCHED, to select one of the policies below, in
  57. order to take advantage of StarPU's performance modelling. For instance
  58. <c>export STARPU_SCHED=dmda</c> . Use <c>help</c> to get the list of available
  59. schedulers.
  60. <b>Note:</B> Depending on the performance model type chosen, some preliminary
  61. calibration runs may be needed for the model to converge. If the calibration
  62. has not been done, or is insufficient yet, or if no performance model is
  63. specified for a codelet, every task built from this codelet will be scheduled
  64. using an <b>eager</b> fallback policy.
  65. <b>Troubleshooting:</b> Configuring and recompiling StarPU using the \c configure option
  66. \ref enable-verbose "--enable-verbose" displays some statistics at the end of
  67. execution about the percentage of tasks which have been scheduled by a DM*
  68. family policy using performance model hints. A low or zero percentage may be
  69. the sign that performance models are not converging or that codelets do not
  70. have performance models enabled.
  71. - The <b>dm</b> (deque model) scheduler takes task execution performance models into account to
  72. perform a HEFT-similar scheduling strategy: it schedules tasks where their
  73. termination time will be minimal. The difference with HEFT is that <b>dm</b>
  74. schedules tasks as soon as they become available, and thus in the order they
  75. become available, without taking priorities into account.
  76. - The <b>dmda</b> (deque model data aware) scheduler is similar to \b dm, but it also takes
  77. into account data transfer time.
  78. - The <b>dmdap</b> (deque model data aware prio) scheduler is similar to \b dmda,
  79. except that it sorts tasks by priority order, which allows to become even closer
  80. to HEFT by respecting priorities after having made the scheduling decision (but
  81. it still schedules tasks in the order they become available).
  82. - The <b>dmdar</b> (deque model data aware ready) scheduler is similar to \b dmda,
  83. but it also privileges tasks whose data buffers are already available
  84. on the target device.
  85. - The <b>dmdas</b> combines \b dmdap and \b dmdas: it sorts tasks by priority order,
  86. but for a given priority it will privilege tasks whose data buffers are already
  87. available on the target device.
  88. - The <b>dmdasd</b> (deque model data aware sorted decision) scheduler is similar
  89. to dmdas, except that when scheduling a task, it takes into account its priority
  90. when computing the minimum completion time, since this task may get executed
  91. before others, and thus the latter should be ignored.
  92. - The <b>heft</b> (heterogeneous earliest finish time) scheduler is a deprecated
  93. alias for <b>dmda</b>.
  94. - The <b>pheft</b> (parallel HEFT) scheduler is similar to \b dmda, it also supports
  95. parallel tasks (still experimental). It should not be used when several contexts using
  96. it are being executed simultaneously.
  97. - The <b>peager</b> (parallel eager) scheduler is similar to eager, it also
  98. supports parallel tasks (still experimental). It should not be used when several
  99. contexts using it are being executed simultaneously.
  100. \subsection ExistingModularizedSchedulers Modularized Schedulers
  101. StarPU provides a powerful way to implement schedulers, as documented in \ref
  102. DefiningANewModularSchedulingPolicy . It is currently shipped with the following
  103. pre-defined Modularized Schedulers :
  104. - <b>modular-eager</b> , <b>modular-eager-prefetching</b> are eager-based Schedulers (without and with prefetching)), they are \n
  105. naive schedulers, which try to map a task on the first available resource
  106. they find. The prefetching variant queues several tasks in advance to be able to
  107. do data prefetching. This may however degrade load balancing a bit.
  108. - <b>modular-prio</b>, <b>modular-prio-prefetching</b>, <b>modular-eager-prio</b> are prio-based Schedulers (without / with prefetching):,
  109. similar to Eager-Based Schedulers. Can handle tasks which have a defined
  110. priority and schedule them accordingly.
  111. The <b>modular-eager-prio</b> variant integrates the eager and priority queue in a
  112. single component. This allows it to do a better job at pushing tasks.
  113. - <b>modular-random</b>, <b>modular-random-prio</b>, <b>modular-random-prefetching</b>, <b>modular-random-prio-prefetching</b> are random-based Schedulers (without/with prefetching) : \n
  114. Select randomly a resource to be mapped on for each task.
  115. - <b>modular-ws</b>) implements Work Stealing:
  116. Maps tasks to workers in round robin, but allows workers to steal work from other workers.
  117. - <b>modular-heft</b>, <b>modular-heft2</b>, and <b>modular-heft-prio</b> are
  118. HEFT Schedulers : \n
  119. Maps tasks to workers using a heuristic very close to
  120. Heterogeneous Earliest Finish Time.
  121. It needs that every task submitted to StarPU have a
  122. defined performance model (\ref PerformanceModelCalibration)
  123. to work efficiently, but can handle tasks without a performance
  124. model. <b>modular-heft</b> just takes tasks by order. <b>modular-heft2</b> takes
  125. at most 5 tasks of the same priority and checks which one fits best.
  126. <b>modular-heft-prio</b> is similar to <b>modular-heft</b>, but only decides the memory
  127. node, not the exact worker, just pushing tasks to one central queue per memory
  128. node. By default, they sort tasks by priorities and privilege running first
  129. a task which has most of its data already available on the target. These can
  130. however be changed with \ref STARPU_SCHED_SORTED_ABOVE, \ref
  131. STARPU_SCHED_SORTED_BELOW, and \ref STARPU_SCHED_READY .
  132. - <b>modular-heteroprio</b> is a Heteroprio Scheduler: \n
  133. Maps tasks to worker similarly to HEFT, but first attribute accelerated tasks to
  134. GPUs, then not-so-accelerated tasks to CPUs.
  135. \section TaskDistributionVsDataTransfer Task Distribution Vs Data Transfer
  136. Distributing tasks to balance the load induces data transfer penalty. StarPU
  137. thus needs to find a balance between both. The target function that the
  138. scheduler \b dmda of StarPU
  139. tries to minimize is <c>alpha * T_execution + beta * T_data_transfer</c>, where
  140. <c>T_execution</c> is the estimated execution time of the codelet (usually
  141. accurate), and <c>T_data_transfer</c> is the estimated data transfer time. The
  142. latter is estimated based on bus calibration before execution start,
  143. i.e. with an idle machine, thus without contention. You can force bus
  144. re-calibration by running the tool <c>starpu_calibrate_bus</c>. The
  145. beta parameter defaults to <c>1</c>, but it can be worth trying to tweak it
  146. by using <c>export STARPU_SCHED_BETA=2</c> (\ref STARPU_SCHED_BETA) for instance, since during
  147. real application execution, contention makes transfer times bigger.
  148. This is of course imprecise, but in practice, a rough estimation
  149. already gives the good results that a precise estimation would give.
  150. \section Energy-basedScheduling Energy-based Scheduling
  151. Note: by default StarPU does not let CPU workers sleep, to let them react to
  152. task release as quickly as possible. For idle time to really let CPU cores save
  153. energy, one needs to use the \c configure option \ref enable-blocking-drivers
  154. "--enable-blocking-drivers".
  155. If the application can provide some energy consumption performance model (through
  156. the field starpu_codelet::energy_model), StarPU will
  157. take it into account when distributing tasks. The target function that
  158. the scheduler \b dmda minimizes becomes <c>alpha * T_execution +
  159. beta * T_data_transfer + gamma * Consumption</c> , where <c>Consumption</c>
  160. is the estimated task consumption in Joules. To tune this parameter, use
  161. <c>export STARPU_SCHED_GAMMA=3000</c> (\ref STARPU_SCHED_GAMMA) for instance, to express that each Joule
  162. (i.e kW during 1000us) is worth 3000us execution time penalty. Setting
  163. <c>alpha</c> and <c>beta</c> to zero permits to only take into account energy consumption.
  164. This is however not sufficient to correctly optimize energy: the scheduler would
  165. simply tend to run all computations on the most energy-conservative processing
  166. unit. To account for the consumption of the whole machine (including idle
  167. processing units), the idle power of the machine should be given by setting
  168. <c>export STARPU_IDLE_POWER=200</c> (\ref STARPU_IDLE_POWER) for 200W, for instance. This value can often
  169. be obtained from the machine power supplier, e.g. by running
  170. \verbatim
  171. ipmitool -I lanplus -H mymachine-ipmi -U myuser -P mypasswd sdr type Current
  172. \endverbatim
  173. The energy actually consumed by the total execution can be displayed by setting
  174. <c>export STARPU_PROFILING=1 STARPU_WORKER_STATS=1</c> (\ref STARPU_PROFILING and \ref STARPU_WORKER_STATS).
  175. For OpenCL devices, on-line task consumption measurement is currently supported through the OpenCL extension
  176. <c>CL_PROFILING_POWER_CONSUMED</c>, implemented in the MoviSim simulator.
  177. For CUDA devices, on-line task consumption measurement is supported on V100
  178. cards and beyond. This however only works for quite long tasks, since the
  179. measurement granularity is about 10ms.
  180. Applications can however provide explicit measurements by using the function
  181. starpu_perfmodel_update_history() (examplified in \ref PerformanceModelExample
  182. with the performance model <c>energy_model</c>). Fine-grain measurement
  183. is often not feasible with the feedback provided by the hardware, so the
  184. user can for instance run a given task a thousand times, measure the global
  185. consumption for that series of tasks, divide it by a thousand, repeat for
  186. varying kinds of tasks and task sizes, and eventually feed StarPU with these
  187. manual measurements through starpu_perfmodel_update_history(). For instance,
  188. for CUDA devices, <c>nvidia-smi -q -d POWER</c> can be used to get the current
  189. consumption in Watt. Multiplying this value by the average duration of a
  190. single task gives the consumption of the task in Joules, which can be given to
  191. starpu_perfmodel_update_history().
  192. Another way to provide the energy performance is to define a
  193. perfmodel with starpu_perfmodel::type ::STARPU_PER_ARCH or
  194. ::STARPU_PER_WORKER , and set the field starpu_perfmodel::arch_cost_function or
  195. starpu_perfmodel::worker_cost_function to a function which shall return
  196. the estimated consumption of the task in Joules. Such a function can for instance
  197. use starpu_task_expected_length() on the task (in µs), multiplied by the
  198. typical power consumption of the device, e.g. in W, and divided by 1000000. to
  199. get Joules.
  200. \subsection MeasuringEnergyandPower Measuring energy and power with StarPU
  201. We have extended the performance model of StarPU to measure energy and power values of CPUs. These values are measured using the existing Performance API (PAPI) analysis library. PAPI provides the tool designer and application engineer with a consistent interface and methodology for use of the performance counter hardware found in most major microprocessors. PAPI enables software engineers to see, in near real time, the relation between software performance and processor events.
  202. - To measure energy consumption of CPUs, we use the <c>RAPL</c> events, which are available on CPU architecture:
  203. <c>RAPL_ENERGY_PKG</c> that represents the whole CPU socket power consumption,
  204. and <c>RAPL_ENERGY_DRAM</c> that represents the RAM power consumption.
  205. PAPI provides a generic, portable interface for the hardware performance counters available on all modern CPUs and some other components of interest that are scattered across the chip
  206. and system.
  207. In order to use the right <c>rapl events</c> for energy measurement, user should check the <c>rapl events</c> available on the machine, using this command:
  208. \verbatim
  209. $ papi_native_avail
  210. \endverbatim
  211. Depending on the system configuration, the user may have to run this as <b>root</b> to get the performance counter values.
  212. Since the measurement is for all the the CPUs and the memory, the approach taken
  213. here is to run a series of tasks on all of them and to take the overall measurement.
  214. - The example below illustrates the energy and power measurements, using the functions starpu_energy_start() and starpu_energy_stop().
  215. In this example, we launch several tasks of the same type in parallel. To perform the energy requirement measurement of a program, we call starpu_energy_start(), which initializes energy measurement counters and starpu_energy_stop(struct starpu_perfmodel *model, struct starpu_task *task, unsigned nimpl, unsigned ntasks, int workerid, enum starpu_worker_archtype archi) to stop counting and update the performance model. This ends up yielding the average energy requirement of a single task. The example below illustrates this for a given task type.
  216. \code{.c}
  217. unsigned N = starpu_cpu_worker_get_count() * 40;
  218. starpu_energy_start(-1, STARPU_CPU_WORKER);
  219. for (i = 0; i < N; i++)
  220. starpu_task_insert(&cl, STARPU_EXECUTE_WHERE, STARPU_CPU, STARPU_R, arg1, STARPU_RW, arg2, 0);
  221. starpu_task_t *specimen = starpu_task_build(&cl, STARPU_R, arg1, STARPU_RW, arg2, 0);
  222. starpu_energy_stop(&codelet.energy_model, specimen, 0, N, -1, STARPU_CPU_WORKER);
  223. . . .
  224. \endcode
  225. The example starts 40 times more tasks of the same type than there are CPU execution unit. Once the tasks are distributed over all CPUs, the latter are all executing the same type of tasks (with the same data size and parameters); each CPU will in the end execute 40 tasks. A specimen task is then constructed and passed to starpu_energy_stop(), which will fold into the performance model the energy requirement measurement for that type and size of task.
  226. For the energy and power measurements, depending on the system configuration the user may have to run applications as <b>root</b> to use PAPI library.
  227. The function starpu_energy_stop() uses <c>PAPI_stop()</c> to stop counting and store the values into the array. We calculate both energy in <c>Joules</c> and power consumption in <c>Watt</c>. We call the function starpu_perfmodel_update_history() in the perfmormance model to provide explicit measurements.
  228. - In the CUDA case, nvml provides per-GPU energy measurement. We can thus calibrate the performance models per GPU:
  229. \code{.c}
  230. unsigned N = 40;
  231. for (i = 0; i < starpu_cuda_worker_get_count(); i++) {
  232. int workerid = starpu_worker_get_by_type(STARPU_CUDA_WORKER, i);
  233. starpu_energy_start(workerid, STARPU_CUDA_WORKER);
  234. for (i = 0; i < N; i++)
  235. starpu_task_insert(&cl, STARPU_EXECUTE_ON_WORKER, workerid, STARPU_R, arg1, STARPU_RW, arg2, 0);
  236. starpu_task_t *specimen = starpu_task_build(&cl, STARPU_R, arg1, STARPU_RW, arg2, 0);
  237. starpu_energy_stop(&codelet.energy_model, specimen, 0, N, workerid, STARPU_CUDA_WORKER);
  238. }
  239. \endcode
  240. - A complete example is available in <c>tests/perfmodels/regression_based_memset.c</c>
  241. \section StaticScheduling Static Scheduling
  242. In some cases, one may want to force some scheduling, for instance force a given
  243. set of tasks to GPU0, another set to GPU1, etc. while letting some other tasks
  244. be scheduled on any other device. This can indeed be useful to guide StarPU into
  245. some work distribution, while still letting some degree of dynamism. For
  246. instance, to force execution of a task on CUDA0:
  247. \code{.c}
  248. task->execute_on_a_specific_worker = 1;
  249. task->workerid = starpu_worker_get_by_type(STARPU_CUDA_WORKER, 0);
  250. \endcode
  251. or equivalently
  252. \code{.c}
  253. starpu_task_insert(&cl, ..., STARPU_EXECUTE_ON_WORKER, starpu_worker_get_by_type(STARPU_CUDA_WORKER, 0), ...);
  254. \endcode
  255. One can also specify a set of worker(s) which are allowed to take the task, as an
  256. array of bit, for instance to allow workers 2 and 42:
  257. \code{.c}
  258. task->workerids = calloc(2,sizeof(uint32_t));
  259. task->workerids[2/32] |= (1 << (2%32));
  260. task->workerids[42/32] |= (1 << (42%32));
  261. task->workerids_len = 2;
  262. \endcode
  263. One can also specify the order in which tasks must be executed by setting the field
  264. starpu_task::workerorder. If this field is set to a non-zero value, it
  265. provides the per-worker consecutive order in which tasks will be executed,
  266. starting from 1. For a given of such task, the worker will thus not execute
  267. it before all the tasks with smaller order value have been executed, notably
  268. in case those tasks are not available yet due to some dependencies. This
  269. eventually gives total control of task scheduling, and StarPU will only serve as
  270. a "self-timed" task runtime. Of course, the provided order has to be runnable,
  271. i.e. a task should should not depend on another task bound to the same worker
  272. with a bigger order.
  273. Note however that using scheduling contexts while statically scheduling tasks on workers
  274. could be tricky. Be careful to schedule the tasks exactly on the workers of the corresponding
  275. contexts, otherwise the workers' corresponding scheduling structures may not be allocated or
  276. the execution of the application may deadlock. Moreover, the hypervisor should not be used when
  277. statically scheduling tasks.
  278. \section configuringHeteroprio Configuring Heteroprio
  279. Within Heteroprio, one priority per processing unit type is assigned to each task, such that a task has several
  280. priorities. Each worker pops the task that has the highest priority for the hardware type it uses, which
  281. could be CPU or CUDA for example. Therefore, the priorities has to be used to manage the critical path,
  282. but also to promote the consumption of tasks by the more appropriate workers.
  283. The tasks are stored inside buckets, where each bucket corresponds to a priority set. Then each
  284. worker uses an indirect access array to know the order in which it should access the buckets. Moreover,
  285. all the tasks inside a bucket must be compatible with all the processing units that may access it (at least).
  286. These priorities are now automatically assigned by Heteroprio in auto calibration mode using heuristics.
  287. If you want to set these priorities manually, you can change \ref STARPU_HETEROPRIO_USE_AUTO_CALIBRATION
  288. and follow the example below.
  289. In this example code, we have 5 types of tasks.
  290. CPU workers can compute all of them, but CUDA workers can only execute
  291. tasks of types 0 and 1, and is expected to go 20 and 30 time
  292. faster than the CPU, respectively.
  293. \code{.c}
  294. #include <starpu_heteroprio.h>
  295. // Before calling starpu_init
  296. struct starpu_conf conf;
  297. starpu_conf_init(&conf);
  298. // Inform StarPU to use Heteroprio
  299. conf.sched_policy_name = "heteroprio";
  300. // Inform StarPU about the function that will init the priorities in Heteroprio
  301. // where init_heteroprio is a function to implement
  302. conf.sched_policy_init = &init_heteroprio;
  303. // Do other things with conf if needed, then init StarPU
  304. starpu_init(&conf);
  305. \endcode
  306. \code{.c}
  307. void init_heteroprio(unsigned sched_ctx) {
  308. // CPU uses 5 buckets and visits them in the natural order
  309. starpu_heteroprio_set_nb_prios(ctx, STARPU_CPU_WORKER, 5);
  310. // It uses direct mapping idx => idx
  311. for(unsigned idx = 0; idx < 5; ++idx){
  312. starpu_heteroprio_set_mapping(ctx, STARPU_CPU_WORKER, idx, idx);
  313. // If there is no CUDA worker we must tell that CPU is faster
  314. starpu_heteroprio_set_faster_arch(ctx, STARPU_CPU_WORKER, idx);
  315. }
  316. if(starpu_cuda_worker_get_count()){
  317. // CUDA is enabled and uses 2 buckets
  318. starpu_heteroprio_set_nb_prios(ctx, STARPU_CUDA_WORKER, 2);
  319. // CUDA will first look at bucket 1
  320. starpu_heteroprio_set_mapping(ctx, STARPU_CUDA_WORKER, 0, 1);
  321. // CUDA will then look at bucket 2
  322. starpu_heteroprio_set_mapping(ctx, STARPU_CUDA_WORKER, 1, 2);
  323. // For bucket 1 CUDA is the fastest
  324. starpu_heteroprio_set_faster_arch(ctx, STARPU_CUDA_WORKER, 1);
  325. // And CPU is 30 times slower
  326. starpu_heteroprio_set_arch_slow_factor(ctx, STARPU_CPU_WORKER, 1, 30.0f);
  327. // For bucket 0 CUDA is the fastest
  328. starpu_heteroprio_set_faster_arch(ctx, STARPU_CUDA_WORKER, 0);
  329. // And CPU is 20 times slower
  330. starpu_heteroprio_set_arch_slow_factor(ctx, STARPU_CPU_WORKER, 0, 20.0f);
  331. }
  332. }
  333. \endcode
  334. Then, when a task is inserted <b>the priority of the task will be used to
  335. select in which bucket is has to be stored</b>.
  336. So, in the given example, the priority of a task will be between 0 and 4 included.
  337. However, tasks of priorities 0-1 must provide CPU and CUDA kernels, and
  338. tasks of priorities 2-4 must provide CPU kernels (at least).
  339. \subsection LAHeteroprio Using locality aware Heteroprio
  340. Heteroprio supports a mode where locality is evaluated to guide the distribution
  341. of the tasks (see https://peerj.com/articles/cs-190.pdf).
  342. Currently, this mode is available using the dedicated function or an environment variable
  343. \ref STARPU_HETEROPRIO_USE_LA, and can be configured using environment variables.
  344. \code{.c}
  345. void starpu_heteroprio_set_use_locality(unsigned sched_ctx_id, unsigned use_locality);
  346. \endcode
  347. In this mode, multiple strategies are available to determine which memory node's workers are the most qualified for executing a specific task. This strategy can be set with \ref STARPU_LAHETEROPRIO_PUSH
  348. and available strategies are:
  349. - WORKER: the worker which pushed the task is preferred for the execution.
  350. - LCs: the node with the shortest data transfer time (estimated by StarPU) is the most qualified
  351. - LS_SDH: the node with the smallest data amount to be transferred will be preferred.
  352. - LS_SDH2: similar to LS_SDH, but data in write access is counted in a quadratic manner to give them more importance.
  353. - LS_SDHB: similar to LS_SDH, but data in write access is balanced with a coefficient (its value is set to 1000) and
  354. for the same amount of data, the one with less pieces of data to be transferred will be preferred.
  355. - LC_SMWB: similar to LS_SDH, but the amount of data in write access gets multiplied by a coefficient which gets closer to 2
  356. as the amount of data in read access gets larger than the data in write access.
  357. - AUTO: strategy by default, this one selects the best strategy and changes it in runtime to improve performance
  358. Other environment variables to configure LaHeteteroprio are documented in \ref ConfiguringLaHeteroprio
  359. \subsection AutoHeteroprio Using Heteroprio in auto-calibration mode
  360. In this mode, Heteroprio saves data about each program execution, in order to improve future ones.
  361. By default, theses files are stored in the folder used by perfmodel, but this can be changed using the
  362. \ref STARPU_HETEROPRIO_DATA_DIR environment variable. You can also specify the data filename directly using
  363. \ref STARPU_HETEROPRIO_DATA_FILE.
  364. Additionally, to assign priorities to tasks, Heteroprio needs a way to detect that some tasks are similar.
  365. By default, Heteroprio looks for tasks with the same perfmodel, or with the same codelet's name if no perfmodel was assigned.
  366. This behavior can be changed to only consider the codelet's name by setting
  367. \ref STARPU_HETEROPRIO_CODELET_GROUPING_STRATEGY to <c>1</c>
  368. Other environment variables to configure AutoHeteteroprio are documented in \ref ConfiguringAutoHeteroprio
  369. */