StarPU Handbook
starpu_scheduler.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2011-2013 Inria
4  * Copyright (C) 2010-2018 Université de Bordeaux
5  * Copyright (C) 2011-2013,2015 CNRS
6  * Copyright (C) 2011 Télécom-SudParis
7  *
8  * StarPU is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or (at
11  * your option) any later version.
12  *
13  * StarPU is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
18  */
19 
20 #ifndef __STARPU_SCHEDULER_H__
21 #define __STARPU_SCHEDULER_H__
22 
23 #include <starpu.h>
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29 
30 struct starpu_task;
31 
33 {
34  void (*init_sched)(unsigned sched_ctx_id);
35  void (*deinit_sched)(unsigned sched_ctx_id);
36 
37  int (*push_task)(struct starpu_task *);
38  double (*simulate_push_task)(struct starpu_task *);
39  void (*push_task_notify)(struct starpu_task *, int workerid, int perf_workerid, unsigned sched_ctx_id);
40  struct starpu_task *(*pop_task)(unsigned sched_ctx_id);
41  struct starpu_task *(*pop_every_task)(unsigned sched_ctx_id);
42 
43  void (*submit_hook)(struct starpu_task *task);
44  void (*pre_exec_hook)(struct starpu_task *);
45  void (*post_exec_hook)(struct starpu_task *);
46 
47  void (*do_schedule)(unsigned sched_ctx_id);
48 
49  void (*add_workers)(unsigned sched_ctx_id, int *workerids, unsigned nworkers);
50  void (*remove_workers)(unsigned sched_ctx_id, int *workerids, unsigned nworkers);
51 
52  const char *policy_name;
53  const char *policy_description;
54 };
55 
57 
58 void starpu_worker_get_sched_condition(int workerid, starpu_pthread_mutex_t **sched_mutex, starpu_pthread_cond_t **sched_cond);
59 unsigned long starpu_task_get_job_id(struct starpu_task *task);
60 
61 /* This function must be called to wake up a worker that is sleeping on the cond.
62  * It returns 0 whenever the worker is not in a sleeping state */
63 int starpu_wake_worker(int workerid);
64 int starpu_wakeup_worker(int workerid, starpu_pthread_cond_t *cond, starpu_pthread_mutex_t *mutex);
65 /* This is a version of starpu_wake_worker which assumes that the sched mutex is locked */
66 int starpu_wake_worker_locked(int workerid);
67 /* This is a version of starpu_wakeup_worker which assumes that the sched mutex is locked */
68 int starpu_wakeup_worker_locked(int workerid, starpu_pthread_cond_t *cond, starpu_pthread_mutex_t *mutex);
69 
70 int starpu_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl);
71 int starpu_worker_can_execute_task_impl(unsigned workerid, struct starpu_task *task, unsigned *impl_mask);
72 int starpu_worker_can_execute_task_first_impl(unsigned workerid, struct starpu_task *task, unsigned *nimpl);
73 
74 int starpu_push_local_task(int workerid, struct starpu_task *task, int back);
75 
76 int starpu_push_task_end(struct starpu_task *task);
77 
78 int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[]);
79 int starpu_combined_worker_get_description(int workerid, int *worker_size, int **combined_workerid);
80 int starpu_combined_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl);
81 
82 int starpu_get_prefetch_flag(void);
83 int starpu_prefetch_task_input_on_node(struct starpu_task *task, unsigned node);
84 int starpu_idle_prefetch_task_input_on_node(struct starpu_task *task, unsigned node);
85 
86 uint32_t starpu_task_footprint(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl);
87 uint32_t starpu_task_data_footprint(struct starpu_task *task);
88 double starpu_task_expected_length(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl);
90 double starpu_task_expected_data_transfer_time(unsigned memory_node, struct starpu_task *task);
91 double starpu_data_expected_transfer_time(starpu_data_handle_t handle, unsigned memory_node, enum starpu_data_access_mode mode);
92 double starpu_task_expected_energy(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl);
93 double starpu_task_expected_conversion_time(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl);
94 
95 double starpu_task_bundle_expected_length(starpu_task_bundle_t bundle, struct starpu_perfmodel_arch *arch, unsigned nimpl);
96 double starpu_task_bundle_expected_data_transfer_time(starpu_task_bundle_t bundle, unsigned memory_node);
97 double starpu_task_bundle_expected_energy(starpu_task_bundle_t bundle, struct starpu_perfmodel_arch *arch, unsigned nimpl);
98 
99 void starpu_sched_ctx_worker_shares_tasks_lists(int workerid, int sched_ctx_id);
100 
101 void starpu_sched_task_break(struct starpu_task *task);
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /* __STARPU_SCHEDULER_H__ */
double starpu_task_expected_data_transfer_time(unsigned memory_node, struct starpu_task *task)
double starpu_task_bundle_expected_data_transfer_time(starpu_task_bundle_t bundle, unsigned memory_node)
uint32_t starpu_task_data_footprint(struct starpu_task *task)
int starpu_combined_worker_get_description(int workerid, int *worker_size, int **combined_workerid)
void(* submit_hook)(struct starpu_task *task)
Definition: starpu_scheduler.h:43
int starpu_push_local_task(int workerid, struct starpu_task *task, int back)
void starpu_worker_get_sched_condition(int workerid, starpu_pthread_mutex_t **sched_mutex, starpu_pthread_cond_t **sched_cond)
int starpu_combined_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl)
const char * policy_description
Definition: starpu_scheduler.h:53
unsigned workerid
Definition: starpu_task.h:181
int starpu_get_prefetch_flag(void)
double starpu_worker_get_relative_speedup(struct starpu_perfmodel_arch *perf_arch)
void(* deinit_sched)(unsigned sched_ctx_id)
Definition: starpu_scheduler.h:35
void(* post_exec_hook)(struct starpu_task *)
Definition: starpu_scheduler.h:45
int starpu_wake_worker(int workerid)
double starpu_task_expected_length(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl)
double starpu_task_bundle_expected_length(starpu_task_bundle_t bundle, struct starpu_perfmodel_arch *arch, unsigned nimpl)
int(* push_task)(struct starpu_task *)
Definition: starpu_scheduler.h:37
int starpu_worker_can_execute_task_first_impl(unsigned workerid, struct starpu_task *task, unsigned *nimpl)
double starpu_task_expected_energy(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl)
struct _starpu_task_bundle * starpu_task_bundle_t
Definition: starpu_task_bundle.h:30
void(* remove_workers)(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
Definition: starpu_scheduler.h:50
Definition: starpu_task.h:129
Definition: starpu_perfmodel.h:47
void(* push_task_notify)(struct starpu_task *, int workerid, int perf_workerid, unsigned sched_ctx_id)
Definition: starpu_scheduler.h:39
const char * policy_name
Definition: starpu_scheduler.h:52
double starpu_data_expected_transfer_time(starpu_data_handle_t handle, unsigned memory_node, enum starpu_data_access_mode mode)
int starpu_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl)
double starpu_task_expected_conversion_time(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl)
void starpu_sched_ctx_worker_shares_tasks_lists(int workerid, int sched_ctx_id)
void(* init_sched)(unsigned sched_ctx_id)
Definition: starpu_scheduler.h:34
Definition: starpu_perfmodel.h:127
int starpu_idle_prefetch_task_input_on_node(struct starpu_task *task, unsigned node)
struct starpu_sched_policy ** starpu_sched_get_predefined_policies()
Definition: starpu_scheduler.h:32
int starpu_prefetch_task_input_on_node(struct starpu_task *task, unsigned node)
void(* do_schedule)(unsigned sched_ctx_id)
Definition: starpu_scheduler.h:47
int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[])
starpu_data_access_mode
Definition: starpu_data.h:33
struct _starpu_data_state * starpu_data_handle_t
Definition: starpu_data.h:30
void(* pre_exec_hook)(struct starpu_task *)
Definition: starpu_scheduler.h:44
int starpu_push_task_end(struct starpu_task *task)
uint32_t starpu_task_footprint(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl)
void(* add_workers)(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
Definition: starpu_scheduler.h:49
double starpu_task_bundle_expected_energy(starpu_task_bundle_t bundle, struct starpu_perfmodel_arch *arch, unsigned nimpl)
int starpu_worker_can_execute_task_impl(unsigned workerid, struct starpu_task *task, unsigned *impl_mask)