scheduling_context_hypervisor.doxy 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. /*
  2. * This file is part of the StarPU Handbook.
  3. * Copyright (C) 2009--2011 Universit@'e de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
  5. * Copyright (C) 2011, 2012, 2013 Institut National de Recherche en Informatique et Automatique
  6. * See the file version.doxy for copying conditions.
  7. */
  8. /*! \defgroup API_Scheduling_Context_Hypervisor Scheduling Context Hypervisor
  9. \struct sc_hypervisor_policy
  10. \ingroup API_Scheduling_Context_Hypervisor
  11. This structure contains all the methods that implement a hypervisor resizing policy.
  12. \var sc_hypervisor_policy::name
  13. Indicates the name of the policy, if there is not a custom policy, the policy corresponding to this name will be used by the hypervisor
  14. \var sc_hypervisor_policy::custom
  15. Indicates whether the policy is custom or not
  16. \var sc_hypervisor_policy::size_ctxs
  17. Distribute workers to contexts even at the begining of the program
  18. \var sc_hypervisor_policy::resize_ctxs
  19. Require explicit resizing
  20. \var sc_hypervisor_policy::handle_idle_cycle
  21. It is called whenever the indicated worker executes another idle cycle in sched_ctx
  22. \var sc_hypervisor_policy::handle_pushed_task
  23. It is called whenever a task is pushed on the worker’s queue corresponding to the context sched_ctx
  24. \var sc_hypervisor_policy::handle_poped_task
  25. It is called whenever a task is poped from the worker’s queue corresponding to the context sched_ctx
  26. \var sc_hypervisor_policy::handle_poped_task
  27. The hypervisor takes a decision when another task was poped from this worker in this ctx
  28. \var sc_hypervisor_policy::handle_idle_end
  29. It is called whenever a task is executed on the indicated worker and context after a long period of idle time
  30. \var sc_hypervisor_policy::handle_post_exec_hook
  31. It is called whenever a tag task has just been executed. The table of resize requests is provided as well as the tag
  32. \var sc_hypervisor_policy::handle_submitted_job
  33. The hypervisor takes a decision when a job was submitted in this ctx
  34. \var sc_hypervisor_policy::end_ctx
  35. The hypervisor takes a decision when a certain ctx was deleted
  36. \struct sc_hypervisor_policy_config
  37. \ingroup API_Scheduling_Context_Hypervisor
  38. This structure contains all configuration information of a
  39. context. It contains configuration information for each context, which
  40. can be used to construct new resize strategies.
  41. \var sc_hypervisor_policy_config::min_nworkers
  42. Indicates the minimum number of workers needed by the context
  43. \var sc_hypervisor_policy_config::max_nworkers
  44. Indicates the maximum number of workers needed by the context
  45. \var sc_hypervisor_policy_config::granularity
  46. Indicates the workers granularity of the context
  47. \var sc_hypervisor_policy_config::priority
  48. Indicates the priority of each worker in the context
  49. \var sc_hypervisor_policy_config::max_idle
  50. Indicates the maximum idle time accepted before a resize is triggered
  51. \var sc_hypervisor_policy_config::min_working
  52. Indicates that underneath this limit the priority of the worker is reduced
  53. \var sc_hypervisor_policy_config::fixed_workers
  54. Indicates which workers can be moved and which ones are fixed
  55. \var sc_hypervisor_policy_config:: new_workers_max_idle
  56. Indicates the maximum idle time accepted before a resize is triggered for the workers that just arrived in the new context
  57. \var sc_hypervisor_policy_config::empty_ctx_max_idle
  58. Indicates that above this context we allow removing all workers
  59. \var sc_hypervisor_policy_config::ispeed_w_sample
  60. Indicates the sample used to compute the instant speed per worker
  61. \var sc_hypervisor_policy_config::ispeed_ctx_sample
  62. Indicates the sample used to compute the instant speed per ctxs
  63. \struct sc_hypervisor_wrapper
  64. \ingroup API_Scheduling_Context_Hypervisor
  65. This structure is a wrapper of the contexts available in StarPU
  66. and contains all information about a context obtained by incrementing
  67. the performance counters.
  68. \var sc_hypervisor_wrapper::sched_ctx
  69. The context wrapped
  70. \var sc_hypervisor_wrapper::config
  71. The corresponding resize configuration
  72. \var sc_hypervisor_wrapper::current_idle_time
  73. The idle time counter of each worker of the context
  74. \var sc_hypervisor_wrapper::pushed_tasks
  75. The number of pushed tasks of each worker of the context
  76. \var sc_hypervisor_wrapper::poped_tasks
  77. The number of poped tasks of each worker of the context
  78. \var sc_hypervisor_wrapper::total_flops
  79. The total number of flops to execute by the context
  80. \var sc_hypervisor_wrapper::total_elapsed_flops
  81. The number of flops executed by each workers of the context
  82. \var sc_hypervisor_wrapper::elapsed_flops
  83. The number of flops executed by each worker of the context from last resize
  84. \var sc_hypervisor_wrapper::remaining_flops
  85. The number of flops that still have to be executed by the workers in the context
  86. \var sc_hypervisor_wrapper::start_time
  87. The time when he started executed
  88. \var sc_hypervisor_wrapper::resize_ack
  89. The structure confirming the last resize finished and a new one can be done
  90. \struct sc_hypervisor_resize_ack
  91. \ingroup API_Scheduling_Context_Hypervisor
  92. This structures checks if the workers moved to another context
  93. are actually taken into account in that context.
  94. \var sc_hypervisor_resize_ack::receiver_sched_ctx
  95. The context receiving the new workers
  96. \var sc_hypervisor_resize_ack::moved_workers
  97. The workers moved to the receiver context
  98. \var sc_hypervisor_resize_ack::nmoved_workers
  99. The number of workers moved
  100. \var sc_hypervisor_resize_ack::acked_workers
  101. If the value corresponding to a worker is 1, this one is taken
  102. into account in the new context if 0 not yet
  103. \struct sc_hypervisor_policy_task_pool
  104. task wrapper linked list
  105. \ingroup API_Scheduling_Context_Hypervisor
  106. \var sc_hypervisor_policy_task_pool::cl
  107. Which codelet has been executed
  108. \var sc_hypervisor_policy_task_pool::footprint
  109. Task footprint key
  110. \var sc_hypervisor_policy_task_pool::sched_ctx_id
  111. Context the task belongs to
  112. \var sc_hypervisor_policy_task_pool::n
  113. Number of tasks of this kind
  114. \var sc_hypervisor_policy_task_pool::next
  115. Other task kinds
  116. \fn void *sc_hypervisor_init(struct sc_hypervisor_policy *policy)
  117. \ingroup API_Scheduling_Context_Hypervisor
  118. There is a single hypervisor that is in charge of resizing contexts
  119. and the resizing strategy is chosen at the initialization of the
  120. hypervisor. A single resize can be done at a time.
  121. The Scheduling Context Hypervisor Plugin provides a series of
  122. performance counters to StarPU. By incrementing them, StarPU can help
  123. the hypervisor in the resizing decision making process. TODO maybe
  124. they should be hidden to the user
  125. This function initializes the hypervisor to use the strategy provided as parameter
  126. and creates the performance counters (see starpu_sched_ctx_performance_counters).
  127. These performance counters represent actually some callbacks that will
  128. be used by the contexts to notify the information needed by the
  129. hypervisor.
  130. Note: The Hypervisor is actually a worker that takes this role once
  131. certain conditions trigger the resizing process (there is no
  132. additional thread assigned to the hypervisor).
  133. \fn void sc_hypervisor_shutdown(void)
  134. \ingroup API_Scheduling_Context_Hypervisor
  135. The hypervisor and all information concerning it is cleaned. There is
  136. no synchronization between this function and starpu_shutdown(). Thus,
  137. this should be called after starpu_shutdown(), because the performance
  138. counters will still need allocated callback functions.
  139. \fn void sc_hypervisor_register_ctx(unsigned sched_ctx, double total_flops)
  140. \ingroup API_Scheduling_Context_Hypervisor
  141. Scheduling Contexts that have to be resized by the hypervisor must be
  142. first registered to the hypervisor.
  143. This function registers the context to the hypervisor, and indicate the number of
  144. flops the context will execute (needed for Gflops rate based strategy
  145. see \ref ResizingStrategies or any other custom strategy needing it, for
  146. the others we can pass 0.0)
  147. \fn void sc_hypervisor_unregister_ctx(unsigned sched_ctx)
  148. \ingroup API_Scheduling_Context_Hypervisor
  149. Whenever we want to exclude
  150. contexts from the resizing process we have to unregister them from the
  151. hypervisor.
  152. \fn void sc_hypervisor_post_resize_request(unsigned sched_ctx, int task_tag)
  153. \ingroup API_Scheduling_Context_Hypervisor
  154. Requires resizing the context \p sched_ctx whenever a task tagged with the id \p task_tag
  155. finished executing
  156. \fn void sc_hypervisor_resize_ctxs(int *sched_ctxs, int nsched_ctxs , int *workers, int nworkers)
  157. \ingroup API_Scheduling_Context_Hypervisor
  158. Requires reconsidering the distribution of ressources over the indicated scheduling contexts
  159. \fn void sc_hypervisor_stop_resize(unsigned sched_ctx)
  160. \ingroup API_Scheduling_Context_Hypervisor
  161. The user can totally forbid the resizing of a certain context or can
  162. then change his mind and allow it (in this case the resizing is
  163. managed by the hypervisor, that can forbid it or allow it)
  164. \fn void sc_hypervisor_start_resize(unsigned sched_ctx)
  165. \ingroup API_Scheduling_Context_Hypervisor
  166. Allow resizing of a context. The user can then provide information to
  167. the hypervisor concerning the conditions of resizing.
  168. \fn char *sc_hypervisor_get_policy();
  169. \ingroup API_Scheduling_Context_Hypervisor
  170. Returns the name of the resizing policy the hypervisor uses
  171. \fn void sc_hypervisor_add_workers_to_sched_ctx(int* workers_to_add, unsigned nworkers_to_add, unsigned sched_ctx)
  172. \ingroup API_Scheduling_Context_Hypervisor
  173. Ask the hypervisor to add workers to a sched_ctx
  174. \fn void sc_hypervisor_remove_workers_from_sched_ctx(int* workers_to_remove, unsigned nworkers_to_remove, unsigned sched_ctx, unsigned now)
  175. \ingroup API_Scheduling_Context_Hypervisor
  176. Ask the hypervisor to remove workers from a sched_ctx
  177. \fn void sc_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned receiver_sched_ctx, int *workers_to_move, unsigned nworkers_to_move, unsigned now)
  178. \ingroup API_Scheduling_Context_Hypervisor
  179. Moves workers from one context to another
  180. \fn void sc_hypervisor_size_ctxs(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
  181. \ingroup API_Scheduling_Context_Hypervisor
  182. Ask the hypervisor to chose a distribution of workers in the required contexts
  183. \fn unsigned sc_hypervisor_get_size_req(unsigned **sched_ctxs, int* nsched_ctxs, int **workers, int *nworkers)
  184. \ingroup API_Scheduling_Context_Hypervisor
  185. Check if there are pending demands of resizing
  186. \fn void sc_hypervisor_save_size_req(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
  187. \ingroup API_Scheduling_Context_Hypervisor
  188. Save a demand of resizing
  189. \fn void sc_hypervisor_free_size_req(void)
  190. \ingroup API_Scheduling_Context_Hypervisor
  191. Clear the list of pending demands of resizing
  192. \fn unsigned sc_hypervisor_can_resize(unsigned sched_ctx)
  193. \ingroup API_Scheduling_Context_Hypervisor
  194. Check out if a context can be resized
  195. \fn void sc_hypervisor_set_type_of_task(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint, size_t data_size)
  196. \ingroup API_Scheduling_Context_Hypervisor
  197. Indicate the types of tasks a context will execute in order to better decide the sizing of ctxs
  198. \fn void sc_hypervisor_update_diff_total_flops(unsigned sched_ctx, double diff_total_flops)
  199. \ingroup API_Scheduling_Context_Hypervisor
  200. Change dynamically the total number of flops of a context, move the deadline of the finishing time of the context
  201. \fn void sc_hypervisor_update_diff_elapsed_flops(unsigned sched_ctx, double diff_task_flops)
  202. \ingroup API_Scheduling_Context_Hypervisor
  203. Change dynamically the number of the elapsed flops in a context, modify the past in order to better compute the speed
  204. \fn void sc_hypervisor_ctl(unsigned sched_ctx, ...)
  205. \ingroup API_Scheduling_Context_Hypervisor
  206. Inputs conditions to the context sched_ctx with the following
  207. arguments. The argument list must be zero-terminated.
  208. \def SC_HYPERVISOR_MAX_IDLE
  209. \ingroup API_Scheduling_Context_Hypervisor
  210. This macro is used when calling sc_hypervisor_ctl() and must be
  211. followed by 3 arguments: an array of int for the workerids to apply
  212. the condition, an int to indicate the size of the array, and a double
  213. value indicating the maximum idle time allowed for a worker before the
  214. resizing process should be triggered
  215. \def SC_HYPERVISOR_PRIORITY
  216. \ingroup API_Scheduling_Context_Hypervisor
  217. This macro is used when calling sc_hypervisor_ctl() and must be
  218. followed by 3 arguments: an array of int for the workerids to apply
  219. the condition, an int to indicate the size of the array, and an int
  220. value indicating the priority of the workers previously mentioned. The
  221. workers with the smallest priority are moved the first.
  222. \def SC_HYPERVISOR_MIN_WORKERS
  223. \ingroup API_Scheduling_Context_Hypervisor
  224. This macro is used when calling sc_hypervisor_ctl() and must be
  225. followed by 1 argument(int) indicating the minimum number of workers a
  226. context should have, underneath this limit the context cannot execute.
  227. \def SC_HYPERVISOR_MAX_WORKERS
  228. \ingroup API_Scheduling_Context_Hypervisor
  229. This macro is used when calling sc_hypervisor_ctl() and must be
  230. followed by 1 argument(int) indicating the maximum number of workers a
  231. context should have, above this limit the context would not be able to
  232. scale
  233. \def SC_HYPERVISOR_GRANULARITY
  234. \ingroup API_Scheduling_Context_Hypervisor
  235. This macro is used when calling sc_hypervisor_ctl() and must be
  236. followed by 1 argument(int) indicating the granularity of the resizing
  237. process (the number of workers should be moved from the context once
  238. it is resized) This parameter is ignore for the Gflops rate based
  239. strategy (see \ref ResizingStrategies), the number of workers that have to
  240. be moved is calculated by the strategy.
  241. \def SC_HYPERVISOR_FIXED_WORKERS
  242. \ingroup API_Scheduling_Context_Hypervisor
  243. This macro is used when calling sc_hypervisor_ctl() and must be
  244. followed by 2 arguments: an array of int for the workerids to apply
  245. the condition and an int to indicate the size of the array. These
  246. workers are not allowed to be moved from the context.
  247. \def SC_HYPERVISOR_MIN_TASKS
  248. \ingroup API_Scheduling_Context_Hypervisor
  249. This macro is used when calling sc_hypervisor_ctl() and must be
  250. followed by 1 argument (int) that indicated the minimum number of
  251. tasks that have to be executed before the context could be resized.
  252. This parameter is ignored for the Application Driven strategy (see \ref
  253. ResizingStrategies) where the user indicates exactly when the resize
  254. should be done.
  255. \def SC_HYPERVISOR_NEW_WORKERS_MAX_IDLE
  256. \ingroup API_Scheduling_Context_Hypervisor
  257. This macro is used when calling sc_hypervisor_ctl() and must be
  258. followed by 1 argument, a double value indicating the maximum idle
  259. time allowed for workers that have just been moved from other contexts
  260. in the current context.
  261. \def SC_HYPERVISOR_TIME_TO_APPLY
  262. \ingroup API_Scheduling_Context_Hypervisor
  263. This macro is used when calling sc_hypervisor_ctl() and must be
  264. followed by 1 argument (int) indicating the tag an executed task
  265. should have such that this configuration should be taken into account.
  266. \def SC_HYPERVISOR_ISPEED_W_SAMPLE
  267. \ingroup API_Scheduling_Context_Hypervisor
  268. This macro is used when calling sc_hypervisor_ctl() and must be
  269. followed by 1 argument, a double, that indicates the number of flops
  270. needed to be executed before computing the speed of a worker
  271. \def SC_HYPERVISOR_ISPEED_CTX_SAMPLE
  272. \ingroup API_Scheduling_Context_Hypervisor
  273. This macro is used when calling sc_hypervisor_ctl() and must be
  274. followed by 1 argument, a double, that indicates the number of flops
  275. needed to be executed before computing the speed of a context
  276. \def SC_HYPERVISOR_NULL
  277. \ingroup API_Scheduling_Context_Hypervisor
  278. This macro is used when calling sc_hypervisor_ctl() and must be
  279. followed by 1 arguments
  280. \fn struct sc_hypervisor_policy_config *sc_hypervisor_get_config(unsigned sched_ctx);
  281. \ingroup API_Scheduling_Context_Hypervisor
  282. Returns the configuration structure of a context
  283. \fn void sc_hypervisor_set_config(unsigned sched_ctx, void *config);
  284. \ingroup API_Scheduling_Context_Hypervisor
  285. Set a certain configuration to a contexts
  286. \fn int *sc_hypervisor_get_sched_ctxs();
  287. \ingroup API_Scheduling_Context_Hypervisor
  288. Gets the contexts managed by the hypervisor
  289. \fn int sc_hypervisor_get_nsched_ctxs();
  290. \ingroup API_Scheduling_Context_Hypervisor
  291. Gets the number of contexts managed by the hypervisor
  292. \fn struct sc_hypervisor_wrapper *sc_hypervisor_get_wrapper(unsigned sched_ctx);
  293. \ingroup API_Scheduling_Context_Hypervisor
  294. Returns the wrapper corresponding the context \p sched_ctx
  295. \fn double sc_hypervisor_get_elapsed_flops_per_sched_ctx(struct sc_hypervisor_wrapper *sc_w);
  296. \ingroup API_Scheduling_Context_Hypervisor
  297. Returns the flops of a context elapsed from the last resize
  298. */