scheduling_contexts.doxy 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 Institut National de Recherche en Informatique et Automatique
  6. * See the file version.doxy for copying conditions.
  7. */
  8. /*! \defgroup Scheduling_Contexts Scheduling Contexts
  9. \brief StarPU permits on one hand grouping workers in combined workers
  10. in order to execute a parallel task and on the other hand grouping
  11. tasks in bundles that will be executed by a single specified worker.
  12. In contrast when we group workers in scheduling contexts we submit
  13. starpu tasks to them and we schedule them with the policy assigned to
  14. the context. Scheduling contexts can be created, deleted and modified
  15. dynamically.
  16. \enum starpu_worker_collection_type
  17. \ingroup Scheduling_Contexts
  18. types of structures the worker collection can implement
  19. \var starpu_worker_collection_type::STARPU_WORKER_LIST
  20. \ingroup Scheduling_Contexts
  21. List of workers
  22. \struct starpu_sched_ctx_performance_counters
  23. \brief Performance counters used by the starpu to indicate the
  24. hypervisor how the application and the resources are executing.
  25. \ingroup Scheduling_Contexts
  26. \var starpu_sched_ctx_performance_counters::notify_idle_cycle
  27. Informs the hypervisor for how long a worker has been idle in the specified context
  28. \var starpu_sched_ctx_performance_counters::notify_idle_end
  29. Informs the hypervisor that after a period of idle, the worker has just executed a task in the specified context. The idle counter it though reset.
  30. \var starpu_sched_ctx_performance_counters::notify_pushed_task
  31. Notifies the hypervisor a task has been scheduled on the queue of the worker corresponding to the specified context
  32. \var starpu_sched_ctx_performance_counters::notify_poped_task
  33. Informs the hypervisor a task executing a specified number of instructions has been poped from the worker
  34. \var starpu_sched_ctx_performance_counters::notify_post_exec_hook
  35. Notifies the hypervisor a task has just been executed
  36. @name Scheduling Contexts Basic API
  37. \ingroup Scheduling_Contexts
  38. \fn unsigned starpu_sched_ctx_create(const char *policy_name, int *workerids_ctx, int nworkers_ctx, const char *sched_ctx_name)
  39. \ingroup Scheduling_Contexts
  40. This function creates a scheduling context which uses the scheduling
  41. policy \p policy_name and assigns the workers in \p workerids_ctx to
  42. execute the tasks submitted to it.
  43. The return value represents the identifier of the context that has
  44. just been created. It will be further used to indicate the context the
  45. tasks will be submitted to. The return value should be at most
  46. STARPU_NMAX_SCHED_CTXS.
  47. \fn unsigned starpu_sched_ctx_create_inside_interval(const char *policy_name, const char *sched_name, int min_ncpus, int max_ncpus, int min_ngpus, int max_ngpus, unsigned allow_overlap)
  48. \ingroup Scheduling_Contexts
  49. Create a context indicating an approximate interval of resources
  50. \fn void starpu_sched_ctx_delete(unsigned sched_ctx_id)
  51. \ingroup Scheduling_Contexts
  52. Delete scheduling context \p sched_ctx_id and transfer remaining
  53. workers to the inheritor scheduling context.
  54. \fn void starpu_sched_ctx_add_workers(int *workerids_ctx, int nworkers_ctx, unsigned sched_ctx_id)
  55. \ingroup Scheduling_Contexts
  56. This function adds dynamically the workers in \p workerids_ctx to the
  57. context \p sched_ctx_id. The last argument cannot be greater than
  58. STARPU_NMAX_SCHED_CTXS.
  59. \fn void starpu_sched_ctx_remove_workers(int *workerids_ctx, int nworkers_ctx, unsigned sched_ctx_id)
  60. \ingroup Scheduling_Contexts
  61. This function removes the workers in \p workerids_ctx from the context
  62. \p sched_ctx_id. The last argument cannot be greater than
  63. STARPU_NMAX_SCHED_CTXS.
  64. \fn void starpu_sched_ctx_set_inheritor(unsigned sched_ctx_id, unsigned inheritor)
  65. \ingroup Scheduling_Contexts
  66. Indicate which context whill inherit the resources of this context
  67. when he will be deleted.
  68. \fn void starpu_sched_ctx_set_context(unsigned *sched_ctx_id)
  69. \ingroup Scheduling_Contexts
  70. Set the scheduling context the subsequent tasks will be submitted to
  71. \fn unsigned starpu_sched_ctx_get_context(void)
  72. \ingroup Scheduling_Contexts
  73. Return the scheduling context the tasks are currently submitted to
  74. \fn void starpu_sched_ctx_stop_task_submission(void)
  75. \ingroup Scheduling_Contexts
  76. Stop submitting tasks from the empty context list until the next time
  77. the context has time to check the empty context list
  78. \fn void starpu_sched_ctx_finished_submit(unsigned sched_ctx_id);
  79. \ingroup Scheduling_Contexts
  80. Indicate starpu that the application finished submitting to this
  81. context in order to move the workers to the inheritor as soon as
  82. possible.
  83. \fn unsigned starpu_sched_ctx_get_nworkers(unsigned sched_ctx_id)
  84. \ingroup Scheduling_Contexts
  85. Return the number of workers managed by the specified contexts
  86. (Usually needed to verify if it manages any workers or if it should be
  87. blocked)
  88. \fn unsigned starpu_sched_ctx_get_nshared_workers(unsigned sched_ctx_id, unsigned sched_ctx_id2)
  89. \ingroup Scheduling_Contexts
  90. Return the number of workers shared by two contexts.
  91. \fn unsigned starpu_sched_ctx_contains_worker(int workerid, unsigned sched_ctx_id)
  92. \ingroup Scheduling_Contexts
  93. Return 1 if the worker belongs to the context and 0 otherwise
  94. \fn unsigned starpu_sched_ctx_overlapping_ctxs_on_worker(int workerid)
  95. \ingroup Scheduling_Contexts
  96. Check if a worker is shared between several contexts
  97. \fn unsigned starpu_sched_ctx_is_ctxs_turn(int workerid, unsigned sched_ctx_id)
  98. \ingroup Scheduling_Contexts
  99. Manage sharing of resources between contexts: checkOB which ctx has
  100. its turn to pop.
  101. \fn void starpu_sched_ctx_set_turn_to_other_ctx(int workerid, unsigned sched_ctx_id)
  102. \ingroup Scheduling_Contexts
  103. Manage sharing of resources between contexts: by default a round_robin
  104. strategy is executed but the user can interfere to tell which ctx has
  105. its turn to pop.
  106. \fn double starpu_sched_ctx_get_max_time_worker_on_ctx(void)
  107. \ingroup Scheduling_Contexts
  108. Time sharing a resources, indicate how long a worker has been active
  109. in the current sched_ctx.
  110. @name Scheduling Context Priorities
  111. \ingroup Scheduling_Contexts
  112. \def STARPU_MIN_PRIO
  113. \ingroup Scheduling_Contexts
  114. Provided for legacy reasons.
  115. \def STARPU_MAX_PRIO
  116. \ingroup Scheduling_Contexts
  117. Provided for legacy reasons.
  118. \def STARPU_DEFAULT_PRIO
  119. \ingroup Scheduling_Contexts
  120. By convention, the default priority level should be 0 so that we can
  121. statically allocate tasks with a default priority.
  122. \fn int starpu_sched_ctx_set_min_priority(unsigned sched_ctx_id, int min_prio)
  123. \ingroup Scheduling_Contexts
  124. Defines the minimum task priority level supported by the scheduling
  125. policy of the given scheduler context. The default minimum priority
  126. level is the same as the default priority level which is 0 by
  127. convention. The application may access that value by calling the function
  128. starpu_sched_ctx_get_min_priority(). This function should only
  129. be called from the initialization method of the scheduling policy, and
  130. should not be used directly from the application.
  131. \fn int starpu_sched_ctx_set_max_priority(unsigned sched_ctx_id, int max_prio)
  132. \ingroup Scheduling_Contexts
  133. Defines the maximum priority level supported by the scheduling policy
  134. of the given scheduler context. The default maximum priority level is
  135. 1. The application may access that value by calling the
  136. starpu_sched_ctx_get_max_priority function. This function should only
  137. be called from the initialization method of the scheduling policy, and
  138. should not be used directly from the application.
  139. \fn int starpu_sched_ctx_get_min_priority(unsigned sched_ctx_id)
  140. \ingroup Scheduling_Contexts
  141. Returns the current minimum priority level supported by the scheduling
  142. policy of the given scheduler context.
  143. \fn int starpu_sched_ctx_get_max_priority(unsigned sched_ctx_id)
  144. \ingroup Scheduling_Contexts
  145. Returns the current maximum priority level supported by the scheduling
  146. policy of the given scheduler context.
  147. @name Scheduling Context Worker Collection
  148. \ingroup Scheduling_Contexts
  149. \struct starpu_sched_ctx_iterator
  150. \ingroup Scheduling_Contexts
  151. \brief todo
  152. \var starpu_sched_ctx_iterator::cursor
  153. todo
  154. \struct starpu_worker_collection
  155. \ingroup Scheduling_Contexts
  156. \brief A scheduling context manages a collection of workers that can
  157. be memorized using different data structures. Thus, a generic
  158. structure is available in order to simplify the choice of its type.
  159. Only the list data structure is available but further data
  160. structures(like tree) implementations are foreseen.
  161. \var starpu_worker_collection::workerids
  162. The workerids managed by the collection
  163. \var starpu_worker_collection::nworkers
  164. The number of workers in the collection
  165. \var starpu_worker_collection::type
  166. The type of structure (currently STARPU_WORKER_LIST is the only one available)
  167. \var starpu_worker_collection::has_next
  168. Checks if there is another element in collection
  169. \var starpu_worker_collection::get_next
  170. return the next element in the collection
  171. \var starpu_worker_collection::add
  172. add a new element in the collection
  173. \var starpu_worker_collection::remove
  174. remove an element from the collection
  175. \var starpu_worker_collection::init
  176. Initialize the collection
  177. \var starpu_worker_collection::deinit
  178. Deinitialize the colection
  179. \var starpu_worker_collection::init_iterator
  180. Initialize the cursor if there is one
  181. \fn struct starpu_worker_collection* starpu_sched_ctx_create_worker_collection(unsigned sched_ctx_id, enum starpu_worker_collection_type type)
  182. \ingroup Scheduling_Contexts
  183. Create a worker collection of the type indicated by the last parameter
  184. for the context specified through the first parameter.
  185. \fn void starpu_sched_ctx_delete_worker_collection(unsigned sched_ctx_id)
  186. \ingroup Scheduling_Contexts
  187. Delete the worker collection of the specified scheduling context
  188. \fn struct starpu_worker_collection* starpu_sched_ctx_get_worker_collection(unsigned sched_ctx_id)
  189. \ingroup Scheduling_Contexts
  190. Return the worker collection managed by the indicated context
  191. @name Scheduling Context Link with Hypervisor
  192. \ingroup Scheduling_Contexts
  193. \fn void starpu_sched_ctx_set_perf_counters(unsigned sched_ctx_id, struct starpu_sched_ctx_performance_counters *perf_counters)
  194. \ingroup Scheduling_Contexts
  195. Indicates to starpu the pointer to the performance counter
  196. \fn void starpu_sched_ctx_call_pushed_task_cb(int workerid, unsigned sched_ctx_id)
  197. \ingroup Scheduling_Contexts
  198. Callback that lets the scheduling policy tell the hypervisor that a
  199. task was pushed on a worker
  200. \fn void starpu_sched_ctx_notify_hypervisor_exists(void)
  201. \ingroup Scheduling_Contexts
  202. Allow the hypervisor to let starpu know he's initialised
  203. \fn unsigned starpu_sched_ctx_check_if_hypervisor_exists(void)
  204. \ingroup Scheduling_Contexts
  205. Ask starpu if he is informed if the hypervisor is initialised
  206. */