deque_modeling_policy_data_aware.c 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  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) 2011 Télécom-SudParis
  5. * Copyright (C) 2013 Joris Pablo
  6. * Copyright (C) 2013 Simon Archipoff
  7. * Copyright (C) 2013 Thibaut Lambert
  8. * Copyright (C) 2016 Uppsala University
  9. * Copyright (C) 2020 Télécom-Sud Paris
  10. *
  11. * StarPU is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU Lesser General Public License as published by
  13. * the Free Software Foundation; either version 2.1 of the License, or (at
  14. * your option) any later version.
  15. *
  16. * StarPU is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  19. *
  20. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  21. */
  22. /* Distributed queues using performance modeling to assign tasks */
  23. #include <starpu_config.h>
  24. #include <starpu_scheduler.h>
  25. #include <common/fxt.h>
  26. #include <core/task.h>
  27. #include <core/workers.h>
  28. #include <core/sched_policy.h>
  29. #include <core/debug.h>
  30. #ifdef BUILDING_STARPU
  31. #include <datawizard/memory_nodes.h>
  32. #endif
  33. #include <sched_policies/fifo_queues.h>
  34. #include <limits.h>
  35. #include <math.h> /* for fpclassify() checks on knob values */
  36. #ifndef DBL_MIN
  37. #define DBL_MIN __DBL_MIN__
  38. #endif
  39. #ifndef DBL_MAX
  40. #define DBL_MAX __DBL_MAX__
  41. #endif
  42. //#define NOTIFY_READY_SOON
  43. struct _starpu_dmda_data
  44. {
  45. double alpha;
  46. double beta;
  47. double _gamma;
  48. double idle_power;
  49. struct _starpu_fifo_taskq queue_array[STARPU_NMAXWORKERS];
  50. long int total_task_cnt;
  51. long int ready_task_cnt;
  52. long int eager_task_cnt; /* number of tasks scheduled without model */
  53. int num_priorities;
  54. };
  55. /* performance steering knobs */
  56. /* . per-scheduler knobs */
  57. static int __s_alpha_knob;
  58. static int __s_beta_knob;
  59. static int __s_gamma_knob;
  60. static int __s_idle_power_knob;
  61. /* . knob variables */
  62. static double __s_alpha__value = 1.0;
  63. static double __s_beta__value = 1.0;
  64. static double __s_gamma__value = 1.0;
  65. static double __s_idle_power__value = 1.0;
  66. /* . per-scheduler knob group */
  67. static struct starpu_perf_knob_group * __kg_starpu_dmda__per_scheduler;
  68. static void sched_knobs__set(const struct starpu_perf_knob * const knob, void *context, const struct starpu_perf_knob_value * const value)
  69. {
  70. const char * const sched_policy_name = *(const char **)context;
  71. (void) sched_policy_name;
  72. if (knob->id == __s_alpha_knob)
  73. {
  74. STARPU_ASSERT(fpclassify(value->val_double) == FP_NORMAL);
  75. __s_alpha__value = value->val_double;
  76. }
  77. else if (knob->id == __s_beta_knob)
  78. {
  79. STARPU_ASSERT(fpclassify(value->val_double) == FP_NORMAL);
  80. __s_beta__value = value->val_double;
  81. }
  82. else if (knob->id == __s_gamma_knob)
  83. {
  84. STARPU_ASSERT(fpclassify(value->val_double) == FP_NORMAL);
  85. __s_gamma__value = value->val_double;
  86. }
  87. else if (knob->id == __s_idle_power_knob)
  88. {
  89. STARPU_ASSERT(fpclassify(value->val_double) == FP_NORMAL);
  90. __s_idle_power__value = value->val_double;
  91. }
  92. else
  93. {
  94. STARPU_ASSERT(0);
  95. abort();
  96. }
  97. }
  98. static void sched_knobs__get(const struct starpu_perf_knob * const knob, void *context, struct starpu_perf_knob_value * const value)
  99. {
  100. const char * const sched_policy_name = *(const char **)context;
  101. (void) sched_policy_name;
  102. if (knob->id == __s_alpha_knob)
  103. {
  104. value->val_double = __s_alpha__value;
  105. }
  106. else if (knob->id == __s_beta_knob)
  107. {
  108. value->val_double = __s_beta__value;
  109. }
  110. else if (knob->id == __s_gamma_knob)
  111. {
  112. value->val_double = __s_gamma__value;
  113. }
  114. else if (knob->id == __s_idle_power_knob)
  115. {
  116. value->val_double = __s_idle_power__value;
  117. }
  118. else
  119. {
  120. STARPU_ASSERT(0);
  121. abort();
  122. }
  123. }
  124. void _starpu__dmda_c__register_knobs(void)
  125. {
  126. {
  127. const enum starpu_perf_knob_scope scope = starpu_perf_knob_scope_per_scheduler;
  128. __kg_starpu_dmda__per_scheduler = _starpu_perf_knob_group_register(scope, sched_knobs__set, sched_knobs__get);
  129. /* TODO: priority capping knobs actually work globally for now, the sched policy name is ignored */
  130. __STARPU_PERF_KNOB_REG("starpu.dmda", __kg_starpu_dmda__per_scheduler, s_alpha_knob, double, "alpha constant multiplier");
  131. __STARPU_PERF_KNOB_REG("starpu.dmda", __kg_starpu_dmda__per_scheduler, s_beta_knob, double, "beta constant multiplier");
  132. __STARPU_PERF_KNOB_REG("starpu.dmda", __kg_starpu_dmda__per_scheduler, s_gamma_knob, double, "gamma constant multiplier");
  133. __STARPU_PERF_KNOB_REG("starpu.dmda", __kg_starpu_dmda__per_scheduler, s_idle_power_knob, double, "idle_power constant multiplier");
  134. }
  135. }
  136. void _starpu__dmda_c__unregister_knobs(void)
  137. {
  138. _starpu_perf_knob_group_unregister(__kg_starpu_dmda__per_scheduler);
  139. __kg_starpu_dmda__per_scheduler = NULL;
  140. }
  141. /* The dmda scheduling policy uses
  142. *
  143. * alpha * T_computation + beta * T_communication + gamma * Consumption
  144. *
  145. * Here are the default values of alpha, beta, gamma
  146. */
  147. #define _STARPU_SCHED_ALPHA_DEFAULT 1.0
  148. #define _STARPU_SCHED_BETA_DEFAULT 1.0
  149. #define _STARPU_SCHED_GAMMA_DEFAULT 1000.0
  150. /* This is called when a transfer request is actually pushed to the worker */
  151. static void _starpu_fifo_task_transfer_started(struct _starpu_fifo_taskq *fifo, struct starpu_task *task, int num_priorities)
  152. {
  153. double transfer_model = task->predicted_transfer;
  154. if (isnan(transfer_model))
  155. return;
  156. /* We now start the transfer, move it from predicted to pipelined */
  157. fifo->exp_len -= transfer_model;
  158. fifo->pipeline_len += transfer_model;
  159. fifo->exp_start = starpu_timing_now() + fifo->pipeline_len;
  160. fifo->exp_end = fifo->exp_start + fifo->exp_len;
  161. if(num_priorities != -1)
  162. {
  163. int i;
  164. int task_prio = _starpu_normalize_prio(task->priority, num_priorities, task->sched_ctx);
  165. for(i = 0; i <= task_prio; i++)
  166. fifo->exp_len_per_priority[i] -= transfer_model;
  167. }
  168. }
  169. /* This is called when a task is actually pushed to the worker (i.e. the transfer finished */
  170. static void _starpu_fifo_task_started(struct _starpu_fifo_taskq *fifo, struct starpu_task *task, int num_priorities)
  171. {
  172. double model = task->predicted;
  173. double transfer_model = task->predicted_transfer;
  174. if(!isnan(transfer_model))
  175. /* The transfer is over, remove it from pipelined */
  176. fifo->pipeline_len -= transfer_model;
  177. if(!isnan(model))
  178. {
  179. /* We now start the computation, move it from predicted to pipelined */
  180. fifo->exp_len -= model;
  181. fifo->pipeline_len += model;
  182. fifo->exp_start = starpu_timing_now() + fifo->pipeline_len;
  183. fifo->exp_end= fifo->exp_start + fifo->exp_len;
  184. if(num_priorities != -1)
  185. {
  186. int i;
  187. int task_prio = _starpu_normalize_prio(task->priority, num_priorities, task->sched_ctx);
  188. for(i = 0; i <= task_prio; i++)
  189. fifo->exp_len_per_priority[i] -= model;
  190. }
  191. }
  192. }
  193. /* This is called when a task is actually finished */
  194. static void _starpu_fifo_task_finished(struct _starpu_fifo_taskq *fifo, struct starpu_task *task, int num_priorities STARPU_ATTRIBUTE_UNUSED)
  195. {
  196. if(!isnan(task->predicted))
  197. /* The execution is over, remove it from pipelined */
  198. fifo->pipeline_len -= task->predicted;
  199. fifo->exp_start = STARPU_MAX(starpu_timing_now() + fifo->pipeline_len, fifo->exp_start);
  200. fifo->exp_end = fifo->exp_start + fifo->exp_len;
  201. }
  202. static struct starpu_task *_dmda_pop_task(unsigned sched_ctx_id, int ready)
  203. {
  204. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  205. struct starpu_task *task;
  206. unsigned workerid = starpu_worker_get_id_check();
  207. struct _starpu_fifo_taskq *fifo = &dt->queue_array[workerid];
  208. /* Take the opportunity to update start time */
  209. fifo->exp_start = STARPU_MAX(starpu_timing_now(), fifo->exp_start);
  210. fifo->exp_end = fifo->exp_start + fifo->exp_len;
  211. STARPU_ASSERT_MSG(fifo, "worker %u does not belong to ctx %u anymore.\n", workerid, sched_ctx_id);
  212. if (ready)
  213. task = _starpu_fifo_pop_first_ready_task(fifo, workerid, dt->num_priorities);
  214. else
  215. task = _starpu_fifo_pop_local_task(fifo);
  216. if (task)
  217. {
  218. _starpu_fifo_task_transfer_started(fifo, task, dt->num_priorities);
  219. starpu_sched_ctx_list_task_counters_decrement(sched_ctx_id, workerid);
  220. #ifdef STARPU_VERBOSE
  221. if (task->cl)
  222. {
  223. int non_ready = _starpu_count_non_ready_buffers(task, workerid);
  224. if (non_ready == 0)
  225. dt->ready_task_cnt++;
  226. }
  227. dt->total_task_cnt++;
  228. #endif
  229. }
  230. return task;
  231. }
  232. static struct starpu_task *dmda_pop_ready_task(unsigned sched_ctx_id)
  233. {
  234. return _dmda_pop_task(sched_ctx_id, 1);
  235. }
  236. static struct starpu_task *dmda_pop_task(unsigned sched_ctx_id)
  237. {
  238. return _dmda_pop_task(sched_ctx_id, 0);
  239. }
  240. static struct starpu_task *dmda_pop_every_task(unsigned sched_ctx_id)
  241. {
  242. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  243. struct starpu_task *new_list, *task;
  244. unsigned workerid = starpu_worker_get_id_check();
  245. struct _starpu_fifo_taskq *fifo = &dt->queue_array[workerid];
  246. /* Take the opportunity to update start time */
  247. fifo->exp_start = STARPU_MAX(starpu_timing_now(), fifo->exp_start);
  248. fifo->exp_end = fifo->exp_start + fifo->exp_len;
  249. starpu_worker_lock_self();
  250. new_list = _starpu_fifo_pop_every_task(fifo, workerid);
  251. starpu_worker_unlock_self();
  252. starpu_sched_ctx_list_task_counters_reset(sched_ctx_id, workerid);
  253. for (task = new_list; task; task = task->next)
  254. _starpu_fifo_task_transfer_started(fifo, task, dt->num_priorities);
  255. return new_list;
  256. }
  257. static int push_task_on_best_worker(struct starpu_task *task, int best_workerid,
  258. double predicted, double predicted_transfer,
  259. int prio, unsigned sched_ctx_id)
  260. {
  261. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  262. /* make sure someone could execute that task ! */
  263. STARPU_ASSERT(best_workerid != -1);
  264. if (_starpu_get_nsched_ctxs() > 1)
  265. {
  266. starpu_worker_relax_on();
  267. _starpu_sched_ctx_lock_write(sched_ctx_id);
  268. starpu_worker_relax_off();
  269. if (_starpu_sched_ctx_worker_is_master_for_child_ctx(sched_ctx_id, best_workerid, task))
  270. task = NULL;
  271. _starpu_sched_ctx_unlock_write(sched_ctx_id);
  272. if (!task)
  273. return 0;
  274. }
  275. struct _starpu_fifo_taskq *fifo = &dt->queue_array[best_workerid];
  276. double now = starpu_timing_now();
  277. #ifdef STARPU_USE_SC_HYPERVISOR
  278. starpu_sched_ctx_call_pushed_task_cb(best_workerid, sched_ctx_id);
  279. #endif //STARPU_USE_SC_HYPERVISOR
  280. starpu_worker_lock(best_workerid);
  281. /* Sometimes workers didn't take the tasks as early as we expected */
  282. fifo->exp_start = isnan(fifo->exp_start) ? now + fifo->pipeline_len : STARPU_MAX(fifo->exp_start, now);
  283. fifo->exp_end = fifo->exp_start + fifo->exp_len;
  284. if ((now + predicted_transfer) < fifo->exp_end)
  285. {
  286. /* We may hope that the transfer will be finished by
  287. * the start of the task. */
  288. predicted_transfer = 0.0;
  289. }
  290. else
  291. {
  292. /* The transfer will not be finished by then, take the
  293. * remainder into account */
  294. predicted_transfer = (now + predicted_transfer) - fifo->exp_end;
  295. }
  296. if(!isnan(predicted_transfer))
  297. {
  298. fifo->exp_len += predicted_transfer;
  299. if(dt->num_priorities != -1)
  300. {
  301. int i;
  302. int task_prio = _starpu_normalize_prio(task->priority, dt->num_priorities, task->sched_ctx);
  303. for(i = 0; i <= task_prio; i++)
  304. fifo->exp_len_per_priority[i] += predicted_transfer;
  305. }
  306. }
  307. if(!isnan(predicted))
  308. {
  309. fifo->exp_len += predicted;
  310. if(dt->num_priorities != -1)
  311. {
  312. int i;
  313. int task_prio = _starpu_normalize_prio(task->priority, dt->num_priorities, task->sched_ctx);
  314. for(i = 0; i <= task_prio; i++)
  315. fifo->exp_len_per_priority[i] += predicted;
  316. }
  317. }
  318. fifo->exp_end = fifo->exp_start + fifo->exp_len;
  319. starpu_worker_unlock(best_workerid);
  320. task->predicted = predicted;
  321. task->predicted_transfer = predicted_transfer;
  322. if (starpu_get_prefetch_flag())
  323. starpu_prefetch_task_input_for(task, best_workerid);
  324. STARPU_AYU_ADDTOTASKQUEUE(starpu_task_get_job_id(task), best_workerid);
  325. if (_starpu_get_nsched_ctxs() > 1)
  326. {
  327. unsigned stream_ctx_id = starpu_worker_get_sched_ctx_id_stream(best_workerid);
  328. if(stream_ctx_id != STARPU_NMAX_SCHED_CTXS)
  329. {
  330. starpu_worker_relax_on();
  331. _starpu_sched_ctx_lock_write(sched_ctx_id);
  332. starpu_worker_relax_off();
  333. starpu_sched_ctx_move_task_to_ctx_locked(task, stream_ctx_id, 0);
  334. starpu_sched_ctx_revert_task_counters_ctx_locked(sched_ctx_id, task->flops);
  335. _starpu_sched_ctx_unlock_write(sched_ctx_id);
  336. }
  337. }
  338. int ret = 0;
  339. if (prio)
  340. {
  341. starpu_worker_lock(best_workerid);
  342. ret =_starpu_fifo_push_sorted_task(&dt->queue_array[best_workerid], task);
  343. if(dt->num_priorities != -1)
  344. {
  345. int i;
  346. int task_prio = _starpu_normalize_prio(task->priority, dt->num_priorities, task->sched_ctx);
  347. for(i = 0; i <= task_prio; i++)
  348. dt->queue_array[best_workerid].ntasks_per_priority[i]++;
  349. }
  350. #if !defined(STARPU_NON_BLOCKING_DRIVERS) || defined(STARPU_SIMGRID)
  351. starpu_wake_worker_locked(best_workerid);
  352. #endif
  353. starpu_push_task_end(task);
  354. starpu_worker_unlock(best_workerid);
  355. }
  356. else
  357. {
  358. starpu_worker_lock(best_workerid);
  359. starpu_task_list_push_back (&dt->queue_array[best_workerid].taskq, task);
  360. dt->queue_array[best_workerid].ntasks++;
  361. dt->queue_array[best_workerid].nprocessed++;
  362. #if !defined(STARPU_NON_BLOCKING_DRIVERS) || defined(STARPU_SIMGRID)
  363. starpu_wake_worker_locked(best_workerid);
  364. #endif
  365. starpu_push_task_end(task);
  366. starpu_worker_unlock(best_workerid);
  367. }
  368. starpu_sched_ctx_list_task_counters_increment(sched_ctx_id, best_workerid);
  369. return ret;
  370. }
  371. /* TODO: factorise CPU computations, expensive with a lot of cores */
  372. static void compute_all_performance_predictions(struct starpu_task *task,
  373. unsigned nworkers,
  374. double local_task_length[nworkers][STARPU_MAXIMPLEMENTATIONS],
  375. double exp_end[nworkers][STARPU_MAXIMPLEMENTATIONS],
  376. double *max_exp_endp_of_workers,
  377. double *min_exp_endp_of_task,
  378. double local_data_penalty[nworkers][STARPU_MAXIMPLEMENTATIONS],
  379. double local_energy[nworkers][STARPU_MAXIMPLEMENTATIONS],
  380. int *forced_worker, int *forced_impl, unsigned sched_ctx_id, unsigned sorted_decision)
  381. {
  382. int calibrating = 0;
  383. double max_exp_end_of_workers = DBL_MIN;
  384. double best_exp_end_of_task = DBL_MAX;
  385. int ntasks_best = -1;
  386. int nimpl_best = 0;
  387. double ntasks_best_end = 0.0;
  388. /* A priori, we know all estimations */
  389. int unknown = 0;
  390. unsigned worker_ctx = 0;
  391. int task_prio = 0;
  392. starpu_task_bundle_t bundle = task->bundle;
  393. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  394. if(sorted_decision && dt->num_priorities != -1)
  395. task_prio = _starpu_normalize_prio(task->priority, dt->num_priorities, sched_ctx_id);
  396. struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
  397. double now = starpu_timing_now();
  398. struct starpu_sched_ctx_iterator it;
  399. workers->init_iterator_for_parallel_tasks(workers, &it, task);
  400. while(worker_ctx<nworkers && workers->has_next(workers, &it))
  401. {
  402. unsigned nimpl;
  403. unsigned impl_mask;
  404. unsigned workerid = workers->get_next(workers, &it);
  405. struct _starpu_fifo_taskq *fifo = &dt->queue_array[workerid];
  406. struct starpu_perfmodel_arch* perf_arch = starpu_worker_get_perf_archtype(workerid, sched_ctx_id);
  407. unsigned memory_node = starpu_worker_get_memory_node(workerid);
  408. STARPU_ASSERT_MSG(fifo != NULL, "workerid %u ctx %u\n", workerid, sched_ctx_id);
  409. /* Sometimes workers didn't take the tasks as early as we expected */
  410. double exp_start = isnan(fifo->exp_start) ? now + fifo->pipeline_len : STARPU_MAX(fifo->exp_start, now);
  411. if (!starpu_worker_can_execute_task_impl(workerid, task, &impl_mask))
  412. continue;
  413. for (nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
  414. {
  415. if (!(impl_mask & (1U << nimpl)))
  416. {
  417. /* no one on that queue may execute this task */
  418. continue;
  419. }
  420. int fifo_ntasks = fifo->ntasks;
  421. double prev_exp_len = fifo->exp_len;
  422. /* consider the priority of the task when deciding on which workerid to schedule,
  423. compute the expected_end of the task if it is inserted before other tasks already scheduled */
  424. if(sorted_decision)
  425. {
  426. if(dt->num_priorities != -1)
  427. {
  428. prev_exp_len = fifo->exp_len_per_priority[task_prio];
  429. fifo_ntasks = fifo->ntasks_per_priority[task_prio];
  430. }
  431. else
  432. {
  433. starpu_worker_lock(workerid);
  434. prev_exp_len = _starpu_fifo_get_exp_len_prev_task_list(fifo, task, workerid, nimpl, &fifo_ntasks);
  435. starpu_worker_unlock(workerid);
  436. }
  437. }
  438. exp_end[worker_ctx][nimpl] = exp_start + prev_exp_len;
  439. if (exp_end[worker_ctx][nimpl] > max_exp_end_of_workers)
  440. max_exp_end_of_workers = exp_end[worker_ctx][nimpl];
  441. //_STARPU_DEBUG("Scheduler dmda: task length (%lf) workerid (%u) kernel (%u) \n", local_task_length[workerid][nimpl],workerid,nimpl);
  442. if (bundle)
  443. {
  444. /* TODO : conversion time */
  445. local_task_length[worker_ctx][nimpl] = starpu_task_bundle_expected_length(bundle, perf_arch, nimpl);
  446. if (local_data_penalty)
  447. local_data_penalty[worker_ctx][nimpl] = starpu_task_bundle_expected_data_transfer_time(bundle, memory_node);
  448. if (local_energy)
  449. local_energy[worker_ctx][nimpl] = starpu_task_bundle_expected_energy(bundle, perf_arch,nimpl);
  450. }
  451. else
  452. {
  453. local_task_length[worker_ctx][nimpl] = starpu_task_worker_expected_length(task, workerid, sched_ctx_id, nimpl);
  454. if (local_data_penalty)
  455. local_data_penalty[worker_ctx][nimpl] = starpu_task_expected_data_transfer_time_for(task, workerid);
  456. if (local_energy)
  457. local_energy[worker_ctx][nimpl] = starpu_task_worker_expected_energy(task, workerid, sched_ctx_id,nimpl);
  458. double conversion_time = starpu_task_expected_conversion_time(task, perf_arch, nimpl);
  459. if (conversion_time > 0.0)
  460. local_task_length[worker_ctx][nimpl] += conversion_time;
  461. }
  462. double ntasks_end = fifo_ntasks / starpu_worker_get_relative_speedup(perf_arch);
  463. /*
  464. * This implements a default greedy scheduler for the
  465. * case of tasks which have no performance model, or
  466. * whose performance model is not calibrated yet.
  467. *
  468. * It simply uses the number of tasks already pushed to
  469. * the workers, divided by the relative performance of
  470. * a CPU and of a GPU.
  471. *
  472. * This is always computed, but the ntasks_best
  473. * selection is only really used if the task indeed has
  474. * no performance model, or is not calibrated yet.
  475. */
  476. if (ntasks_best == -1
  477. /* Always compute the greedy decision, at least for
  478. * the tasks with no performance model. */
  479. || (!calibrating && ntasks_end < ntasks_best_end)
  480. /* The performance model of this task is not
  481. * calibrated on this workerid, try to run it there
  482. * to calibrate it there. */
  483. || (!calibrating && isnan(local_task_length[worker_ctx][nimpl]))
  484. /* the performance model of this task is not
  485. * calibrated on this workerid either, rather run it
  486. * there if this one is low on scheduled tasks. */
  487. || (calibrating && isnan(local_task_length[worker_ctx][nimpl]) && ntasks_end < ntasks_best_end)
  488. )
  489. {
  490. ntasks_best_end = ntasks_end;
  491. ntasks_best = workerid;
  492. nimpl_best = nimpl;
  493. }
  494. if (isnan(local_task_length[worker_ctx][nimpl]))
  495. /* we are calibrating, we want to speed-up calibration time
  496. * so we privilege non-calibrated tasks (but still
  497. * greedily distribute them to avoid dumb schedules) */
  498. calibrating = 1;
  499. if (isnan(local_task_length[worker_ctx][nimpl])
  500. || _STARPU_IS_ZERO(local_task_length[worker_ctx][nimpl]))
  501. /* there is no prediction available for that task
  502. * with that arch (yet or at all), so switch to a greedy strategy */
  503. unknown = 1;
  504. if (unknown)
  505. continue;
  506. double task_starting_time = exp_start + prev_exp_len;
  507. if (local_data_penalty)
  508. task_starting_time = STARPU_MAX(task_starting_time,
  509. now + local_data_penalty[worker_ctx][nimpl]);
  510. exp_end[worker_ctx][nimpl] = task_starting_time + local_task_length[worker_ctx][nimpl];
  511. if (exp_end[worker_ctx][nimpl] < best_exp_end_of_task)
  512. {
  513. /* a better solution was found */
  514. best_exp_end_of_task = exp_end[worker_ctx][nimpl];
  515. nimpl_best = nimpl;
  516. }
  517. if (local_energy)
  518. if (isnan(local_energy[worker_ctx][nimpl]))
  519. local_energy[worker_ctx][nimpl] = 0.;
  520. }
  521. worker_ctx++;
  522. }
  523. *forced_worker = unknown?ntasks_best:-1;
  524. *forced_impl = unknown?nimpl_best:-1;
  525. #ifdef STARPU_VERBOSE
  526. if (unknown)
  527. {
  528. dt->eager_task_cnt++;
  529. }
  530. #endif
  531. *min_exp_endp_of_task = best_exp_end_of_task;
  532. *max_exp_endp_of_workers = max_exp_end_of_workers;
  533. }
  534. static double _dmda_push_task(struct starpu_task *task, unsigned prio, unsigned sched_ctx_id, unsigned da, unsigned simulate, unsigned sorted_decision)
  535. {
  536. /* find the queue */
  537. int best = -1, best_in_ctx = -1;
  538. int selected_impl = 0;
  539. double model_best = 0.0;
  540. double transfer_model_best = 0.0;
  541. /* this flag is set if the corresponding worker is selected because
  542. there is no performance prediction available yet */
  543. int forced_best = -1;
  544. int forced_impl = -1;
  545. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  546. struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
  547. unsigned nworkers_ctx = workers->nworkers;
  548. double local_task_length[nworkers_ctx][STARPU_MAXIMPLEMENTATIONS];
  549. double local_data_penalty[nworkers_ctx][STARPU_MAXIMPLEMENTATIONS];
  550. double local_energy[nworkers_ctx][STARPU_MAXIMPLEMENTATIONS];
  551. /* Expected end of this task on the workers */
  552. double exp_end[nworkers_ctx][STARPU_MAXIMPLEMENTATIONS];
  553. /* This is the minimum among the exp_end[] matrix */
  554. double min_exp_end_of_task;
  555. /* This is the maximum termination time of already-scheduled tasks over all workers */
  556. double max_exp_end_of_workers = 0.0;
  557. double fitness[nworkers_ctx][STARPU_MAXIMPLEMENTATIONS];
  558. compute_all_performance_predictions(task,
  559. nworkers_ctx,
  560. local_task_length,
  561. exp_end,
  562. &max_exp_end_of_workers,
  563. &min_exp_end_of_task,
  564. da ? local_data_penalty : NULL,
  565. da ? local_energy : NULL,
  566. &forced_best,
  567. &forced_impl, sched_ctx_id, sorted_decision);
  568. if (forced_best == -1)
  569. {
  570. double best_fitness = -1;
  571. unsigned worker_ctx = 0;
  572. struct starpu_sched_ctx_iterator it;
  573. workers->init_iterator_for_parallel_tasks(workers, &it, task);
  574. while(worker_ctx < nworkers_ctx && workers->has_next(workers, &it))
  575. {
  576. unsigned worker = workers->get_next(workers, &it);
  577. unsigned nimpl;
  578. unsigned impl_mask;
  579. if (!starpu_worker_can_execute_task_impl(worker, task, &impl_mask))
  580. continue;
  581. for (nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
  582. {
  583. if (!(impl_mask & (1U << nimpl)))
  584. {
  585. /* no one on that queue may execute this task */
  586. continue;
  587. }
  588. if (da)
  589. fitness[worker_ctx][nimpl] = dt->alpha * __s_alpha__value *(exp_end[worker_ctx][nimpl] - min_exp_end_of_task)
  590. + dt->beta * __s_beta__value *(local_data_penalty[worker_ctx][nimpl])
  591. + dt->_gamma * __s_gamma__value *(local_energy[worker_ctx][nimpl]);
  592. else
  593. fitness[worker_ctx][nimpl] = exp_end[worker_ctx][nimpl] - min_exp_end_of_task;
  594. if (da && exp_end[worker_ctx][nimpl] > max_exp_end_of_workers)
  595. {
  596. /* This placement will make the computation
  597. * longer, take into account the idle
  598. * consumption of other cpus */
  599. fitness[worker_ctx][nimpl] += dt->_gamma * __s_gamma__value * dt->idle_power * __s_idle_power__value * (exp_end[worker_ctx][nimpl] - max_exp_end_of_workers) / 1000000.0; /* Since gamma is the cost in us of one Joules,
  600. then d->idle_power * (exp_end - max_exp_end_of_workers)
  601. must be in Joules, thus the / 1000000.0 */
  602. }
  603. if (best == -1 || fitness[worker_ctx][nimpl] < best_fitness)
  604. {
  605. /* we found a better solution */
  606. best_fitness = fitness[worker_ctx][nimpl];
  607. best = worker;
  608. best_in_ctx = worker_ctx;
  609. selected_impl = nimpl;
  610. //_STARPU_DEBUG("best fitness (worker %d) %e = alpha*(%e) + beta(%e) +gamma(%e)\n", worker, best_fitness, exp_end[worker][nimpl] - min_exp_end_of_task, local_data_penalty[worker][nimpl], local_energy[worker][nimpl]);
  611. }
  612. }
  613. worker_ctx++;
  614. }
  615. }
  616. STARPU_ASSERT(forced_best != -1 || best != -1);
  617. if (forced_best != -1)
  618. {
  619. /* there is no prediction available for that task
  620. * with that arch we want to speed-up calibration time
  621. * so we force this measurement */
  622. best = forced_best;
  623. selected_impl = forced_impl;
  624. model_best = 0.0;
  625. transfer_model_best = 0.0;
  626. }
  627. else if (task->bundle)
  628. {
  629. struct starpu_perfmodel_arch* perf_arch = starpu_worker_get_perf_archtype(best_in_ctx, sched_ctx_id);
  630. unsigned memory_node = starpu_worker_get_memory_node(best);
  631. model_best = starpu_task_expected_length(task, perf_arch, selected_impl);
  632. if (da)
  633. transfer_model_best = starpu_task_expected_data_transfer_time(memory_node, task);
  634. }
  635. else
  636. {
  637. model_best = local_task_length[best_in_ctx][selected_impl];
  638. if (da)
  639. transfer_model_best = local_data_penalty[best_in_ctx][selected_impl];
  640. }
  641. //_STARPU_DEBUG("Scheduler dmda: kernel (%u)\n", selected_impl);
  642. starpu_task_set_implementation(task, selected_impl);
  643. starpu_sched_task_break(task);
  644. if(!simulate)
  645. {
  646. /* we should now have the best worker in variable "best" */
  647. return push_task_on_best_worker(task, best, model_best, transfer_model_best, prio, sched_ctx_id);
  648. }
  649. else
  650. {
  651. return exp_end[best_in_ctx][selected_impl] ;
  652. }
  653. }
  654. static int dmda_push_sorted_decision_task(struct starpu_task *task)
  655. {
  656. return _dmda_push_task(task, 1, task->sched_ctx, 1, 0, 1);
  657. }
  658. static int dmda_push_sorted_task(struct starpu_task *task)
  659. {
  660. #ifdef STARPU_DEVEL
  661. #warning TODO: after defining a scheduling window, use that instead of empty_ctx_tasks
  662. #endif
  663. return _dmda_push_task(task, 1, task->sched_ctx, 1, 0, 0);
  664. }
  665. static int dm_push_task(struct starpu_task *task)
  666. {
  667. return _dmda_push_task(task, 0, task->sched_ctx, 0, 0, 0);
  668. }
  669. static int dm_simulate_push_task(struct starpu_task *task)
  670. {
  671. return _dmda_push_task(task, 0, task->sched_ctx, 0, 1, 0);
  672. }
  673. static int dmda_push_task(struct starpu_task *task)
  674. {
  675. STARPU_ASSERT(task);
  676. return _dmda_push_task(task, 0, task->sched_ctx, 1, 0, 0);
  677. }
  678. static double dmda_simulate_push_task(struct starpu_task *task)
  679. {
  680. STARPU_ASSERT(task);
  681. return _dmda_push_task(task, 0, task->sched_ctx, 1, 1, 0);
  682. }
  683. static double dmda_simulate_push_sorted_task(struct starpu_task *task)
  684. {
  685. STARPU_ASSERT(task);
  686. return _dmda_push_task(task, 1, task->sched_ctx, 1, 1, 0);
  687. }
  688. static double dmda_simulate_push_sorted_decision_task(struct starpu_task *task)
  689. {
  690. STARPU_ASSERT(task);
  691. return _dmda_push_task(task, 1, task->sched_ctx, 1, 1, 1);
  692. }
  693. #ifdef NOTIFY_READY_SOON
  694. static void dmda_notify_ready_soon(void *data STARPU_ATTRIBUTE_UNUSED, struct starpu_task *task, double delay)
  695. {
  696. if (!task->cl)
  697. return;
  698. /* fprintf(stderr, "task %lu %p %p %s %s will be ready within %f\n", starpu_task_get_job_id(task), task, task->cl, task->cl->name, task->cl->model?task->cl->model->symbol : NULL, delay); */
  699. /* TODO: do something with it */
  700. }
  701. #endif
  702. static void dmda_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
  703. {
  704. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  705. unsigned i;
  706. for (i = 0; i < nworkers; i++)
  707. {
  708. struct _starpu_fifo_taskq *q;
  709. int workerid = workerids[i];
  710. /* if the worker has alreadry belonged to this context
  711. the queue and the synchronization variables have been already initialized */
  712. q = &dt->queue_array[workerid];
  713. _starpu_init_fifo(q);
  714. /* These are only stats, they can be read with races */
  715. STARPU_HG_DISABLE_CHECKING(q->exp_start);
  716. STARPU_HG_DISABLE_CHECKING(q->exp_len);
  717. STARPU_HG_DISABLE_CHECKING(q->exp_end);
  718. if(dt->num_priorities != -1)
  719. {
  720. _STARPU_MALLOC(q->exp_len_per_priority, dt->num_priorities*sizeof(double));
  721. _STARPU_MALLOC(q->ntasks_per_priority, dt->num_priorities*sizeof(unsigned));
  722. int j;
  723. for(j = 0; j < dt->num_priorities; j++)
  724. {
  725. q->exp_len_per_priority[j] = 0.0;
  726. q->ntasks_per_priority[j] = 0;
  727. }
  728. }
  729. }
  730. }
  731. static void dmda_remove_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
  732. {
  733. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  734. unsigned i;
  735. for (i = 0; i < nworkers; i++)
  736. {
  737. int workerid = workerids[i];
  738. if(dt->num_priorities != -1)
  739. {
  740. free(dt->queue_array[workerid].exp_len_per_priority);
  741. free(dt->queue_array[workerid].ntasks_per_priority);
  742. }
  743. }
  744. }
  745. static void initialize_dmda_policy(unsigned sched_ctx_id)
  746. {
  747. struct _starpu_dmda_data *dt;
  748. _STARPU_CALLOC(dt, 1, sizeof(struct _starpu_dmda_data));
  749. starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)dt);
  750. dt->alpha = starpu_get_env_float_default("STARPU_SCHED_ALPHA", _STARPU_SCHED_ALPHA_DEFAULT);
  751. dt->beta = starpu_get_env_float_default("STARPU_SCHED_BETA", _STARPU_SCHED_BETA_DEFAULT);
  752. /* data->_gamma: cost of one Joule in us. If gamma is set to 10^6, then one Joule cost 1s */
  753. #ifdef STARPU_NON_BLOCKING_DRIVERS
  754. if (starpu_getenv("STARPU_SCHED_GAMMA"))
  755. _STARPU_DISP("Warning: STARPU_SCHED_GAMMA was used, but --enable-blocking-drivers configuration was not set, CPU cores will not actually be sleeping\n");
  756. #endif
  757. dt->_gamma = starpu_get_env_float_default("STARPU_SCHED_GAMMA", _STARPU_SCHED_GAMMA_DEFAULT);
  758. /* data->idle_power: Idle power of the whole machine in Watt */
  759. dt->idle_power = starpu_get_env_float_default("STARPU_IDLE_POWER", 0.0);
  760. if(starpu_sched_ctx_min_priority_is_set(sched_ctx_id) != 0 && starpu_sched_ctx_max_priority_is_set(sched_ctx_id) != 0)
  761. dt->num_priorities = starpu_sched_ctx_get_max_priority(sched_ctx_id) - starpu_sched_ctx_get_min_priority(sched_ctx_id) + 1;
  762. else
  763. dt->num_priorities = -1;
  764. #ifdef NOTIFY_READY_SOON
  765. starpu_task_notify_ready_soon_register(dmda_notify_ready_soon, dt);
  766. #endif
  767. }
  768. static void initialize_dmda_sorted_policy(unsigned sched_ctx_id)
  769. {
  770. initialize_dmda_policy(sched_ctx_id);
  771. /* The application may use any integer */
  772. if (starpu_sched_ctx_min_priority_is_set(sched_ctx_id) == 0)
  773. starpu_sched_ctx_set_min_priority(sched_ctx_id, INT_MIN);
  774. if (starpu_sched_ctx_max_priority_is_set(sched_ctx_id) == 0)
  775. starpu_sched_ctx_set_max_priority(sched_ctx_id, INT_MAX);
  776. }
  777. static void deinitialize_dmda_policy(unsigned sched_ctx_id)
  778. {
  779. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  780. #ifdef STARPU_VERBOSE
  781. {
  782. struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
  783. long int modelled_task_cnt = dt->total_task_cnt - dt->eager_task_cnt;
  784. _STARPU_DEBUG("%s sched policy (sched_ctx %u): total_task_cnt %ld ready_task_cnt %ld (%.1f%%), modelled_task_cnt = %ld (%.1f%%)%s\n",
  785. sched_ctx->sched_policy?sched_ctx->sched_policy->policy_name:"<none>",
  786. sched_ctx_id,
  787. dt->total_task_cnt,
  788. dt->ready_task_cnt,
  789. (100.0f*dt->ready_task_cnt)/dt->total_task_cnt,
  790. modelled_task_cnt,
  791. (100.0f*modelled_task_cnt)/dt->total_task_cnt,
  792. modelled_task_cnt==0?" *** Check if performance models are enabled and converging on a per-codelet basis, or use an non-modeling scheduling policy. ***":"");
  793. }
  794. #endif
  795. free(dt);
  796. }
  797. /* dmda_pre_exec_hook is called right after the data transfer is done and right
  798. * before the computation to begin, it is useful to update more precisely the
  799. * value of the expected start, end, length, etc... */
  800. static void dmda_pre_exec_hook(struct starpu_task *task, unsigned sched_ctx_id)
  801. {
  802. unsigned workerid = starpu_worker_get_id_check();
  803. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  804. struct _starpu_fifo_taskq *fifo = &dt->queue_array[workerid];
  805. const double now = starpu_timing_now();
  806. /* Once the task is executing, we can update the predicted amount
  807. * of work. */
  808. starpu_worker_lock_self();
  809. _starpu_fifo_task_started(fifo, task, dt->num_priorities);
  810. /* Take the opportunity to update start time */
  811. fifo->exp_start = STARPU_MAX(now + fifo->pipeline_len, fifo->exp_start);
  812. fifo->exp_end = fifo->exp_start + fifo->exp_len;
  813. starpu_worker_unlock_self();
  814. }
  815. static void _dm_push_task_notify(struct starpu_task *task, int workerid, int perf_workerid, unsigned sched_ctx_id, int da)
  816. {
  817. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  818. struct _starpu_fifo_taskq *fifo = &dt->queue_array[workerid];
  819. /* Compute the expected penality */
  820. double predicted = starpu_task_worker_expected_length(task, perf_workerid, STARPU_NMAX_SCHED_CTXS,
  821. starpu_task_get_implementation(task));
  822. double predicted_transfer = NAN;
  823. if (da)
  824. predicted_transfer = starpu_task_expected_data_transfer_time_for(task, workerid);
  825. double now = starpu_timing_now();
  826. /* Update the predictions */
  827. starpu_worker_lock(workerid);
  828. /* Sometimes workers didn't take the tasks as early as we expected */
  829. fifo->exp_start = isnan(fifo->exp_start) ? now + fifo->pipeline_len : STARPU_MAX(fifo->exp_start, now);
  830. fifo->exp_end = fifo->exp_start + fifo->exp_len;
  831. if (da)
  832. {
  833. /* If there is no prediction available, we consider the task has a null length */
  834. if (!isnan(predicted_transfer))
  835. {
  836. if (now + predicted_transfer < fifo->exp_end)
  837. {
  838. /* We may hope that the transfer will be finished by
  839. * the start of the task. */
  840. predicted_transfer = 0;
  841. }
  842. else
  843. {
  844. /* The transfer will not be finished by then, take the
  845. * remainder into account */
  846. predicted_transfer = (now + predicted_transfer) - fifo->exp_end;
  847. }
  848. task->predicted_transfer = predicted_transfer;
  849. fifo->exp_end += predicted_transfer;
  850. fifo->exp_len += predicted_transfer;
  851. if(dt->num_priorities != -1)
  852. {
  853. int i;
  854. int task_prio = _starpu_normalize_prio(task->priority, dt->num_priorities, task->sched_ctx);
  855. for(i = 0; i <= task_prio; i++)
  856. fifo->exp_len_per_priority[i] += predicted_transfer;
  857. }
  858. }
  859. }
  860. /* If there is no prediction available, we consider the task has a null length */
  861. if (!isnan(predicted))
  862. {
  863. task->predicted = predicted;
  864. fifo->exp_end += predicted;
  865. fifo->exp_len += predicted;
  866. if(dt->num_priorities != -1)
  867. {
  868. int i;
  869. int task_prio = _starpu_normalize_prio(task->priority, dt->num_priorities, task->sched_ctx);
  870. for(i = 0; i <= task_prio; i++)
  871. fifo->exp_len_per_priority[i] += predicted;
  872. }
  873. }
  874. if(dt->num_priorities != -1)
  875. {
  876. int i;
  877. int task_prio = _starpu_normalize_prio(task->priority, dt->num_priorities, task->sched_ctx);
  878. for(i = 0; i <= task_prio; i++)
  879. fifo->ntasks_per_priority[i]++;
  880. }
  881. fifo->ntasks++;
  882. starpu_worker_unlock(workerid);
  883. }
  884. static void dm_push_task_notify(struct starpu_task *task, int workerid, int perf_workerid, unsigned sched_ctx_id)
  885. {
  886. _dm_push_task_notify(task, workerid, perf_workerid, sched_ctx_id, 0);
  887. }
  888. static void dmda_push_task_notify(struct starpu_task *task, int workerid, int perf_workerid, unsigned sched_ctx_id)
  889. {
  890. _dm_push_task_notify(task, workerid, perf_workerid, sched_ctx_id, 1);
  891. }
  892. static void dmda_post_exec_hook(struct starpu_task * task, unsigned sched_ctx_id)
  893. {
  894. struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  895. unsigned workerid = starpu_worker_get_id_check();
  896. struct _starpu_fifo_taskq *fifo = &dt->queue_array[workerid];
  897. starpu_worker_lock_self();
  898. _starpu_fifo_task_finished(fifo, task, dt->num_priorities);
  899. starpu_worker_unlock_self();
  900. }
  901. struct starpu_sched_policy _starpu_sched_dm_policy =
  902. {
  903. .init_sched = initialize_dmda_policy,
  904. .deinit_sched = deinitialize_dmda_policy,
  905. .add_workers = dmda_add_workers ,
  906. .remove_workers = dmda_remove_workers,
  907. .push_task = dm_push_task,
  908. .simulate_push_task = dm_simulate_push_task,
  909. .push_task_notify = dm_push_task_notify,
  910. .pop_task = dmda_pop_task,
  911. .pre_exec_hook = dmda_pre_exec_hook,
  912. .post_exec_hook = dmda_post_exec_hook,
  913. .pop_every_task = dmda_pop_every_task,
  914. .policy_name = "dm",
  915. .policy_description = "performance model",
  916. .worker_type = STARPU_WORKER_LIST,
  917. .prefetches = 1,
  918. };
  919. struct starpu_sched_policy _starpu_sched_dmda_policy =
  920. {
  921. .init_sched = initialize_dmda_policy,
  922. .deinit_sched = deinitialize_dmda_policy,
  923. .add_workers = dmda_add_workers ,
  924. .remove_workers = dmda_remove_workers,
  925. .push_task = dmda_push_task,
  926. .simulate_push_task = dmda_simulate_push_task,
  927. .push_task_notify = dmda_push_task_notify,
  928. .pop_task = dmda_pop_task,
  929. .pre_exec_hook = dmda_pre_exec_hook,
  930. .post_exec_hook = dmda_post_exec_hook,
  931. .pop_every_task = dmda_pop_every_task,
  932. .policy_name = "dmda",
  933. .policy_description = "data-aware performance model",
  934. .worker_type = STARPU_WORKER_LIST,
  935. .prefetches = 1,
  936. };
  937. struct starpu_sched_policy _starpu_sched_dmda_prio_policy =
  938. {
  939. .init_sched = initialize_dmda_sorted_policy,
  940. .deinit_sched = deinitialize_dmda_policy,
  941. .add_workers = dmda_add_workers ,
  942. .remove_workers = dmda_remove_workers,
  943. .push_task = dmda_push_sorted_task,
  944. .simulate_push_task = dmda_simulate_push_sorted_task,
  945. .push_task_notify = dmda_push_task_notify,
  946. .pop_task = dmda_pop_task,
  947. .pre_exec_hook = dmda_pre_exec_hook,
  948. .post_exec_hook = dmda_post_exec_hook,
  949. .pop_every_task = dmda_pop_every_task,
  950. .policy_name = "dmdap",
  951. .policy_description = "data-aware performance model (priority)",
  952. .worker_type = STARPU_WORKER_LIST,
  953. .prefetches = 1,
  954. };
  955. struct starpu_sched_policy _starpu_sched_dmda_sorted_policy =
  956. {
  957. .init_sched = initialize_dmda_sorted_policy,
  958. .deinit_sched = deinitialize_dmda_policy,
  959. .add_workers = dmda_add_workers ,
  960. .remove_workers = dmda_remove_workers,
  961. .push_task = dmda_push_sorted_task,
  962. .simulate_push_task = dmda_simulate_push_sorted_task,
  963. .push_task_notify = dmda_push_task_notify,
  964. .pop_task = dmda_pop_ready_task,
  965. .pre_exec_hook = dmda_pre_exec_hook,
  966. .post_exec_hook = dmda_post_exec_hook,
  967. .pop_every_task = dmda_pop_every_task,
  968. .policy_name = "dmdas",
  969. .policy_description = "data-aware performance model (sorted)",
  970. .worker_type = STARPU_WORKER_LIST,
  971. .prefetches = 1,
  972. };
  973. struct starpu_sched_policy _starpu_sched_dmda_sorted_decision_policy =
  974. {
  975. .init_sched = initialize_dmda_sorted_policy,
  976. .deinit_sched = deinitialize_dmda_policy,
  977. .add_workers = dmda_add_workers ,
  978. .remove_workers = dmda_remove_workers,
  979. .push_task = dmda_push_sorted_decision_task,
  980. .simulate_push_task = dmda_simulate_push_sorted_decision_task,
  981. .push_task_notify = dmda_push_task_notify,
  982. .pop_task = dmda_pop_ready_task,
  983. .pre_exec_hook = dmda_pre_exec_hook,
  984. .post_exec_hook = dmda_post_exec_hook,
  985. .pop_every_task = dmda_pop_every_task,
  986. .policy_name = "dmdasd",
  987. .policy_description = "data-aware performance model (sorted decision)",
  988. .worker_type = STARPU_WORKER_LIST,
  989. .prefetches = 1,
  990. };
  991. struct starpu_sched_policy _starpu_sched_dmda_ready_policy =
  992. {
  993. .init_sched = initialize_dmda_policy,
  994. .deinit_sched = deinitialize_dmda_policy,
  995. .add_workers = dmda_add_workers ,
  996. .remove_workers = dmda_remove_workers,
  997. .push_task = dmda_push_task,
  998. .simulate_push_task = dmda_simulate_push_task,
  999. .push_task_notify = dmda_push_task_notify,
  1000. .pop_task = dmda_pop_ready_task,
  1001. .pre_exec_hook = dmda_pre_exec_hook,
  1002. .post_exec_hook = dmda_post_exec_hook,
  1003. .pop_every_task = dmda_pop_every_task,
  1004. .policy_name = "dmdar",
  1005. .policy_description = "data-aware performance model (ready)",
  1006. .worker_type = STARPU_WORKER_LIST,
  1007. .prefetches = 1,
  1008. };