scheduling_contexts.doxy 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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, 2014 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 API_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. \struct starpu_sched_ctx_performance_counters
  17. Performance counters used by the starpu to indicate the
  18. hypervisor how the application and the resources are executing.
  19. \ingroup API_Scheduling_Contexts
  20. \var starpu_sched_ctx_performance_counters::notify_idle_cycle
  21. Informs the hypervisor for how long a worker has been idle in the specified context
  22. \var starpu_sched_ctx_performance_counters::notify_idle_end
  23. 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.
  24. \var starpu_sched_ctx_performance_counters::notify_pushed_task
  25. Notifies the hypervisor that a task has been scheduled on the queue of the worker corresponding to the specified context
  26. \var starpu_sched_ctx_performance_counters::notify_poped_task
  27. Informs the hypervisor that a task executing a specified number of instructions has been poped from the worker
  28. \var starpu_sched_ctx_performance_counters::notify_post_exec_hook
  29. Notifies the hypervisor that a task has just been executed
  30. \var starpu_sched_ctx_performance_counters::notify_submitted_job
  31. Notifies the hypervisor that a task has just been submitted
  32. \var starpu_sched_ctx_performance_counters::notify_delete_context
  33. Notifies the hypervisor that the context was deleted
  34. @name Scheduling Contexts Basic API
  35. \ingroup API_Scheduling_Contexts
  36. \fn unsigned starpu_sched_ctx_create(int *workerids_ctx, int nworkers_ctx, const char *sched_ctx_name, ...)
  37. \ingroup API_Scheduling_Contexts
  38. This function creates a scheduling context with the given parameters
  39. (see below) and assigns the workers in \p workerids_ctx to execute the
  40. tasks submitted to it. The return value represents the identifier of
  41. the context that has just been created. It will be further used to
  42. indicate the context the tasks will be submitted to. The return value
  43. should be at most \ref STARPU_NMAX_SCHED_CTXS.
  44. The arguments following the name of the scheduling context can be of
  45. the following types:
  46. <ul>
  47. <li> ::STARPU_SCHED_CTX_POLICY_NAME, followed by the name of a
  48. predefined scheduling policy
  49. </li>
  50. <li> ::STARPU_SCHED_CTX_POLICY_STRUCT, followed by a pointer to a
  51. custom scheduling policy (struct starpu_sched_policy *)
  52. </li>
  53. <li> ::STARPU_SCHED_CTX_POLICY_MIN_PRIO, followed by a integer
  54. representing the minimum priority value to be defined for the
  55. scheduling policy.
  56. </li>
  57. <li> ::STARPU_SCHED_CTX_POLICY_MAX_PRIO, followed by a integer
  58. representing the maximum priority value to be defined for the
  59. scheduling policy.
  60. </li>
  61. </ul>
  62. \def STARPU_SCHED_CTX_POLICY_NAME
  63. \ingroup API_Scheduling_Contexts
  64. This macro is used when calling starpu_sched_ctx_create() to specify a
  65. name for a scheduling policy
  66. \def STARPU_SCHED_CTX_POLICY_STRUCT
  67. \ingroup API_Scheduling_Contexts
  68. This macro is used when calling starpu_sched_ctx_create() to specify a
  69. pointer to a scheduling policy
  70. \def STARPU_SCHED_CTX_POLICY_MIN_PRIO
  71. \ingroup API_Scheduling_Contexts
  72. This macro is used when calling starpu_sched_ctx_create() to specify a
  73. minimum scheduler priority value.
  74. \def STARPU_SCHED_CTX_POLICY_MAX_PRIO
  75. \ingroup API_Scheduling_Contexts
  76. This macro is used when calling starpu_sched_ctx_create() to specify a
  77. maximum scheduler priority value.
  78. \fn unsigned starpu_sched_ctx_create_inside_interval(const char *policy_name, const char *sched_ctx_name, int min_ncpus, int max_ncpus, int min_ngpus, int max_ngpus, unsigned allow_overlap)
  79. \ingroup API_Scheduling_Contexts
  80. Create a context indicating an approximate interval of resources
  81. \fn void starpu_sched_ctx_register_close_callback(unsigned sched_ctx_id, void (*close_callback)(unsigned sched_ctx_id, void* args), void *args)
  82. \ingroup API_Scheduling_Contexts
  83. Execute the callback whenever the last task of the context finished executing, it is called with the pramaters: sched_ctx and any other paramter needed
  84. by the application (packed in a void*)
  85. \fn void starpu_sched_ctx_add_workers(int *workerids_ctx, int nworkers_ctx, unsigned sched_ctx_id)
  86. \ingroup API_Scheduling_Contexts
  87. This function adds dynamically the workers in \p workerids_ctx to the
  88. context \p sched_ctx_id. The last argument cannot be greater than
  89. \ref STARPU_NMAX_SCHED_CTXS.
  90. \fn void starpu_sched_ctx_remove_workers(int *workerids_ctx, int nworkers_ctx, unsigned sched_ctx_id)
  91. \ingroup API_Scheduling_Contexts
  92. This function removes the workers in \p workerids_ctx from the context
  93. \p sched_ctx_id. The last argument cannot be greater than
  94. STARPU_NMAX_SCHED_CTXS.
  95. \fn void starpu_sched_ctx_delete(unsigned sched_ctx_id)
  96. \ingroup API_Scheduling_Contexts
  97. Delete scheduling context \p sched_ctx_id and transfer remaining
  98. workers to the inheritor scheduling context.
  99. \fn void starpu_sched_ctx_set_inheritor(unsigned sched_ctx_id, unsigned inheritor)
  100. \ingroup API_Scheduling_Contexts
  101. Indicate which context whill inherit the resources of this context
  102. when he will be deleted.
  103. \fn void starpu_sched_ctx_set_context(unsigned *sched_ctx_id)
  104. \ingroup API_Scheduling_Contexts
  105. Set the scheduling context the subsequent tasks will be submitted to
  106. \fn unsigned starpu_sched_ctx_get_context(void)
  107. \ingroup API_Scheduling_Contexts
  108. Return the scheduling context the tasks are currently submitted to,
  109. or ::STARPU_NMAX_SCHED_CTXS if no default context has been defined
  110. by calling the function starpu_sched_ctx_set_context().
  111. \fn void starpu_sched_ctx_stop_task_submission(void)
  112. \ingroup API_Scheduling_Contexts
  113. Stop submitting tasks from the empty context list until the next time
  114. the context has time to check the empty context list
  115. \fn void starpu_sched_ctx_finished_submit(unsigned sched_ctx_id)
  116. \ingroup API_Scheduling_Contexts
  117. Indicate starpu that the application finished submitting to this
  118. context in order to move the workers to the inheritor as soon as
  119. possible.
  120. \fn unsigned starpu_sched_ctx_get_workers_list(unsigned sched_ctx_id, int **workerids)
  121. \ingroup API_Scheduling_Contexts
  122. Returns the list of workers in the array \p workerids, the returned value is the
  123. number of workers. The user should free the \p workerids table after finishing
  124. using it (it is allocated inside the function with the proper size)
  125. \fn unsigned starpu_sched_ctx_get_nworkers(unsigned sched_ctx_id)
  126. \ingroup API_Scheduling_Contexts
  127. Return the number of workers managed by the specified contexts
  128. (Usually needed to verify if it manages any workers or if it should be
  129. blocked)
  130. \fn unsigned starpu_sched_ctx_get_nshared_workers(unsigned sched_ctx_id, unsigned sched_ctx_id2)
  131. \ingroup API_Scheduling_Contexts
  132. Return the number of workers shared by two contexts.
  133. \fn unsigned starpu_sched_ctx_contains_worker(int workerid, unsigned sched_ctx_id)
  134. \ingroup API_Scheduling_Contexts
  135. Return 1 if the worker belongs to the context and 0 otherwise
  136. \fn unsigned starpu_sched_ctx_worker_get_id(unsigned sched_ctx_id)
  137. \ingroup API_Scheduling_Contexts
  138. Return the workerid if the worker belongs to the context and -1 otherwise.
  139. If the thread calling this function is not a worker the function returns -1
  140. as it calls the function \ref starpu_worker_get_id()
  141. \fn unsigned starpu_sched_ctx_overlapping_ctxs_on_worker(int workerid)
  142. \ingroup API_Scheduling_Contexts
  143. Check if a worker is shared between several contexts
  144. @name Scheduling Context Priorities
  145. \ingroup API_Scheduling_Contexts
  146. \def STARPU_MIN_PRIO
  147. \ingroup API_Scheduling_Contexts
  148. Provided for legacy reasons.
  149. \def STARPU_MAX_PRIO
  150. \ingroup API_Scheduling_Contexts
  151. Provided for legacy reasons.
  152. \def STARPU_DEFAULT_PRIO
  153. \ingroup API_Scheduling_Contexts
  154. By convention, the default priority level should be 0 so that we can
  155. statically allocate tasks with a default priority.
  156. \fn int starpu_sched_ctx_set_min_priority(unsigned sched_ctx_id, int min_prio)
  157. \ingroup API_Scheduling_Contexts
  158. Defines the minimum task priority level supported by the scheduling
  159. policy of the given scheduler context. The default minimum priority
  160. level is the same as the default priority level which is 0 by
  161. convention. The application may access that value by calling the function
  162. starpu_sched_ctx_get_min_priority(). This function should only
  163. be called from the initialization method of the scheduling policy, and
  164. should not be used directly from the application.
  165. \fn int starpu_sched_ctx_set_max_priority(unsigned sched_ctx_id, int max_prio)
  166. \ingroup API_Scheduling_Contexts
  167. Defines the maximum priority level supported by the scheduling policy
  168. of the given scheduler context. The default maximum priority level is
  169. 1. The application may access that value by calling the
  170. starpu_sched_ctx_get_max_priority function. This function should only
  171. be called from the initialization method of the scheduling policy, and
  172. should not be used directly from the application.
  173. \fn int starpu_sched_ctx_get_min_priority(unsigned sched_ctx_id)
  174. \ingroup API_Scheduling_Contexts
  175. Returns the current minimum priority level supported by the scheduling
  176. policy of the given scheduler context.
  177. \fn int starpu_sched_ctx_get_max_priority(unsigned sched_ctx_id)
  178. \ingroup API_Scheduling_Contexts
  179. Returns the current maximum priority level supported by the scheduling
  180. policy of the given scheduler context.
  181. \fn int starpu_sched_ctx_min_priority_is_set(unsigned sched_ctx_id)
  182. \ingroup API_Scheduling_Contexts
  183. todo
  184. \fn int starpu_sched_ctx_max_priority_is_set(unsigned sched_ctx_id)
  185. \ingroup API_Scheduling_Contexts
  186. todo
  187. @name Scheduling Context Worker Collection
  188. \ingroup API_Scheduling_Contexts
  189. \fn struct starpu_worker_collection *starpu_sched_ctx_create_worker_collection(unsigned sched_ctx_id, enum starpu_worker_collection_type type)
  190. \ingroup API_Scheduling_Contexts
  191. Create a worker collection of the type indicated by the last parameter
  192. for the context specified through the first parameter.
  193. \fn void starpu_sched_ctx_delete_worker_collection(unsigned sched_ctx_id)
  194. \ingroup API_Scheduling_Contexts
  195. Delete the worker collection of the specified scheduling context
  196. \fn struct starpu_worker_collection *starpu_sched_ctx_get_worker_collection(unsigned sched_ctx_id)
  197. \ingroup API_Scheduling_Contexts
  198. Return the worker collection managed by the indicated context
  199. @name Scheduling Context Link with Hypervisor
  200. \ingroup API_Scheduling_Contexts
  201. \fn void starpu_sched_ctx_set_perf_counters(unsigned sched_ctx_id, void *perf_counters)
  202. \ingroup API_Scheduling_Contexts
  203. Indicates to starpu the pointer to the performance counter
  204. \fn void starpu_sched_ctx_call_pushed_task_cb(int workerid, unsigned sched_ctx_id)
  205. \ingroup API_Scheduling_Contexts
  206. Callback that lets the scheduling policy tell the hypervisor that a
  207. task was pushed on a worker
  208. \fn void starpu_sched_ctx_notify_hypervisor_exists(void)
  209. \ingroup API_Scheduling_Contexts
  210. Allow the hypervisor to let starpu know he's initialised
  211. \fn unsigned starpu_sched_ctx_check_if_hypervisor_exists(void)
  212. \ingroup API_Scheduling_Contexts
  213. Ask starpu if he is informed if the hypervisor is initialised
  214. \fn void starpu_sched_ctx_set_policy_data(unsigned sched_ctx_id, void *policy_data)
  215. \ingroup API_Scheduling_Contexts
  216. Allocate the scheduling policy data (private information of the scheduler like queues, variables,
  217. additional condition variables) the context
  218. \fn void *starpu_sched_ctx_get_policy_data(unsigned sched_ctx_id)
  219. \ingroup API_Scheduling_Contexts
  220. Return the scheduling policy data (private information of the scheduler) of the contexts previously
  221. assigned to.
  222. \fn void *starpu_sched_ctx_exec_parallel_code(void* (*func)(void*), void *param, unsigned sched_ctx_id)
  223. \ingroup API_Scheduling_Contexts
  224. execute any parallel code on the workers of the sched_ctx (workers are blocked)
  225. \fn int starpu_sched_ctx_get_nready_tasks(unsigned sched_ctx_id)
  226. \ingroup API_Scheduling_Contexts
  227. todo
  228. \fn double starpu_sched_ctx_get_nready_flops(unsigned sched_ctx_id)
  229. \ingroup API_Scheduling_Contexts
  230. todo
  231. */