sc_hypervisor_policy.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2014 Inria
  4. * Copyright (C) 2012,2013,2017,2019 CNRS
  5. * Copyright (C) 2012,2013 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. #ifndef SC_HYPERVISOR_POLICY_H
  19. #define SC_HYPERVISOR_POLICY_H
  20. #include <sc_hypervisor.h>
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. /**
  26. @defgroup API_SC_Hypervisor Scheduling Context Hypervisor - Building a new resizing policy
  27. @{
  28. */
  29. #define HYPERVISOR_REDIM_SAMPLE 0.02
  30. #define HYPERVISOR_START_REDIM_SAMPLE 0.1
  31. #define SC_NOTHING 0
  32. #define SC_IDLE 1
  33. #define SC_SPEED 2
  34. struct types_of_workers
  35. {
  36. unsigned ncpus;
  37. unsigned ncuda;
  38. unsigned nw;
  39. };
  40. /**
  41. Task wrapper linked list
  42. @ingroup API_SC_Hypervisor
  43. */
  44. struct sc_hypervisor_policy_task_pool
  45. {
  46. /**
  47. Which codelet has been executed
  48. */
  49. struct starpu_codelet *cl;
  50. /**
  51. Task footprint key
  52. */
  53. uint32_t footprint;
  54. /**
  55. Context the task belongs to
  56. */
  57. unsigned sched_ctx_id;
  58. /**
  59. Number of tasks of this kind
  60. */
  61. unsigned long n;
  62. /**
  63. The quantity of data(in bytes) needed by the task to execute
  64. */
  65. size_t data_size;
  66. /**
  67. Other task kinds
  68. */
  69. struct sc_hypervisor_policy_task_pool *next;
  70. };
  71. /**
  72. add task information to a task wrapper linked list
  73. */
  74. void sc_hypervisor_policy_add_task_to_pool(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint, struct sc_hypervisor_policy_task_pool **task_pools, size_t data_size);
  75. /**
  76. remove task information from a task wrapper linked list
  77. */
  78. void sc_hypervisor_policy_remove_task_from_pool(struct starpu_task *task, uint32_t footprint, struct sc_hypervisor_policy_task_pool **task_pools);
  79. /**
  80. clone a task wrapper linked list
  81. */
  82. struct sc_hypervisor_policy_task_pool* sc_hypervisor_policy_clone_task_pool(struct sc_hypervisor_policy_task_pool *tp);
  83. /**
  84. get the execution time of the submitted tasks out of starpu's calibration files
  85. */
  86. void sc_hypervisor_get_tasks_times(int nw, int nt, double times[nw][nt], int *workers, unsigned size_ctxs, struct sc_hypervisor_policy_task_pool *task_pools);
  87. /**
  88. find the context with the lowest priority in order to move some workers
  89. */
  90. unsigned sc_hypervisor_find_lowest_prio_sched_ctx(unsigned req_sched_ctx, int nworkers_to_move);
  91. /**
  92. find the first most idle workers of a contex
  93. */
  94. int* sc_hypervisor_get_idlest_workers(unsigned sched_ctx, int *nworkers, enum starpu_worker_archtype arch);
  95. /**
  96. find the first most idle workers in a list
  97. */
  98. int* sc_hypervisor_get_idlest_workers_in_list(int *start, int *workers, int nall_workers, int *nworkers, enum starpu_worker_archtype arch);
  99. /**
  100. find workers that can be moved from a context (if the constraints of min, max, etc allow this)
  101. */
  102. int sc_hypervisor_get_movable_nworkers(struct sc_hypervisor_policy_config *config, unsigned sched_ctx, enum starpu_worker_archtype arch);
  103. /**
  104. compute how many workers should be moved from this context
  105. */
  106. int sc_hypervisor_compute_nworkers_to_move(unsigned req_sched_ctx);
  107. /**
  108. check the policy's constraints in order to resize
  109. */
  110. unsigned sc_hypervisor_policy_resize(unsigned sender_sched_ctx, unsigned receiver_sched_ctx, unsigned force_resize, unsigned now);
  111. /**
  112. check the policy's constraints in order to resize and find a context willing the resources
  113. */
  114. unsigned sc_hypervisor_policy_resize_to_unknown_receiver(unsigned sender_sched_ctx, unsigned now);
  115. /**
  116. compute the speed of a context
  117. */
  118. double sc_hypervisor_get_ctx_speed(struct sc_hypervisor_wrapper* sc_w);
  119. /**
  120. get the time of execution of the slowest context
  121. */
  122. double sc_hypervisor_get_slowest_ctx_exec_time(void);
  123. /**
  124. get the time of execution of the fastest context
  125. */
  126. double sc_hypervisor_get_fastest_ctx_exec_time(void);
  127. /**
  128. compute the speed of a workers in a context
  129. */
  130. double sc_hypervisor_get_speed_per_worker(struct sc_hypervisor_wrapper *sc_w, unsigned worker);
  131. /**
  132. compute the speed of a type of worker in a context
  133. */
  134. double sc_hypervisor_get_speed_per_worker_type(struct sc_hypervisor_wrapper* sc_w, enum starpu_worker_archtype arch);
  135. /**
  136. compute the speed of a type of worker in a context depending on its history
  137. */
  138. double sc_hypervisor_get_ref_speed_per_worker_type(struct sc_hypervisor_wrapper* sc_w, enum starpu_worker_archtype arch);
  139. /**
  140. compute the average speed of a type of worker in all ctxs from the begining of appl
  141. */
  142. double sc_hypervisor_get_avg_speed(enum starpu_worker_archtype arch);
  143. /**
  144. verify if we need to consider the max in the lp
  145. */
  146. void sc_hypervisor_check_if_consider_max(struct types_of_workers *tw);
  147. /**
  148. get the list of workers grouped by type
  149. */
  150. void sc_hypervisor_group_workers_by_type(struct types_of_workers *tw, int *total_nw);
  151. /**
  152. get what type of worker corresponds to a certain index of types of workers
  153. */
  154. enum starpu_worker_archtype sc_hypervisor_get_arch_for_index(unsigned w, struct types_of_workers *tw);
  155. /**
  156. get the index of types of workers corresponding to the type of workers indicated
  157. */
  158. unsigned sc_hypervisor_get_index_for_arch(enum starpu_worker_archtype arch, struct types_of_workers *tw);
  159. /**
  160. check if we trigger resizing or not
  161. */
  162. unsigned sc_hypervisor_criteria_fulfilled(unsigned sched_ctx, int worker);
  163. /**
  164. check if worker was idle long enough
  165. */
  166. unsigned sc_hypervisor_check_idle(unsigned sched_ctx, int worker);
  167. /**
  168. check if there is a speed gap btw ctxs
  169. */
  170. unsigned sc_hypervisor_check_speed_gap_btw_ctxs(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers);
  171. /**
  172. check if there is a speed gap btw ctxs on one level
  173. */
  174. unsigned sc_hypervisor_check_speed_gap_btw_ctxs_on_level(int level, int *workers_in, int nworkers_in, unsigned father_sched_ctx_id, unsigned **sched_ctxs, int *nsched_ctxs);
  175. /**
  176. check what triggers resizing (idle, speed, etc.
  177. */
  178. unsigned sc_hypervisor_get_resize_criteria();
  179. /**
  180. load information concerning the type of workers into a types_of_workers struct
  181. */
  182. struct types_of_workers* sc_hypervisor_get_types_of_workers(int *workers, unsigned nworkers);
  183. /** @} */
  184. #ifdef __cplusplus
  185. }
  186. #endif
  187. #endif