StarPU Handbook

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Functions
Scheduling Policy

TODO. While StarPU comes with a variety of scheduling policies (see Task Scheduling Policy), it may sometimes be desirable to implement custom policies to address specific problems. The API described below allows users to write their own scheduling policy. More...

## Data Structures
struct | starpu_sched_policy

## Functions
struct starpu_sched_policy ** | starpu_sched_get_predefined_policies ()
void | starpu_worker_get_sched_condition (int workerid, starpu_pthread_mutex_t **sched_mutex, starpu_pthread_cond_t **sched_cond)
int | starpu_sched_set_min_priority (int min_prio)
int | starpu_sched_set_max_priority (int max_prio)
int | starpu_sched_get_min_priority (void)
int | starpu_sched_get_max_priority (void)
int | starpu_push_local_task (int workerid, struct starpu_task *task, int back)
int | starpu_push_task_end (struct starpu_task *task)
int | starpu_worker_can_execute_task (unsigned workerid, struct starpu_task *task, unsigned nimpl)
double | starpu_timing_now (void)
uint32_t | starpu_task_footprint (struct starpu_perfmodel *model, struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
double | starpu_task_expected_length (struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
double | starpu_worker_get_relative_speedup (enum starpu_perfmodel_archtype perf_archtype)
double | starpu_task_expected_data_transfer_time (unsigned memory_node, struct starpu_task *task)
double | starpu_data_expected_transfer_time (starpu_data_handle_t handle, unsigned memory_node, enum starpu_data_access_mode mode)
double | starpu_task_expected_power (struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
double | starpu_task_expected_conversion_time (struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
int | starpu_get_prefetch_flag (void)
int | starpu_prefetch_task_input_on_node (struct starpu_task *task, unsigned node)
void | starpu_sched_ctx_worker_shares_tasks_lists (int workerid, int sched_ctx_id)

## Detailed Description

TODO. While StarPU comes with a variety of scheduling policies (see Task Scheduling Policy), it may sometimes be desirable to implement custom policies to address specific problems. The API described below allows users to write their own scheduling policy.

## Data Structure Documentation

struct starpu_sched_policy

This structure contains all the methods that implement a scheduling policy. An application may specify which scheduling strategy in the field starpu_conf::sched_policy passed to the function starpu_init().

### Data Fields
void(* | init_sched )(unsigned sched_ctx_id)
void(* | deinit_sched )(unsigned sched_ctx_id)
int(* | push_task )(struct starpu_task *)
void(* | push_task_notify )(struct starpu_task *, int workerid, int perf_workerid, unsigned sched_ctx_id)
struct starpu_task *(* | pop_task )(unsigned sched_ctx_id)
struct starpu_task *(* | pop_every_task )(unsigned sched_ctx_id)
void(* | pre_exec_hook )(struct starpu_task *)
void(* | post_exec_hook )(struct starpu_task *)
void(* | add_workers )(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
void(* | remove_workers )(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
const char * | policy_name
const char * | policy_description

#### Field Documentation

starpu_sched_policy::init_sched

Initialize the scheduling policy.

starpu_sched_policy::deinit_sched

Cleanup the scheduling policy.

starpu_sched_policy::push_task

Insert a task into the scheduler.

starpu_sched_policy::push_task_notify

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.

starpu_sched_policy::pop_task

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.

starpu_sched_policy::pop_every_task

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.

starpu_sched_policy::pre_exec_hook

Optional field. This method is called every time a task is starting.

starpu_sched_policy::post_exec_hook

Optional field. This method is called every time a task has been executed.

starpu_sched_policy::add_workers

Initialize scheduling structures corresponding to each worker used by the policy.

starpu_sched_policy::remove_workers

Deinitialize scheduling structures corresponding to each worker used by the policy.

starpu_sched_policy::policy_name

Optional field. Name of the policy.

starpu_sched_policy::policy_description

Optional field. Human readable description of the policy.

## Function Documentation

struct starpu_sched_policy ** starpu_sched_get_predefined_policies | ( |  | ) |

Return an NULL-terminated array of all the predefined scheduling policies.

void starpu_worker_get_sched_condition | ( | int | workerid,
|  | starpu_pthread_mutex_t ** | sched_mutex,
|  | starpu_pthread_cond_t ** | sched_cond
| ) |  |

When there is no available task for a worker, StarPU blocks this worker on a condition variable. This function specifies which condition variable (and the associated mutex) should be used to block (and to wake up) a worker. Note that multiple workers may use the same condition variable. For instance, in the case of a scheduling strategy with a single task queue, the same condition variable would be used to block and wake up all workers.

int starpu_sched_set_min_priority | ( | int | min_prio | ) |

TODO: check if this is correct Defines the minimum task priority level supported by the scheduling policy. The default minimum priority level is the same as the default priority level which is 0 by convention. The application may access that value by calling the function starpu_sched_get_min_priority(). This function should only be called from the initialization method of the scheduling policy, and should not be used directly from the application.

int starpu_sched_set_max_priority | ( | int | max_prio | ) |

TODO: check if this is correct Defines the maximum priority level supported by the scheduling policy. The default maximum priority level is 1. The application may access that value by calling the function starpu_sched_get_max_priority(). This function should only be called from the initialization method of the scheduling policy, and should not be used directly from the application.

int starpu_sched_get_min_priority | ( | void |  | ) |

TODO: check if this is correct Returns the current minimum priority level supported by the scheduling policy

int starpu_sched_get_max_priority | ( | void |  | ) |

TODO: check if this is correct Returns the current maximum priority level supported by the scheduling policy

int starpu_push_local_task | ( | int | workerid,
|  | struct starpu_task * | task,
|  | int | back
| ) |  |

The scheduling policy may put tasks directly into a worker’s local queue so that it is not always necessary to create its own queue when the local queue is sufficient. If `back` is not 0, `task` is put at the back of the queue where the worker will pop tasks first. Setting `back` to 0 therefore ensures a FIFO ordering.

int starpu_push_task_end | ( | struct starpu_task * | task | ) |

This function must be called by a scheduler to notify that the given task has just been pushed.

int starpu_worker_can_execute_task | ( | unsigned | workerid,
|  | struct starpu_task * | task,
|  | unsigned | nimpl
| ) |  |

Check 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.

double starpu_timing_now | ( | void |  | ) |

Return the current date in micro-seconds.

uint32_t starpu_task_footprint | ( | struct starpu_perfmodel * | model,
|  | struct starpu_task * | task,
|  | enum starpu_perfmodel_archtype | arch,
|  | unsigned | nimpl
| ) |  |

Returns the footprint for a given task

double starpu_task_expected_length | ( | struct starpu_task * | task,
|  | enum starpu_perfmodel_archtype | arch,
|  | unsigned | nimpl
| ) |  |

Returns expected task duration in micro-seconds.

double starpu_worker_get_relative_speedup | ( | enum starpu_perfmodel_archtype | perf_archtype | ) |

Returns an estimated speedup factor relative to CPU speed

double starpu_task_expected_data_transfer_time | ( | unsigned | memory_node,
|  | struct starpu_task * | task
| ) |  |

Returns expected data transfer time in micro-seconds.

double starpu_data_expected_transfer_time | ( | starpu_data_handle_t | handle,
|  | unsigned | memory_node,
|  | enum starpu_data_access_mode | mode
| ) |  |

Predict the transfer time (in micro-seconds) to move `handle` to a memory node

double starpu_task_expected_power | ( | struct starpu_task * | task,
|  | enum starpu_perfmodel_archtype | arch,
|  | unsigned | nimpl
| ) |  |

Returns expected power consumption in J

double starpu_task_expected_conversion_time | ( | struct starpu_task * | task,
|  | enum starpu_perfmodel_archtype | arch,
|  | unsigned | nimpl
| ) |  |

Returns expected conversion time in ms (multiformat interface only)

int starpu_get_prefetch_flag | ( | void |  | ) |

Whether STARPU_PREFETCH was set

int starpu_prefetch_task_input_on_node | ( | struct starpu_task * | task,
|  | unsigned | node
| ) |  |

Prefetch data for a given task on a given node

void starpu_sched_ctx_worker_shares_tasks_lists | ( | int | workerid,
|  | int | sched_ctx_id
| ) |  |

The scheduling policies indicates if the worker may pop tasks from the list of other workers or if there is a central list with task for all the workers