modularized_scheduler.doxy 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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(void)
  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 void starpu_sched_component_add_child(struct starpu_sched_component* component, struct starpu_sched_component * child)
  83. \ingroup API_Modularized_Scheduler
  84. add child to component->children and increment nchildren as well.
  85. and do not modify child->fathers
  86. \p child must not be already in starpu_sched_component::children of \p component
  87. \fn void starpu_sched_component_remove_child(struct starpu_sched_component * component, struct starpu_sched_component * child)
  88. \ingroup API_Modularized_Scheduler
  89. remove child from component->children and decrements nchildren
  90. \p child must be in starpu_sched_component::child of \p component
  91. \fn int starpu_sched_component_can_execute_task(struct starpu_sched_component * component, struct starpu_task * task)
  92. \ingroup API_Modularized_Scheduler
  93. return true iff \p component can execute \p task, this function take into account the workers available in the scheduling context
  94. \fn int STARPU_WARN_UNUSED_RESULT starpu_sched_component_execute_preds(struct starpu_sched_component * component, struct starpu_task * task, double * length);
  95. \ingroup API_Modularized_Scheduler
  96. return a non null value if \p component can execute \p task.
  97. write the execution prediction length for the best implementation of the best worker available and write this at \p length address.
  98. this result is more relevant if starpu_sched_component::is_homogeneous is non null.
  99. if a worker need to be calibrated for an implementation, nan is set to \p length.
  100. \fn double starpu_sched_component_transfer_length(struct starpu_sched_component * component, struct starpu_task * task);
  101. \ingroup API_Modularized_Scheduler
  102. return the average time to transfer \p task data to underlying \p component workers.
  103. \fn struct starpu_sched_component * starpu_sched_component_worker_get(int workerid)
  104. \ingroup API_Modularized_Scheduler
  105. return the struct starpu_sched_component corresponding to \p workerid. Undefined if \p workerid is not a valid workerid
  106. \fn int starpu_sched_component_is_worker(struct starpu_sched_component * component)
  107. \ingroup API_Modularized_Scheduler
  108. return true iff \p component is a worker component
  109. \fn int starpu_sched_component_is_simple_worker(struct starpu_sched_component * component)
  110. \ingroup API_Modularized_Scheduler
  111. return true iff \p component is a simple worker component
  112. \fn int starpu_sched_component_is_combined_worker(struct starpu_sched_component * component)
  113. \ingroup API_Modularized_Scheduler
  114. return true iff \p component is a combined worker component
  115. \fn int starpu_sched_component_worker_get_workerid(struct starpu_sched_component * worker_component)
  116. \ingroup API_Modularized_Scheduler
  117. return the workerid of \p worker_component, undefined if starpu_sched_component_is_worker(worker_component) == 0
  118. \fn struct starpu_sched_component * starpu_sched_component_fifo_create(void * arg STARPU_ATTRIBUTE_UNUSED)
  119. \ingroup API_Modularized_Scheduler
  120. Return a struct starpu_sched_component with a fifo. A stable sort is performed according to tasks priorities.
  121. A push_task call on this component does not perform recursive calls, underlying components will have to call pop_task to get it.
  122. 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.
  123. \fn int starpu_sched_component_is_fifo(struct starpu_sched_component * component)
  124. \ingroup API_Modularized_Scheduler
  125. return true iff \p component is a fifo component
  126. \fn struct starpu_sched_component * starpu_sched_component_work_stealing_create(void * arg STARPU_ATTRIBUTE_UNUSED)
  127. \ingroup API_Modularized_Scheduler
  128. 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.
  129. \fn int starpu_sched_tree_work_stealing_push_task(struct starpu_task *task)
  130. \ingroup API_Modularized_Scheduler
  131. 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.
  132. \fn int starpu_sched_component_is_work_stealing(struct starpu_sched_component * component)
  133. \ingroup API_Modularized_Scheduler
  134. return true iff \p component is a work stealing component
  135. \fn struct starpu_sched_component * starpu_sched_component_random_create(void * arg STARPU_ATTRIBUTE_UNUSED)
  136. \ingroup API_Modularized_Scheduler
  137. create a component that perform a random scheduling
  138. \fn int starpu_sched_component_is_random(struct starpu_sched_component *);
  139. \ingroup API_Modularized_Scheduler
  140. return true iff \p component is a random component
  141. \fn struct starpu_sched_component * starpu_sched_component_heft_create(struct starpu_heft_data * heft_data)
  142. \ingroup API_Modularized_Scheduler
  143. this component perform a heft scheduling
  144. \fn int starpu_sched_component_is_heft(struct starpu_sched_component * component)
  145. \ingroup API_Modularized_Scheduler
  146. return true iff \p component is a heft component
  147. \struct starpu_heft_data
  148. \ingroup API_Modularized_Scheduler
  149. starpu_sched_component_heft_create parameters
  150. \var starpu_heft_data::alpha
  151. coefficient applied to computation length
  152. \var starpu_heft_data::beta
  153. coefficient applied to communication length
  154. \var starpu_heft_data::gamma
  155. coefficient applied to power consumption
  156. \var starpu_heft_data::idle_power
  157. idle consumption of the machine
  158. \var starpu_heft_data::no_perf_model_component_create
  159. called to create the component to push task for whom no perf model is available
  160. \var starpu_heft_data::arg_no_perf_model
  161. argument passed to starpu_heft_data::no_perf_model_component_create
  162. \var starpu_heft_data::calibrating_component_create
  163. idem for tasks with an non calibrated implementation
  164. \var starpu_heft_data::arg_calibrating_component
  165. argument passed to starpu_heft_data::calibrating_component_create
  166. \fn struct starpu_sched_component * starpu_sched_component_best_implementation_create(void * arg STARPU_ATTRIBUTE_UNUSED);
  167. \ingroup API_Modularized_Scheduler
  168. Select the implementation that offer the shortest computation length for the first worker that can execute the task.
  169. Or an implementation that need to be calibrated.
  170. Also set starpu_task::predicted and starpu_task::predicted_transfer for memory component of the first suitable workerid.
  171. If starpu_sched_component::push method is called and starpu_sched_component::nchild > 1 the result is undefined.
  172. \fn struct starpu_sched_tree * starpu_sched_tree_create(void)
  173. \ingroup API_Modularized_Scheduler
  174. create a empty initialized starpu_sched_tree
  175. \fn void starpu_sched_tree_destroy(struct starpu_sched_tree * tree, unsigned sched_ctx_id)
  176. \ingroup API_Modularized_Scheduler
  177. destroy tree and free all non shared component in it.
  178. \fn void starpu_sched_component_destroy_rec (struct starpu_sched_component *component, unsigned sched_ctx_id)
  179. \ingroup API_Modularized_Scheduler
  180. recursively destroy non shared parts of a \p component 's tree
  181. \fn starpu_sched_component_available(struct starpu_sched_component * component)
  182. \ingroup API_Modularized_Scheduler
  183. notify all component's underlying workers that a task is available to pop
  184. \fn int starpu_sched_tree_push_task(struct starpu_task * task)
  185. \ingroup API_Modularized_Scheduler
  186. compatibility with starpu_sched_policy interface
  187. \fn struct starpu_task * starpu_sched_tree_pop_task(unsigned sched_ctx_id)
  188. \ingroup API_Modularized_Scheduler
  189. compatibility with starpu_sched_policy interface
  190. \fn void starpu_sched_tree_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
  191. \ingroup API_Modularized_Scheduler
  192. compatibility with starpu_sched_policy interface
  193. \fn void starpu_sched_tree_remove_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
  194. \ingroup API_Modularized_Scheduler
  195. compatibility with starpu_sched_policy interface
  196. \fn void starpu_sched_component_worker_pre_exec_hook(struct starpu_task * task)
  197. \ingroup API_Modularized_Scheduler
  198. compatibility with starpu_sched_policy interface
  199. update predictions for workers
  200. \fn void starpu_sched_component_worker_post_exec_hook(struct starpu_task * task)
  201. \ingroup API_Modularized_Scheduler
  202. compatibility with starpu_sched_policy interface
  203. \fn void starpu_sched_tree_update_workers(struct starpu_sched_tree * t)
  204. \ingroup API_Modularized_Scheduler
  205. recursively set all starpu_sched_component::workers, do not take into account shared parts (except workers).
  206. \fn void starpu_sched_tree_update_workers_in_ctx(struct starpu_sched_tree * t)
  207. \ingroup API_Modularized_Scheduler
  208. recursively set all starpu_sched_component::workers_in_ctx, do not take into account shared parts (except workers)
  209. \struct starpu_bitmap;
  210. \ingroup API_Modularized_Scheduler
  211. implement a simple bitmap
  212. \fn struct starpu_bitmap * starpu_bitmap_create(void)
  213. \ingroup API_Modularized_Scheduler
  214. create a empty starpu_bitmap
  215. \fn void starpu_bitmap_destroy(struct starpu_bitmap *)
  216. \ingroup API_Modularized_Scheduler
  217. free a starpu_bitmap
  218. \fn void starpu_bitmap_set(struct starpu_bitmap * bitmap, int e)
  219. \ingroup API_Modularized_Scheduler
  220. set bit \p e in \p bitmap
  221. \fn void starpu_bitmap_unset(struct starpu_bitmap * bitmap, int e)
  222. \ingroup API_Modularized_Scheduler
  223. unset bit \p e in \p bitmap
  224. \fn void starpu_bitmap_unset_all(struct starpu_bitmap * bitmap)
  225. \ingroup API_Modularized_Scheduler
  226. unset all bits in \b bitmap
  227. \fn int starpu_bitmap_get(struct starpu_bitmap * bitmap, int e);
  228. \ingroup API_Modularized_Scheduler
  229. return true iff bit \p e is set in \p bitmap
  230. \fn int starpu_bitmap_cardinal(struct starpu_bitmap * bitmap);
  231. \ingroup API_Modularized_Scheduler
  232. return the number of set bits in \p bitmap
  233. \fn int starpu_bitmap_first(struct starpu_bitmap * bitmap)
  234. \ingroup API_Modularized_Scheduler
  235. return the position of the first set bit of \p bitmap, -1 if none
  236. \fn int starpu_bitmap_last(struct starpu_bitmap * bitmap)
  237. \ingroup API_Modularized_Scheduler
  238. return the position of the last set bit of \p bitmap, -1 if none
  239. \fn int starpu_bitmap_next(struct starpu_bitmap *, int e)
  240. \ingroup API_Modularized_Scheduler
  241. return the position of set bit right after \p e in \p bitmap, -1 if none
  242. \struct starpu_sched_component_composed_recipe;
  243. \ingroup API_Modularized_Scheduler
  244. parameters for starpu_sched_component_composed_component_create
  245. \fn struct starpu_sched_component_composed_recipe * starpu_sched_component_create_recipe(void)
  246. \ingroup API_Modularized_Scheduler
  247. return an empty recipe for a composed component, it should not be used without modification
  248. \fn struct starpu_sched_component_composed_recipe * starpu_sched_component_create_recipe_singleton(struct starpu_sched_component *(*create_component)(void * arg), void * arg)
  249. \ingroup API_Modularized_Scheduler
  250. return a recipe to build a composed component with a \p create_component
  251. \fn void starpu_sched_recipe_add_component(struct starpu_sched_component_composed_recipe * recipe, struct starpu_sched_component *(*create_component)(void * arg), void * arg)
  252. \ingroup API_Modularized_Scheduler
  253. add \p create_component under all previous components in recipe
  254. \fn void starpu_destroy_composed_sched_component_recipe(struct starpu_sched_component_composed_recipe *)
  255. \ingroup API_Modularized_Scheduler
  256. destroy composed_sched_component, this should be done after starpu_sched_component_composed_component_create was called
  257. \fn struct starpu_sched_component * starpu_sched_component_composed_component_create(struct starpu_sched_component_composed_recipe * recipe)
  258. \ingroup API_Modularized_Scheduler
  259. create a component that behave as all component of recipe where linked. Except that you cant use starpu_sched_component_is_foo function
  260. if recipe contain a single create_foo arg_foo pair, create_foo(arg_foo) is returned instead of a composed component
  261. \struct starpu_sched_specs
  262. \ingroup API_Modularized_Scheduler
  263. Define how build a scheduler according to topology. Each level (except for hwloc_machine_composed_sched_component) can be NULL, then
  264. the level is just skipped. Bugs everywhere, do not rely on.
  265. \var starpu_sched_specs::hwloc_machine_composed_sched_component
  266. the composed component to put on the top of the scheduler
  267. this member must not be NULL
  268. \var starpu_sched_specs::hwloc_component_composed_sched_component
  269. the composed component to put for each memory component
  270. \var starpu_sched_specs::hwloc_socket_composed_sched_component
  271. the composed component to put for each socket
  272. \var starpu_sched_specs::hwloc_cache_composed_sched_component
  273. the composed component to put for each cache
  274. \var starpu_sched_specs::worker_composed_sched_component
  275. a function that return a starpu_sched_component_composed_recipe to put on top of a worker of type \p archtype.
  276. NULL is a valid return value, then no component will be added on top
  277. \var starpu_sched_specs::mix_heterogeneous_workers
  278. this flag is a dirty hack because of the poor expressivity of this interface. As example, if you want to build
  279. 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.
  280. 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
  281. numa component it will be shared
  282. \fn struct starpu_sched_tree * starpu_sched_component_make_scheduler(unsigned sched_ctx_id, struct starpu_sched_specs s);
  283. \ingroup API_Modularized_Scheduler
  284. this function build a scheduler for \p sched_ctx_id according to \p s and the hwloc topology of the machine.
  285. */