modularized_scheduler.doxy 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /*! \defgroup API_Modularized_Scheduler Modularized Scheduler Interface
  2. \struct starpu_sched_component
  3. \ingroup API_Modularized_Scheduler
  4. This structure represent a scheduler module.
  5. \var starpu_sched_component::push_task
  6. push a task in the scheduler module.
  7. \var starpu_sched_component::pop_task
  8. pop a task from the scheduler module, the task returned by this function is executable by the caller
  9. It should use starpu_sched_component::fathers[sched_ctx_id] to perform a recursive call.
  10. \var starpu_sched_component::estimated_load
  11. is an heuristic to compute load of scheduler module. Basically the number of tasks divided by the sum
  12. of relatives speedup of workers available in context.
  13. \var starpu_sched_component::estimated_end
  14. return the time when a worker will enter in starvation. This function is relevant only if the task->predicted
  15. member has been set.
  16. \var starpu_sched_component::nchildren
  17. the number of modules downstairs
  18. \var starpu_sched_component::children
  19. modules downstairs
  20. \var starpu_sched_component::workers
  21. this member contain the set of underlying workers
  22. \var starpu_sched_component::workers_in_ctx
  23. this member contain the subset of starpu_sched_component::workers that is currently available in the context
  24. The push method should take this member into account.
  25. \var starpu_sched_component::properties
  26. flags starpu_sched_component_properties for things
  27. \var starpu_sched_component::data
  28. data used by the scheduler module
  29. \var starpu_sched_component::add_child
  30. add a child to component
  31. \var starpu_sched_component::remove_child
  32. remove a child from component
  33. \var starpu_sched_component::fathers
  34. the array of scheduler module above indexed by scheduling context index
  35. \var starpu_sched_component::notify_change_workers
  36. this function is called when starpu_sched_component::workers_in_ctx or starpu_sched_component::workers is changed
  37. \var starpu_sched_component::deinit_data
  38. called by starpu_sched_component_destroy. Should free data allocated during creation
  39. \var starpu_sched_component::obj
  40. the hwloc object associated to scheduler module
  41. \enum starpu_sched_component_properties
  42. \ingroup API_Modularized_Scheduler
  43. flags for starpu_sched_component::properties
  44. \var STARPU_SCHED_component_HOMOGENEOUS
  45. indicate that all workers have the same starpu_worker_archtype
  46. \var STARPU_SCHED_component_SINGLE_MEMORY_component
  47. indicate that all workers have the same memory component
  48. \def STARPU_SCHED_component_IS_HOMOGENEOUS
  49. \ingroup API_Modularized_Scheduler
  50. indicate if component is homogeneous
  51. \def STARPU_SCHED_component_IS_SINGLE_MEMORY_component
  52. \ingroup API_Modularized_Scheduler
  53. indicate if all workers have the same memory component
  54. \struct starpu_sched_tree
  55. \ingroup API_Modularized_Scheduler
  56. The actual scheduler
  57. \var starpu_sched_tree::root
  58. this is the entry module of the scheduler
  59. \var starpu_sched_tree::workers
  60. this is the set of workers available in this context, this value is used to mask workers in modules
  61. \var starpu_sched_tree::lock
  62. this lock protect concurrent access from the hypervisor and the application.
  63. \var starpu_sched_tree::sched_ctx_id
  64. the context id of the scheduler
  65. \fn struct starpu_sched_component *starpu_sched_component_create(struct starpu_sched_tree *tree)
  66. \ingroup API_Modularized_Scheduler
  67. allocate and initialize component field with defaults values :
  68. .pop_task make recursive call on father
  69. .estimated_load compute relative speedup and tasks in sub tree
  70. .estimated_end return the average of recursive call on children
  71. .add_child is starpu_sched_component_add_child
  72. .remove_child is starpu_sched_component_remove_child
  73. .notify_change_workers does nothing
  74. .deinit_data does nothing
  75. \fn void starpu_sched_component_destroy(struct starpu_sched_component *component)
  76. \ingroup API_Modularized_Scheduler
  77. free data allocated by starpu_sched_component_create and call component->deinit_data(component)
  78. set to null the member starpu_sched_component::fathers[sched_ctx_id] of all child if its equal to \p component
  79. \fn void starpu_sched_component_set_father(struct starpu_sched_component *component, struct starpu_sched_component *father_component, unsigned sched_ctx_id)
  80. \ingroup API_Modularized_Scheduler
  81. set component->fathers[sched_ctx_id] to father_component
  82. \fn int starpu_sched_component_can_execute_task(struct starpu_sched_component *component, struct starpu_task *task)
  83. \ingroup API_Modularized_Scheduler
  84. return true iff \p component can execute \p task, this function take into account the workers available in the scheduling context
  85. \fn int starpu_sched_component_execute_preds(struct starpu_sched_component *component, struct starpu_task *task, double *length);
  86. \ingroup API_Modularized_Scheduler
  87. return a non null value if \p component can execute \p task.
  88. write the execution prediction length for the best implementation of the best worker available and write this at \p length address.
  89. this result is more relevant if starpu_sched_component::is_homogeneous is non null.
  90. if a worker need to be calibrated for an implementation, nan is set to \p length.
  91. \fn double starpu_sched_component_transfer_length(struct starpu_sched_component *component, struct starpu_task *task);
  92. \ingroup API_Modularized_Scheduler
  93. return the average time to transfer \p task data to underlying \p component workers.
  94. \fn struct starpu_sched_component *starpu_sched_component_worker_get(int workerid)
  95. \ingroup API_Modularized_Scheduler
  96. return the struct starpu_sched_component corresponding to \p workerid. Undefined if \p workerid is not a valid workerid
  97. \fn int starpu_sched_component_is_worker(struct starpu_sched_component *component)
  98. \ingroup API_Modularized_Scheduler
  99. return true iff \p component is a worker component
  100. \fn int starpu_sched_component_is_simple_worker(struct starpu_sched_component *component)
  101. \ingroup API_Modularized_Scheduler
  102. return true iff \p component is a simple worker component
  103. \fn int starpu_sched_component_is_combined_worker(struct starpu_sched_component *component)
  104. \ingroup API_Modularized_Scheduler
  105. return true iff \p component is a combined worker component
  106. \fn int starpu_sched_component_worker_get_workerid(struct starpu_sched_component *worker_component)
  107. \ingroup API_Modularized_Scheduler
  108. return the workerid of \p worker_component, undefined if starpu_sched_component_is_worker(worker_component) == 0
  109. \fn struct starpu_sched_component *starpu_sched_component_fifo_create(void *arg)
  110. \ingroup API_Modularized_Scheduler
  111. Return a struct starpu_sched_component with a fifo. A stable sort is performed according to tasks priorities.
  112. A push_task call on this component does not perform recursive calls, underlying components will have to call pop_task to get it.
  113. starpu_sched_component::estimated_end function compute the estimated length by dividing the sequential length by the number of underlying workers. Do not take into account tasks that are currently executed.
  114. \fn int starpu_sched_component_is_fifo(struct starpu_sched_component *component)
  115. \ingroup API_Modularized_Scheduler
  116. return true iff \p component is a fifo component
  117. \fn struct starpu_sched_component *starpu_sched_component_work_stealing_create(struct starpu_sched_tree *tree, void *arg)
  118. \ingroup API_Modularized_Scheduler
  119. return a component that perform a work stealing scheduling. Tasks are pushed in a round robin way. estimated_end return the average of expected length of fifos, starting at the average of the expected_end of his children. When a worker have to steal a task, it steal a task in a round robin way, and get the last pushed task of the higher priority.
  120. \fn int starpu_sched_tree_work_stealing_push_task(struct starpu_task *task)
  121. \ingroup API_Modularized_Scheduler
  122. undefined if there is no work stealing component in the scheduler. If any, \p task is pushed in a default way if the caller is the application, and in the caller's fifo if its a worker.
  123. \fn int starpu_sched_component_is_work_stealing(struct starpu_sched_component *component)
  124. \ingroup API_Modularized_Scheduler
  125. return true iff \p component is a work stealing component
  126. \fn struct starpu_sched_component *starpu_sched_component_random_create(struct starpu_sched_tree *tree, void *arg)
  127. \ingroup API_Modularized_Scheduler
  128. create a component that perform a random scheduling
  129. \fn int starpu_sched_component_is_random(struct starpu_sched_component *);
  130. \ingroup API_Modularized_Scheduler
  131. return true iff \p component is a random component
  132. \fn struct starpu_sched_component *starpu_sched_component_heft_create(struct starpu_sched_tree *tree, struct starpu_mct_data *mct_data)
  133. \ingroup API_Modularized_Scheduler
  134. this component perform a heft scheduling
  135. \fn int starpu_sched_component_is_heft(struct starpu_sched_component *component)
  136. \ingroup API_Modularized_Scheduler
  137. return true iff \p component is a heft component
  138. \struct starpu_heft_data
  139. \ingroup API_Modularized_Scheduler
  140. starpu_sched_component_heft_create parameters
  141. \var starpu_heft_data::alpha
  142. coefficient applied to computation length
  143. \var starpu_heft_data::beta
  144. coefficient applied to communication length
  145. \var starpu_heft_data::gamma
  146. coefficient applied to power consumption
  147. \var starpu_heft_data::idle_power
  148. idle consumption of the machine
  149. \var starpu_heft_data::no_perf_model_component_create
  150. called to create the component to push task for whom no perf model is available
  151. \var starpu_heft_data::arg_no_perf_model
  152. argument passed to starpu_heft_data::no_perf_model_component_create
  153. \var starpu_heft_data::calibrating_component_create
  154. idem for tasks with an non calibrated implementation
  155. \var starpu_heft_data::arg_calibrating_component
  156. argument passed to starpu_heft_data::calibrating_component_create
  157. \fn struct starpu_sched_component *starpu_sched_component_best_implementation_create(struct starpu_sched_tree *tree, void *arg)
  158. \ingroup API_Modularized_Scheduler
  159. Select the implementation that offer the shortest computation length for the first worker that can execute the task.
  160. Or an implementation that need to be calibrated.
  161. Also set starpu_task::predicted and starpu_task::predicted_transfer for memory component of the first suitable workerid.
  162. If starpu_sched_component::push method is called and starpu_sched_component::nchild > 1 the result is undefined.
  163. \fn struct starpu_sched_tree *starpu_sched_tree_create(void)
  164. \ingroup API_Modularized_Scheduler
  165. create a empty initialized starpu_sched_tree
  166. \fn void starpu_sched_tree_destroy(struct starpu_sched_tree *tree)
  167. \ingroup API_Modularized_Scheduler
  168. destroy tree and free all non shared component in it.
  169. \fn void starpu_sched_component_destroy_rec (struct starpu_sched_component *component, unsigned sched_ctx_id)
  170. \ingroup API_Modularized_Scheduler
  171. recursively destroy non shared parts of a \p component 's tree
  172. \fn starpu_sched_component_available(struct starpu_sched_component *component)
  173. \ingroup API_Modularized_Scheduler
  174. notify all component's underlying workers that a task is available to pop
  175. \fn int starpu_sched_tree_push_task(struct starpu_task *task)
  176. \ingroup API_Modularized_Scheduler
  177. compatibility with starpu_sched_policy interface
  178. \fn struct starpu_task *starpu_sched_tree_pop_task(unsigned sched_ctx_id)
  179. \ingroup API_Modularized_Scheduler
  180. compatibility with starpu_sched_policy interface
  181. \fn void starpu_sched_tree_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
  182. \ingroup API_Modularized_Scheduler
  183. compatibility with starpu_sched_policy interface
  184. \fn void starpu_sched_tree_remove_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
  185. \ingroup API_Modularized_Scheduler
  186. compatibility with starpu_sched_policy interface
  187. \fn void starpu_sched_component_worker_pre_exec_hook(struct starpu_task *task)
  188. \ingroup API_Modularized_Scheduler
  189. compatibility with starpu_sched_policy interface
  190. update predictions for workers
  191. \fn void starpu_sched_component_worker_post_exec_hook(struct starpu_task *task)
  192. \ingroup API_Modularized_Scheduler
  193. compatibility with starpu_sched_policy interface
  194. \fn void starpu_sched_tree_update_workers(struct starpu_sched_tree *t)
  195. \ingroup API_Modularized_Scheduler
  196. recursively set all starpu_sched_component::workers, do not take into account shared parts (except workers).
  197. \fn void starpu_sched_tree_update_workers_in_ctx(struct starpu_sched_tree *t)
  198. \ingroup API_Modularized_Scheduler
  199. recursively set all starpu_sched_component::workers_in_ctx, do not take into account shared parts (except workers)
  200. \struct starpu_bitmap;
  201. \ingroup API_Modularized_Scheduler
  202. implement a simple bitmap
  203. \fn struct starpu_bitmap *starpu_bitmap_create(void)
  204. \ingroup API_Modularized_Scheduler
  205. create a empty starpu_bitmap
  206. \fn void starpu_bitmap_destroy(struct starpu_bitmap *b)
  207. \ingroup API_Modularized_Scheduler
  208. free a starpu_bitmap
  209. \fn void starpu_bitmap_set(struct starpu_bitmap *b, int e)
  210. \ingroup API_Modularized_Scheduler
  211. set bit \p e in \p b
  212. \fn void starpu_bitmap_unset(struct starpu_bitmap *b, int e)
  213. \ingroup API_Modularized_Scheduler
  214. unset bit \p e in \p b
  215. \fn void starpu_bitmap_unset_all(struct starpu_bitmap *b)
  216. \ingroup API_Modularized_Scheduler
  217. unset all bits in \b b
  218. \fn int starpu_bitmap_get(struct starpu_bitmap *b, int e);
  219. \ingroup API_Modularized_Scheduler
  220. return true iff bit \p e is set in \p b
  221. \fn int starpu_bitmap_cardinal(struct starpu_bitmap *b);
  222. \ingroup API_Modularized_Scheduler
  223. return the number of set bits in \p b
  224. \fn int starpu_bitmap_first(struct starpu_bitmap *b)
  225. \ingroup API_Modularized_Scheduler
  226. return the position of the first set bit of \p b, -1 if none
  227. \fn int starpu_bitmap_last(struct starpu_bitmap *b)
  228. \ingroup API_Modularized_Scheduler
  229. return the position of the last set bit of \p b, -1 if none
  230. \fn int starpu_bitmap_next(struct starpu_bitmap *b, int e)
  231. \ingroup API_Modularized_Scheduler
  232. return the position of set bit right after \p e in \p b, -1 if none
  233. \struct starpu_sched_component_composed_recipe;
  234. \ingroup API_Modularized_Scheduler
  235. parameters for starpu_sched_component_composed_component_create
  236. \fn struct starpu_sched_component_composed_recipe *starpu_sched_component_create_recipe(void)
  237. \ingroup API_Modularized_Scheduler
  238. return an empty recipe for a composed component, it should not be used without modification
  239. \fn struct starpu_sched_component_composed_recipe *starpu_sched_component_create_recipe_singleton(struct starpu_sched_component *(*create_component)(void *arg), void *arg)
  240. \ingroup API_Modularized_Scheduler
  241. return a recipe to build a composed component with a \p create_component
  242. \fn void starpu_sched_recipe_add_component(struct starpu_sched_component_composed_recipe *recipe, struct starpu_sched_component *(*create_component)(void *arg), void *arg)
  243. \ingroup API_Modularized_Scheduler
  244. add \p create_component under all previous components in recipe
  245. \fn void starpu_destroy_composed_sched_component_recipe(struct starpu_sched_component_composed_recipe *)
  246. \ingroup API_Modularized_Scheduler
  247. destroy composed_sched_component, this should be done after starpu_sched_component_composed_component_create was called
  248. \fn struct starpu_sched_component *starpu_sched_component_composed_component_create(struct starpu_sched_component_composed_recipe *recipe)
  249. \ingroup API_Modularized_Scheduler
  250. create a component that behave as all component of recipe where linked. Except that you cant use starpu_sched_component_is_foo function
  251. if recipe contain a single create_foo arg_foo pair, create_foo(arg_foo) is returned instead of a composed component
  252. \struct starpu_sched_specs
  253. \ingroup API_Modularized_Scheduler
  254. Define how build a scheduler according to topology. Each level (except for hwloc_machine_composed_sched_component) can be NULL, then
  255. the level is just skipped. Bugs everywhere, do not rely on.
  256. \var starpu_sched_specs::hwloc_machine_composed_sched_component
  257. the composed component to put on the top of the scheduler
  258. this member must not be NULL
  259. \var starpu_sched_specs::hwloc_component_composed_sched_component
  260. the composed component to put for each memory component
  261. \var starpu_sched_specs::hwloc_socket_composed_sched_component
  262. the composed component to put for each socket
  263. \var starpu_sched_specs::hwloc_cache_composed_sched_component
  264. the composed component to put for each cache
  265. \var starpu_sched_specs::worker_composed_sched_component
  266. a function that return a starpu_sched_component_composed_recipe to put on top of a worker of type \p archtype.
  267. NULL is a valid return value, then no component will be added on top
  268. \var starpu_sched_specs::mix_heterogeneous_workers
  269. this flag is a dirty hack because of the poor expressivity of this interface. As example, if you want to build
  270. a heft component with a fifo component per numa component, and you also have GPUs, if this flag is set, GPUs will share those fifos.
  271. If this flag is not set, a new fifo will be built for each of them (if they have the same starpu_perf_arch and the same
  272. numa component it will be shared
  273. \fn struct starpu_sched_tree *starpu_sched_component_make_scheduler(unsigned sched_ctx_id, struct starpu_sched_specs s);
  274. \ingroup API_Modularized_Scheduler
  275. this function build a scheduler for \p sched_ctx_id according to \p s and the hwloc topology of the machine.
  276. */