| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 | /* * This file is part of the StarPU Handbook. * Copyright (C) 2009--2011  Universit@'e de Bordeaux * Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique * Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique * See the file version.doxy for copying conditions. *//*! \defgroup API_Scheduling_Policy Scheduling Policy\brief TODO. While StarPU comes with a variety of scheduling policies(see \ref TaskSchedulingPolicy), it may sometimes be desirable toimplement custom policies to address specific problems. The APIdescribed below allows users to write their own scheduling policy.\struct starpu_sched_policy\ingroup API_Scheduling_PolicyThis structure contains all the methods that implement ascheduling policy. An application may specify which schedulingstrategy in the field starpu_conf::sched_policy passed to the functionstarpu_init().\var void (*starpu_sched_policy::init_sched)(unsigned sched_ctx_id)        Initialize the scheduling policy.\var void (*starpu_sched_policy::deinit_sched)(unsigned sched_ctx_id)        Cleanup the scheduling policy.\var int (*starpu_sched_policy::push_task)(struct starpu_task *)        Insert a task into the scheduler.\var void (*starpu_sched_policy::push_task_notify)(struct starpu_task *, int workerid, int perf_workerid, unsigned sched_ctx_id)        Notify the scheduler that a task was pushed on a given worker.	This method is called when a task that was explicitly	assigned to a worker becomes ready and is about to be executed	by the worker. This method therefore permits to keep the state	of the scheduler coherent even when StarPU bypasses the	scheduling strategy.\var struct starpu_task *(*starpu_sched_policy::pop_task)(unsigned sched_ctx_id)        Get a task from the scheduler. The mutex associated to the	worker is already taken when this method is called. If this	method is defined as NULL, the worker will only execute tasks	from its local queue. In this case, the push_task method	should use the starpu_push_local_task method to assign tasks	to the different workers.\var struct starpu_task *(*starpu_sched_policy::pop_every_task)(unsigned sched_ctx_id)        Remove all available tasks from the scheduler (tasks are	chained by the means of the field starpu_task::prev and	starpu_task::next). The mutex associated to the worker is	already taken when this method is called. This is currently	not used.\var void (*starpu_sched_policy::pre_exec_hook)(struct starpu_task *)        Optional field. This method is called every time a task is starting.\var void (*starpu_sched_policy::post_exec_hook)(struct starpu_task *)        Optional field. This method is called every time a task has been executed.\var void (*starpu_sched_policy::add_workers)(unsigned sched_ctx_id, int *workerids, unsigned nworkers)        Initialize scheduling structures corresponding to each worker used by the policy.\var void (*starpu_sched_policy::remove_workers)(unsigned sched_ctx_id, int *workerids, unsigned nworkers)        Deinitialize scheduling structures corresponding to each worker used by the policy.\var const char *starpu_sched_policy::policy_name        Optional field. Name of the policy.\var const char *starpu_sched_policy::policy_description        Optional field. Human readable description of the policy.\fn struct starpu_sched_policy **starpu_sched_get_predefined_policies()\ingroup API_Scheduling_PolicyReturn an NULL-terminated array of all the predefined schedulingpolicies.\fn void starpu_worker_get_sched_condition(int workerid, starpu_pthread_mutex_t **sched_mutex, starpu_pthread_cond_t **sched_cond)\ingroup API_Scheduling_PolicyWhen there is no available task for a worker, StarPU blocks thisworker on a condition variable. This function specifies whichcondition variable (and the associated mutex) should be used to block(and to wake up) a worker. Note that multiple workers may use the samecondition variable. For instance, in the case of a scheduling strategywith a single task queue, the same condition variable would be used toblock and wake up all workers.\fn int starpu_sched_set_min_priority(int min_prio)\ingroup API_Scheduling_PolicyTODO: check if this is correctDefines the minimum task priority level supported by the schedulingpolicy. The default minimum priority level is the same as the defaultpriority level which is 0 by convention. The application may accessthat value by calling the function starpu_sched_get_min_priority().This function should only be called from the initialization method ofthe scheduling policy, and should not be used directly from theapplication.\fn int starpu_sched_set_max_priority(int max_prio)\ingroup API_Scheduling_PolicyTODO: check if this is correctDefines the maximum priority level supported by the scheduling policy.The default maximum priority level is 1. The application may accessthat value by calling the function starpu_sched_get_max_priority().This function should only be called from the initialization method ofthe scheduling policy, and should not be used directly from theapplication.\fn int starpu_sched_get_min_priority(void)\ingroup API_Scheduling_PolicyTODO: check if this is correctReturns the current minimum priority level supported by the schedulingpolicy\fn int starpu_sched_get_max_priority(void)\ingroup API_Scheduling_PolicyTODO: check if this is correctReturns the current maximum priority level supported by the schedulingpolicy\fn int starpu_push_local_task(int workerid, struct starpu_task *task, int back)\ingroup API_Scheduling_PolicyThe scheduling policy may put tasks directly into a worker’s localqueue so that it is not always necessary to create its own queue whenthe local queue is sufficient. If \p back is not 0, \p task is putat the back of the queue where the worker will pop tasks first.Setting \p back to 0 therefore ensures a FIFO ordering.\fn int starpu_push_task_end(struct starpu_task *task)\ingroup API_Scheduling_PolicyThis function must be called by a scheduler to notify that the giventask has just been pushed.\fn int starpu_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl)\ingroup API_Scheduling_PolicyCheck if the worker specified by workerid can execute the codelet.Schedulers need to call it before assigning a task to a worker,otherwise the task may fail to execute.\fn int starpu_worker_can_execute_task_impl(unsigned workerid, struct starpu_task *task, unsigned *impl_mask)\ingroup API_Scheduling_PolicyCheck if the worker specified by workerid can execute the codelet and returnswhich implementation numbers can be used.Schedulers need to call it before assigning a task to a worker,otherwise the task may fail to execute.This should be preferred rather than calling starpu_worker_can_execute_task foreach and every implementation. It can also be used with impl_mask == NULL tocheck for at least one implementation without determining which.\fn int starpu_worker_can_execute_task_first_impl(unsigned workerid, struct starpu_task *task, unsigned *nimpl)\ingroup API_Scheduling_PolicyCheck if the worker specified by workerid can execute the codelet and returnsthe first implementation which can be used.Schedulers need to call it before assigning a task to a worker,otherwise the task may fail to execute.This should be preferred rather than calling starpu_worker_can_execute_task foreach and every implementation. It can also be used with impl_mask == NULL tocheck for at least one implementation without determining which.\fn uint32_t starpu_task_footprint(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl)\ingroup API_Scheduling_PolicyReturns the footprint for a given task, taking into account user-providedperfmodel footprint or size_base functions.\fn uint32_t starpu_task_data_footprint(struct starpu_task *task)\ingroup API_Scheduling_PolicyReturns the raw footprint for the data of a given task (without taking into account user-provided functions).\fn double starpu_task_expected_length(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl)\ingroup API_Scheduling_PolicyReturns expected task duration in micro-seconds.\fn double starpu_worker_get_relative_speedup(struct starpu_perfmodel_arch *perf_arch)\ingroup API_Scheduling_PolicyReturns an estimated speedup factor relative to CPU speed\fn double starpu_task_expected_data_transfer_time(unsigned memory_node, struct starpu_task *task)\ingroup API_Scheduling_PolicyReturns expected data transfer time in micro-seconds.\fn double starpu_data_expected_transfer_time(starpu_data_handle_t handle, unsigned memory_node, enum starpu_data_access_mode mode)\ingroup API_Scheduling_PolicyPredict the transfer time (in micro-seconds) to move \p handle to a memory node\fn double starpu_task_expected_power(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl)\ingroup API_Scheduling_PolicyReturns expected power consumption in J\fn double starpu_task_expected_conversion_time(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl)\ingroup API_Scheduling_PolicyReturns expected conversion time in ms (multiformat interface only)\fn int starpu_get_prefetch_flag(void)\ingroup API_Scheduling_PolicyWhether \ref STARPU_PREFETCH was set\fn int starpu_prefetch_task_input_on_node(struct starpu_task *task, unsigned node)\ingroup API_Scheduling_PolicyPrefetch data for a given task on a given node\fn void starpu_sched_ctx_worker_shares_tasks_lists(int workerid, int sched_ctx_id)\ingroup API_Scheduling_PolicyThe scheduling policies indicates if the worker may pop tasks from the list of other workersor if there is a central list with task for all the workers*/
 |