modularized_scheduler.doxy 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /*! \defgroup API_Modularized_Scheduler Modularized Scheduler Interface
  2. \struct starpu_sched_node
  3. \ingroup API_Modularized_Scheduler
  4. This structure represent a scheduler module.
  5. \var starpu_sched_node::push_task
  6. push a task in the scheduler module.
  7. \var starpu_sched_node::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_node::fathers[sched_ctx_id] to perform a recursive call.
  10. \var starpu_sched_node::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_node::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_node::nchilds
  17. the number of modules downstairs
  18. \var starpu_sched_node::childs
  19. modules downstairs
  20. \var starpu_sched_node::workers
  21. this member contain the set of underlying workers
  22. \var starpu_sched_node::workers_in_ctx
  23. this member contain the subset of starpu_sched_node::workers that is currently available in the context
  24. The push method should take this member into account.
  25. \var starpu_sched_node::properties
  26. flags starpu_sched_node_properties for things
  27. \var starpu_sched_node::data
  28. data used by the scheduler module
  29. \var starpu_sched_node::add_child
  30. add a child to node
  31. \var starpu_sched_node::remove_child
  32. remove a child from node
  33. \var starpu_sched_node::fathers
  34. the array of scheduler module above indexed by scheduling context index
  35. \var starpu_sched_node::notify_change_workers
  36. this function is called when starpu_sched_node::workers_in_ctx or starpu_sched_node::workers is changed
  37. \var starpu_sched_node::deinit_data
  38. called by starpu_sched_node_destroy. Should free data allocated during creation
  39. \var starpu_sched_node::obj
  40. the hwloc object associated to scheduler module
  41. \enum starpu_sched_node_properties
  42. \ingroup API_Modularized_Scheduler
  43. flags for starpu_sched_node::properties
  44. \var STARPU_SCHED_NODE_HOMOGENEOUS
  45. indicate that all workers have the same starpu_worker_archtype
  46. \var STARPU_SCHED_NODE_SINGLE_MEMORY_NODE
  47. indicate that all workers have the same memory node
  48. \def STARPU_SCHED_NODE_IS_HOMOGENEOUS
  49. \ingroup API_Modularized_Scheduler
  50. \def STARPU_SCHED_NODE_HOMOGENEOUS
  51. indicate if node is homogeneous
  52. \def STARPU_SCHED_NODE_IS_SINGLE_MEMORY_NODE
  53. \ingroup API_Modularized_Scheduler
  54. indicate if all workers have the same memory node
  55. \struct starpu_sched_tree
  56. \ingroup API_Modularized_Scheduler
  57. The actual scheduler
  58. \var starpu_sched_tree::root
  59. this is the entry module of the scheduler
  60. \var starpu_sched_tree::workers
  61. this is the set of workers available in this context, this value is used to mask workers in modules
  62. \var starpu_sched_tree::lock
  63. this lock protect concurrent access from the hypervisor and the application.
  64. \var starpu_sched_tree::sched_ctx_id
  65. the context id of the scheduler
  66. \fn struct starpu_sched_node * starpu_sched_node_create(void)
  67. \ingroup API_Modularized_Scheduler
  68. allocate and initialize node field with defaults values :
  69. .pop_task make recursive call on father
  70. .estimated_load compute relative speedup and tasks in sub tree
  71. .estimated_end return the average of recursive call on childs
  72. .add_child is starpu_sched_node_add_child
  73. .remove_child is starpu_sched_node_remove_child
  74. .notify_change_workers does nothing
  75. .deinit_data does nothing
  76. \fn void starpu_sched_node_destroy(struct starpu_sched_node * node)
  77. \ingroup API_Modularized_Scheduler
  78. free data allocated by starpu_sched_node_create and call node->deinit_data(node)
  79. set to null the member starpu_sched_node::fathers[sched_ctx_id] of all child if its equal to \p node
  80. \fn void starpu_sched_node_set_father(struct starpu_sched_node * node, struct starpu_sched_node * father_node, unsigned sched_ctx_id)
  81. \ingroup API_Modularized_Scheduler
  82. set node->fathers[sched_ctx_id] to father_node
  83. \fn void starpu_sched_node_add_child(struct starpu_sched_node* node, struct starpu_sched_node * child)
  84. \ingroup API_Modularized_Scheduler
  85. add child to node->childs and increment nchilds as well.
  86. and dont modify child->fathers
  87. \p child must not be already in starpu_sched_node::childs of \p node
  88. \fn void starpu_sched_node_remove_child(struct starpu_sched_node * node, struct starpu_sched_node * child)
  89. \ingroup API_Modularized_Scheduler
  90. remove child from node->childs and decrements nchilds
  91. \p child must be in starpu_sched_node::child of \p node
  92. \fn int starpu_sched_node_can_execute_task(struct starpu_sched_node * node, struct starpu_task * task)
  93. \ingroup API_Modularized_Scheduler
  94. return true iff \p node can execute \p task, this function take into account the workers available in the scheduling context
  95. \fn int STARPU_WARN_UNUSED_RESULT starpu_sched_node_execute_preds(struct starpu_sched_node * node, struct starpu_task * task, double * length);
  96. \ingroup API_Modularized_Scheduler
  97. return a non null value if \p node can execute \p task.
  98. write the execution prediction length for the best implementation of the best worker available and write this at \p length address.
  99. this result is more relevant if starpu_sched_node::is_homogeneous is non null.
  100. if a worker need to be calibrated for an implementation, nan is set to \p length.
  101. \fn double starpu_sched_node_transfer_length(struct starpu_sched_node * node, struct starpu_task * task);
  102. \ingroup API_Modularized_Scheduler
  103. return the average time to transfer \p task data to underlying \p node workers.
  104. \fn struct starpu_sched_node * starpu_sched_node_worker_get(int workerid)
  105. \ingroup API_Modularized_Scheduler
  106. return the struct starpu_sched_node corresponding to \p workerid. Undefined if \p workerid is not a valid workerid
  107. \fn int starpu_sched_node_is_worker(struct starpu_sched_node * node)
  108. \ingroup API_Modularized_Scheduler
  109. return true iff \p node is a worker node
  110. \fn int starpu_sched_node_is_simple_worker(struct starpu_sched_node * node)
  111. \ingroup API_Modularized_Scheduler
  112. return true iff \p node is a simple worker node
  113. \fn int starpu_sched_node_is_combined_worker(struct starpu_sched_node * node)
  114. \ingroup API_Modularized_Scheduler
  115. return true iff \p node is a combined worker node
  116. \fn int starpu_sched_node_worker_get_workerid(struct starpu_sched_node * worker_node)
  117. \ingroup API_Modularized_Scheduler
  118. return the workerid of \p worker_node, undefined if starpu_sched_node_is_worker(worker_node) == 0
  119. \fn struct starpu_sched_node * starpu_sched_node_fifo_create(void * arg STARPU_ATTRIBUTE_UNUSED)
  120. \ingroup API_Modularized_Scheduler
  121. Return a struct starpu_sched_node with a fifo. A stable sort is performed according to tasks priorities.
  122. A push_task call on this node does not perform recursive calls, underlaying nodes will have to call pop_task to get it.
  123. starpu_sched_node::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.
  124. \fn int starpu_sched_node_is_fifo(struct starpu_sched_node * node)
  125. \ingroup API_Modularized_Scheduler
  126. return true iff \p node is a fifo node
  127. \fn struct starpu_sched_node * starpu_sched_node_work_stealing_create(void * arg STARPU_ATTRIBUTE_UNUSED)
  128. \ingroup API_Modularized_Scheduler
  129. return a node 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 childs. 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.
  130. \fn int starpu_sched_tree_work_stealing_push_task(struct starpu_task *task)
  131. \ingroup API_Modularized_Scheduler
  132. undefined if there is no work stealing node 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.
  133. \fn int starpu_sched_node_is_work_stealing(struct starpu_sched_node * node)
  134. \ingroup API_Modularized_Scheduler
  135. return true iff \p node is a work stealing node
  136. \fn struct starpu_sched_node * starpu_sched_node_random_create(void * arg STARPU_ATTRIBUTE_UNUSED)
  137. \ingroup API_Modularized_Scheduler
  138. create a node that perform a random scheduling.
  139. \fn int starpu_sched_node_is_random(struct starpu_sched_node *);
  140. \ingroup API_Modularized_Scheduler
  141. return true iff \p node is a random node
  142. \fn struct starpu_sched_node * starpu_sched_node_heft_create(struct starpu_heft_data * heft_data)
  143. \ingroup API_Modularized_Scheduler
  144. this node perform a heft scheduling using data provided by estimated_execute_preds, if no pred_model are available a random node is used to push tasks.
  145. \fn int starpu_sched_node_is_heft(struct starpu_sched_node * node)
  146. \ingroup API_Modularized_Scheduler
  147. return true iff \p node is a heft node
  148. \struct starpu_heft_data
  149. \ingroup API_Modularized_Scheduler
  150. starpu_sched_node_heft_create parameters
  151. \var starpu_heft_data::alpha
  152. coefficient applied to computation length
  153. \var starpu_heft_data::beta
  154. coefficient applied to communication length
  155. \var starpu_heft_data::gamma
  156. coefficient applied to power consumption
  157. \var starpu_heft_data::idle_power
  158. idle consumption of the machine
  159. \var starpu_heft_data::no_perf_model_node_create
  160. called to create the node to push task for whom no perf model is available
  161. \var starpu_heft_data::arg_no_perf_model
  162. argument passed to starpu_heft_data::no_perf_model_node_create
  163. \var starpu_heft_data::calibrating_node_create
  164. idem for tasks with an non calibrated implementation
  165. \var starpu_heft_data::arg_calibrating_node
  166. argument passed to starpu_heft_data::calibrating_node_create
  167. \fn struct starpu_sched_node * starpu_sched_node_best_implementation_create(void * arg STARPU_ATTRIBUTE_UNUSED);
  168. \ingroup API_Modularized_Scheduler
  169. Select the implementation that offer the shortest computation length for the first worker that can execute the task.
  170. Or an implementation that need to be calibrated.
  171. Also set starpu_task::predicted and starpu_task::predicted_transfer for memory node of the first suitable workerid.
  172. If starpu_sched_node::push method is called and starpu_sched_node::nchild > 1 the result is undefined.
  173. \fn struct starpu_sched_tree * starpu_sched_tree_create(void)
  174. \ingroup API_Modularized_Scheduler
  175. create a empty initialized starpu_sched_tree
  176. \fn void starpu_sched_tree_destroy(struct starpu_sched_tree * tree, unsigned sched_ctx_id)
  177. \ingroup API_Modularized_Scheduler
  178. destroy tree and free all non shared node in it.
  179. \fn void starpu_sched_node_destroy_rec (struct starpu_sched_node *node, unsigned sched_ctx_id)
  180. \ingroup API_Modularized_Scheduler
  181. recursively destroy non shared parts of a \p node 's tree
  182. \fn starpu_sched_node_available(struct starpu_sched_node * node)
  183. \ingroup API_Modularized_Scheduler
  184. notify all node's underlying workers that a task is available to pop
  185. \fn int starpu_sched_tree_push_task(struct starpu_task * task)
  186. \ingroup API_Modularized_Scheduler
  187. compatibility with starpu_sched_policy interface
  188. \fn struct starpu_task * starpu_sched_tree_pop_task(unsigned sched_ctx_id)
  189. \ingroup API_Modularized_Scheduler
  190. compatibility with starpu_sched_policy interface
  191. \fn void starpu_sched_tree_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
  192. \ingroup API_Modularized_Scheduler
  193. compatibility with starpu_sched_policy interface
  194. \fn void starpu_sched_tree_remove_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
  195. \ingroup API_Modularized_Scheduler
  196. compatibility with starpu_sched_policy interface
  197. \fn void starpu_sched_node_worker_pre_exec_hook(struct starpu_task * task)
  198. \ingroup API_Modularized_Scheduler
  199. compatibility with starpu_sched_policy interface
  200. update predictions for workers
  201. \fn void starpu_sched_node_worker_post_exec_hook(struct starpu_task * task)
  202. \ingroup API_Modularized_Scheduler
  203. compatibility with starpu_sched_policy interface
  204. \fn void starpu_sched_tree_update_workers(struct starpu_sched_tree * t)
  205. \ingroup API_Modularized_Scheduler
  206. recursively set all starpu_sched_node::workers, do not take into account shared parts (except workers).
  207. \fn void starpu_sched_tree_update_workers_in_ctx(struct starpu_sched_tree * t)
  208. \ingroup API_Modularized_Scheduler
  209. recursively set all starpu_sched_node::workers_in_ctx, do not take into account shared parts (except workers)
  210. \struct starpu_bitmap;
  211. \ingroup API_Modularized_Scheduler
  212. implement a simple bitmap
  213. \fn struct starpu_bitmap * starpu_bitmap_create(void)
  214. \ingroup API_Modularized_Scheduler
  215. create a empty starpu_bitmap
  216. \fn void starpu_bitmap_destroy(struct starpu_bitmap *)
  217. \ingroup API_Modularized_Scheduler
  218. free a starpu_bitmap
  219. \fn void starpu_bitmap_set(struct starpu_bitmap * bitmap, int e)
  220. \ingroup API_Modularized_Scheduler
  221. set bit \p e in \p bitmap
  222. \fn void starpu_bitmap_unset(struct starpu_bitmap * bitmap, int e)
  223. \ingroup API_Modularized_Scheduler
  224. unset bit \p e in \p bitmap
  225. \fn void starpu_bitmap_unset_all(struct starpu_bitmap * bitmap)
  226. \ingroup API_Modularized_Scheduler
  227. unset all bits in \b bitmap
  228. \fn int starpu_bitmap_get(struct starpu_bitmap * bitmap, int e);
  229. \ingroup API_Modularized_Scheduler
  230. return true iff bit \p e is set in \p bitmap
  231. \fn int starpu_bitmap_cardinal(struct starpu_bitmap * bitmap);
  232. \ingroup API_Modularized_Scheduler
  233. return the number of set bits in \p bitmap
  234. \fn int starpu_bitmap_first(struct starpu_bitmap * bitmap)
  235. \ingroup API_Modularized_Scheduler
  236. return the position of the first set bit of \p bitmap, -1 if none
  237. \fn int starpu_bitmap_last(struct starpu_bitmap * bitmap)
  238. \ingroup API_Modularized_Scheduler
  239. return the position of the last set bit of \p bitmap, -1 if none
  240. \fn int starpu_bitmap_next(struct starpu_bitmap *, int e)
  241. \ingroup API_Modularized_Scheduler
  242. return the position of set bit right after \p e in \p bitmap, -1 if none
  243. */