scheduling_policy.doxy 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 API_Scheduling_Policy Scheduling Policy
  9. \brief TODO. While StarPU comes with a variety of scheduling policies
  10. (see \ref Task_scheduling_policy), it may sometimes be desirable to
  11. implement custom policies to address specific problems. The API
  12. described below allows users to write their own scheduling policy.
  13. \struct starpu_sched_policy
  14. \ingroup API_Scheduling_Policy
  15. This structure contains all the methods that implement a
  16. scheduling policy. An application may specify which scheduling
  17. strategy in the field starpu_conf::sched_policy passed to the function
  18. starpu_init().
  19. \var starpu_sched_policy::init_sched
  20. Initialize the scheduling policy.
  21. \var starpu_sched_policy::deinit_sched
  22. Cleanup the scheduling policy.
  23. \var starpu_sched_policy::push_task
  24. Insert a task into the scheduler.
  25. \var starpu_sched_policy::push_task_notify
  26. Notify the scheduler that a task was pushed on a given worker.
  27. This method is called when a task that was explicitely
  28. assigned to a worker becomes ready and is about to be executed
  29. by the worker. This method therefore permits to keep the state
  30. of the scheduler coherent even when StarPU bypasses the
  31. scheduling strategy.
  32. \var starpu_sched_policy::pop_task
  33. Get a task from the scheduler. The mutex associated to the
  34. worker is already taken when this method is called. If this
  35. method is defined as NULL, the worker will only execute tasks
  36. from its local queue. In this case, the push_task method
  37. should use the starpu_push_local_task method to assign tasks
  38. to the different workers.
  39. \var starpu_sched_policy::pop_every_task
  40. Remove all available tasks from the scheduler (tasks are
  41. chained by the means of the field starpu_task::prev and
  42. starpu_task::next). The mutex associated to the worker is
  43. already taken when this method is called. This is currently
  44. not used.
  45. \var starpu_sched_policy::pre_exec_hook
  46. Optional field. This method is called every time a task is starting.
  47. \var starpu_sched_policy::post_exec_hook
  48. Optional field. This method is called every time a task has been executed.
  49. \var starpu_sched_policy::add_workers
  50. Initialize scheduling structures corresponding to each worker used by the policy.
  51. \var starpu_sched_policy::remove_workers
  52. Deinitialize scheduling structures corresponding to each worker used by the policy.
  53. \var starpu_sched_policy::policy_name
  54. Optional field. Name of the policy.
  55. \var starpu_sched_policy::policy_description
  56. Optional field. Human readable description of the policy.
  57. \fn struct starpu_sched_policy ** starpu_sched_get_predefined_policies()
  58. \ingroup API_Scheduling_Policy
  59. Return an NULL-terminated array of all the predefined scheduling
  60. policies.
  61. \fn void starpu_worker_get_sched_condition(int workerid, starpu_pthread_mutex_t **sched_mutex, starpu_pthread_cond_t **sched_cond)
  62. \ingroup API_Scheduling_Policy
  63. When there is no available task for a worker, StarPU blocks this
  64. worker on a condition variable. This function specifies which
  65. condition variable (and the associated mutex) should be used to block
  66. (and to wake up) a worker. Note that multiple workers may use the same
  67. condition variable. For instance, in the case of a scheduling strategy
  68. with a single task queue, the same condition variable would be used to
  69. block and wake up all workers.
  70. \fn void starpu_sched_ctx_set_policy_data(unsigned sched_ctx_id, void * policy_data)
  71. \ingroup API_Scheduling_Policy
  72. Each scheduling policy uses some specific data (queues, variables,
  73. additional condition variables). It is memorize through a local
  74. structure. This function assigns it to a scheduling context.
  75. \fn void* starpu_sched_ctx_get_policy_data(unsigned sched_ctx_id)
  76. \ingroup API_Scheduling_Policy
  77. Returns the policy data previously assigned to a context
  78. \fn int starpu_sched_set_min_priority(int min_prio)
  79. \ingroup API_Scheduling_Policy
  80. Defines the minimum task priority level supported by the scheduling
  81. policy. The default minimum priority level is the same as the default
  82. priority level which is 0 by convention. The application may access
  83. that value by calling the function starpu_sched_get_min_priority().
  84. This function should only be called from the initialization method of
  85. the scheduling policy, and should not be used directly from the
  86. application.
  87. \fn int starpu_sched_set_max_priority(int max_prio)
  88. \ingroup API_Scheduling_Policy
  89. Defines the maximum priority level supported by the scheduling policy.
  90. The default maximum priority level is 1. The application may access
  91. that value by calling the function starpu_sched_get_max_priority().
  92. This function should only be called from the initialization method of
  93. the scheduling policy, and should not be used directly from the
  94. application.
  95. \fn int starpu_sched_get_min_priority(void)
  96. \ingroup API_Scheduling_Policy
  97. Returns the current minimum priority level supported by the scheduling
  98. policy
  99. \fn int starpu_sched_get_max_priority(void)
  100. \ingroup API_Scheduling_Policy
  101. Returns the current maximum priority level supported by the scheduling
  102. policy
  103. \fn int starpu_push_local_task(int workerid, struct starpu_task *task, int back)
  104. \ingroup API_Scheduling_Policy
  105. The scheduling policy may put tasks directly into a worker’s local
  106. queue so that it is not always necessary to create its own queue when
  107. the local queue is sufficient. If \p back is not 0, \p task is put
  108. at the back of the queue where the worker will pop tasks first.
  109. Setting \p back to 0 therefore ensures a FIFO ordering.
  110. \fn int starpu_push_task_end(struct starpu_task *task)
  111. \ingroup API_Scheduling_Policy
  112. This function must be called by a scheduler to notify that the given
  113. task has just been pushed.
  114. \fn int starpu_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl)
  115. \ingroup API_Scheduling_Policy
  116. Check if the worker specified by workerid can execute the codelet.
  117. Schedulers need to call it before assigning a task to a worker,
  118. otherwise the task may fail to execute.
  119. \fn double starpu_timing_now(void)
  120. \ingroup API_Scheduling_Policy
  121. Return the current date in micro-seconds.
  122. \fn uint32_t starpu_task_footprint(struct starpu_perfmodel *model, struct starpu_task * task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
  123. \ingroup API_Scheduling_Policy
  124. Returns the footprint for a given task
  125. \fn double starpu_task_expected_length(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
  126. \ingroup API_Scheduling_Policy
  127. Returns expected task duration in micro-seconds.
  128. \fn double starpu_worker_get_relative_speedup(enum starpu_perfmodel_archtype perf_archtype)
  129. \ingroup API_Scheduling_Policy
  130. Returns an estimated speedup factor relative to CPU speed
  131. \fn double starpu_task_expected_data_transfer_time(unsigned memory_node, struct starpu_task *task)
  132. \ingroup API_Scheduling_Policy
  133. Returns expected data transfer time in micro-seconds.
  134. \fn double starpu_data_expected_transfer_time(starpu_data_handle_t handle, unsigned memory_node, enum starpu_data_access_mode mode)
  135. \ingroup API_Scheduling_Policy
  136. Predict the transfer time (in micro-seconds) to move \p handle to a memory node
  137. \fn double starpu_task_expected_power(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
  138. \ingroup API_Scheduling_Policy
  139. Returns expected power consumption in J
  140. \fn double starpu_task_expected_conversion_time(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
  141. \ingroup API_Scheduling_Policy
  142. Returns expected conversion time in ms (multiformat interface only)
  143. \fn int starpu_get_prefetch_flag(void)
  144. \ingroup API_Scheduling_Policy
  145. Whether STARPU_PREFETCH was set
  146. \fn int starpu_prefetch_task_input_on_node(struct starpu_task *task, unsigned node)
  147. \ingroup API_Scheduling_Policy
  148. Prefetch data for a given task on a given node
  149. */