StarPU Handbook

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

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
starpu_task.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2 *
3 * Copyright (C) 2010-2014 Université de Bordeaux 1
4 * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
5 * Copyright (C) 2011 Télécom-SudParis
6 * Copyright (C) 2011 INRIA
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_TASK_H__
21 #define __STARPU_TASK_H__
22
23 #include <starpu.h>
24 #include <starpu_data.h>
25 #include <starpu_util.h>
26 #include <starpu_task_bundle.h>
27 #include <errno.h>
28
29 #if defined STARPU_USE_CUDA && !defined STARPU_DONT_INCLUDE_CUDA_HEADERS
30 # include <cuda.h>
31 #endif
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37
38 #define STARPU_CPU ((1ULL)<<1)
39 #define STARPU_CUDA ((1ULL)<<3)
40 #define STARPU_OPENCL ((1ULL)<<6)
41
42 enum starpu_codelet_type
43 {
44 STARPU_SEQ,
45 STARPU_SPMD,
46 STARPU_FORKJOIN
47 };
48
49 enum starpu_task_status
50 {
51 STARPU_TASK_INVALID,
52 #define STARPU_TASK_INVALID 0
53 STARPU_TASK_BLOCKED,
54 STARPU_TASK_READY,
55 STARPU_TASK_RUNNING,
56 STARPU_TASK_FINISHED,
57 STARPU_TASK_BLOCKED_ON_TAG,
58 STARPU_TASK_BLOCKED_ON_TASK,
59 STARPU_TASK_BLOCKED_ON_DATA
60 };
61
62 typedef uint64_t starpu_tag_t;
63
64 typedef void (*starpu_cpu_func_t)(void **, void*);
65 typedef void (*starpu_cuda_func_t)(void **, void*);
66 typedef void (*starpu_opencl_func_t)(void **, void*);
67
68 #define STARPU_MULTIPLE_CPU_IMPLEMENTATIONS ((starpu_cpu_func_t) -1)
69 #define STARPU_MULTIPLE_CUDA_IMPLEMENTATIONS ((starpu_cuda_func_t) -1)
70 #define STARPU_MULTIPLE_OPENCL_IMPLEMENTATIONS ((starpu_opencl_func_t) -1)
71
72 struct starpu_task;
73 struct starpu_codelet
74 {
75 uint32_t where;
76 int (*can_execute)(unsigned workerid, struct starpu_task *task, unsigned nimpl);
77 enum starpu_codelet_type type;
78 int max_parallelism;
79
80 starpu_cpu_func_t cpu_func STARPU_DEPRECATED;
81 starpu_cuda_func_t cuda_func STARPU_DEPRECATED;
82 starpu_opencl_func_t opencl_func STARPU_DEPRECATED;
83
84 starpu_cpu_func_t cpu_funcs[STARPU_MAXIMPLEMENTATIONS];
85 starpu_cuda_func_t cuda_funcs[STARPU_MAXIMPLEMENTATIONS];
86 starpu_opencl_func_t opencl_funcs[STARPU_MAXIMPLEMENTATIONS];
87
88 unsigned nbuffers;
89 enum starpu_data_access_mode modes[STARPU_NMAXBUFS];
90 enum starpu_data_access_mode *dyn_modes;
91
92 unsigned specific_nodes;
93 int nodes[STARPU_NMAXBUFS];
94 int *dyn_nodes;
95
96 struct starpu_perfmodel *model;
97 struct starpu_perfmodel *power_model;
98
99 unsigned long per_worker_stats[STARPU_NMAXWORKERS];
100
101 const char *name;
102 };
103
104 struct starpu_task
105 {
106 struct starpu_codelet *cl;
107
108 struct starpu_data_descr buffers[STARPU_NMAXBUFS] STARPU_DEPRECATED;
109 starpu_data_handle_t handles[STARPU_NMAXBUFS];
110 void *interfaces[STARPU_NMAXBUFS];
111
112 starpu_data_handle_t *dyn_handles;
113 void **dyn_interfaces;
114
115 void *cl_arg;
116 size_t cl_arg_size;
117 /* must StarPU release cl_arg ? - 0 by default */
118 unsigned cl_arg_free;
119
120 void (*callback_func)(void *);
121 void *callback_arg;
122 /* must StarPU release callback_arg ? - 0 by default */
123 unsigned callback_arg_free;
124
125 void (*prologue_callback_func)(void *);
126 void *prologue_callback_arg;
127 /* must StarPU release prologue_callback_arg ? - 0 by default */
128 unsigned prologue_callback_arg_free;
129
130 unsigned use_tag;
131 starpu_tag_t tag_id;
132
133 unsigned sequential_consistency;
134
135 unsigned synchronous;
136 int priority;
137
138 unsigned execute_on_a_specific_worker;
139 unsigned workerid;
140
141 starpu_task_bundle_t bundle;
142
143 int detach;
144 int destroy;
145 int regenerate;
146
147 enum starpu_task_status status;
148
149 struct starpu_profiling_task_info *profiling_info;
150
151 double predicted;
152 double predicted_transfer;
153
154 unsigned int mf_skip;
155
156 struct starpu_task *prev;
157 struct starpu_task *next;
158 void *starpu_private;
159 int magic;
160
161 unsigned sched_ctx;
162 int hypervisor_tag;
163 double flops;
164
165 unsigned scheduled;
166 };
167
168 #define STARPU_TASK_INITIALIZER \
169 { \
170 .cl = NULL, \
171 .cl_arg = NULL, \
172 .cl_arg_size = 0, \
173 .callback_func = NULL, \
174 .callback_arg = NULL, \
175 .priority = STARPU_DEFAULT_PRIO, \
176 .use_tag = 0, \
177 .synchronous = 0, \
178 .execute_on_a_specific_worker = 0, \
179 .bundle = NULL, \
180 .detach = 1, \
181 .destroy = 0, \
182 .regenerate = 0, \
183 .status = STARPU_TASK_INVALID, \
184 .profiling_info = NULL, \
185 .predicted = -1.0, \
186 .predicted_transfer = -1.0, \
187 .starpu_private = NULL, \
188 .magic = 42, \
189 .sched_ctx = 0, \
190 .hypervisor_tag = 0, \
191 .flops = 0.0, \
192 .scheduled = 0, \
193 .dyn_handles = NULL, \
194 .dyn_interfaces = NULL \
195 }
196
197 #define STARPU_TASK_GET_HANDLE(task, i) ((task->dyn_handles) ? task->dyn_handles[i] : task->handles[i])
198 #define STARPU_TASK_SET_HANDLE(task, handle, i) do { if (task->dyn_handles) task->dyn_handles[i] = handle; else task->handles[i] = handle; } while(0)
199
200 #define STARPU_CODELET_GET_MODE(codelet, i) ((codelet->dyn_modes) ? codelet->dyn_modes[i] : codelet->modes[i])
201 #define STARPU_CODELET_SET_MODE(codelet, mode, i) do { if (codelet->dyn_modes) codelet->dyn_modes[i] = mode; else codelet->modes[i] = mode; } while(0)
202
203 #define STARPU_CODELET_GET_NODE(codelet, i) ((codelet->dyn_nodes) ? codelet->dyn_nodes[i] : codelet->nodes[i])
204 #define STARPU_CODELET_SET_NODE(codelet, __node, i) do { if (codelet->dyn_nodes) codelet->dyn_nodes[i] = __node; else codelet->nodes[i] = __node; } while(0)
205
206 void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);
207 void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array);
208
209 void starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[]);
210
211 int starpu_tag_wait(starpu_tag_t id);
212 int starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id);
213
214 void starpu_tag_notify_from_apps(starpu_tag_t id);
215
216 void starpu_tag_restart(starpu_tag_t id);
217
218 void starpu_tag_remove(starpu_tag_t id);
219
220 void starpu_task_init(struct starpu_task *task);
221 void starpu_task_clean(struct starpu_task *task);
222
223 struct starpu_task *starpu_task_create(void);
224
225 void starpu_task_destroy(struct starpu_task *task);
226 int starpu_task_submit(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
227 int starpu_task_submit_to_ctx(struct starpu_task *task, unsigned sched_ctx_id);
228
229 int starpu_task_wait(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
230
231 int starpu_task_wait_for_all(void);
232
233 int starpu_task_wait_for_all_in_ctx(unsigned sched_ctx_id);
234
235 int starpu_task_wait_for_no_ready(void);
236
237 int starpu_task_nready(void);
238 int starpu_task_nsubmitted(void);
239
240 void starpu_codelet_init(struct starpu_codelet *cl);
241
242 void starpu_codelet_display_stats(struct starpu_codelet *cl);
243
244 struct starpu_task *starpu_task_get_current(void);
245
246 void starpu_parallel_task_barrier_init(struct starpu_task *task, int workerid);
247 void starpu_parallel_task_barrier_init_n(struct starpu_task *task, int worker_size);
248
249 struct starpu_task *starpu_task_dup(struct starpu_task *task);
250
251 void starpu_task_set_implementation(struct starpu_task *task, unsigned impl);
252 unsigned starpu_task_get_implementation(struct starpu_task *task);
253
254 #ifdef __cplusplus
255 }
256 #endif
257
258 #endif /* __STARPU_TASK_H__ */
STARPU_TASK_BLOCKED_ON_TAG
Definition: starpu_task.h:57
starpu_task::hypervisor_tag
int hypervisor_tag
Definition: starpu_task.h:162
starpu_task::predicted_transfer
double predicted_transfer
Definition: starpu_task.h:152
starpu_codelet
Definition: starpu_task.h:73
starpu_profiling_task_info
Definition: starpu_profiling.h:33
starpu_task::buffers
struct starpu_data_descr buffers[STARPU_NMAXBUFS]
Definition: starpu_task.h:108
starpu_task_submit_to_ctx
int starpu_task_submit_to_ctx(struct starpu_task *task, unsigned sched_ctx_id)
starpu_task::dyn_handles
starpu_data_handle_t * dyn_handles
Definition: starpu_task.h:112
starpu_task::prev
struct starpu_task * prev
Definition: starpu_task.h:156
starpu_task_nready
int starpu_task_nready(void)
starpu_task::detach
int detach
Definition: starpu_task.h:143
starpu_codelet::opencl_funcs
starpu_opencl_func_t opencl_funcs[STARPU_MAXIMPLEMENTATIONS]
Definition: starpu_task.h:86
starpu_task::magic
int magic
Definition: starpu_task.h:159
STARPU_TASK_INVALID
#define STARPU_TASK_INVALID
Definition: starpu_task.h:52
starpu_task_create
struct starpu_task * starpu_task_create(void)
starpu_codelet::specific_nodes
unsigned specific_nodes
Definition: starpu_task.h:92
starpu_tag_declare_deps
void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps,...)
STARPU_TASK_BLOCKED
Definition: starpu_task.h:53
starpu_task_submit
int starpu_task_submit(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT
starpu_task::sequential_consistency
unsigned sequential_consistency
Definition: starpu_task.h:133
starpu_codelet::dyn_modes
enum starpu_data_access_mode * dyn_modes
Definition: starpu_task.h:90
starpu_task_nsubmitted
int starpu_task_nsubmitted(void)
starpu_task::cl_arg_size
size_t cl_arg_size
Definition: starpu_task.h:116
starpu_data.h
starpu_task::tag_id
starpu_tag_t tag_id
Definition: starpu_task.h:131
starpu_task::cl_arg_free
unsigned cl_arg_free
Definition: starpu_task.h:118
starpu_task::cl_arg
void * cl_arg
Definition: starpu_task.h:115
starpu_tag_restart
void starpu_tag_restart(starpu_tag_t id)
starpu_task::dyn_interfaces
void ** dyn_interfaces
Definition: starpu_task.h:113
STARPU_FORKJOIN
Definition: starpu_task.h:46
STARPU_SPMD
Definition: starpu_task.h:45
starpu_task::regenerate
int regenerate
Definition: starpu_task.h:145
starpu_codelet::dyn_nodes
int * dyn_nodes
Definition: starpu_task.h:94
starpu_task::execute_on_a_specific_worker
unsigned execute_on_a_specific_worker
Definition: starpu_task.h:138
starpu_task::scheduled
unsigned scheduled
Definition: starpu_task.h:165
starpu_task_clean
void starpu_task_clean(struct starpu_task *task)
starpu_task_destroy
void starpu_task_destroy(struct starpu_task *task)
starpu_cuda_func_t
void(* starpu_cuda_func_t)(void **, void *)
Definition: starpu_task.h:65
starpu_task::callback_func
void(* callback_func)(void *)
Definition: starpu_task.h:120
starpu_task_wait_for_all
int starpu_task_wait_for_all(void)
starpu_codelet::name
const char * name
Definition: starpu_task.h:101
starpu_task::interfaces
void * interfaces[STARPU_NMAXBUFS]
Definition: starpu_task.h:110
starpu_codelet::cuda_funcs
starpu_cuda_func_t cuda_funcs[STARPU_MAXIMPLEMENTATIONS]
Definition: starpu_task.h:85
STARPU_SEQ
Definition: starpu_task.h:44
STARPU_TASK_READY
Definition: starpu_task.h:54
starpu_codelet::max_parallelism
int max_parallelism
Definition: starpu_task.h:78
starpu_task_bundle_t
struct _starpu_task_bundle * starpu_task_bundle_t
Definition: starpu_task_bundle.h:29
starpu_task::synchronous
unsigned synchronous
Definition: starpu_task.h:135
starpu_parallel_task_barrier_init
void starpu_parallel_task_barrier_init(struct starpu_task *task, int workerid)
starpu_task::callback_arg_free
unsigned callback_arg_free
Definition: starpu_task.h:123
starpu_task_wait_for_all_in_ctx
int starpu_task_wait_for_all_in_ctx(unsigned sched_ctx_id)
starpu_task::prologue_callback_arg
void * prologue_callback_arg
Definition: starpu_task.h:126
starpu_task
Definition: starpu_task.h:104
starpu_task_status
starpu_task_status
Definition: starpu_task.h:49
starpu_task::workerid
unsigned workerid
Definition: starpu_task.h:139
starpu_task_set_implementation
void starpu_task_set_implementation(struct starpu_task *task, unsigned impl)
starpu_tag_wait
int starpu_tag_wait(starpu_tag_t id)
starpu_task_get_implementation
unsigned starpu_task_get_implementation(struct starpu_task *task)
starpu_tag_remove
void starpu_tag_remove(starpu_tag_t id)
starpu_util.h
starpu_codelet::per_worker_stats
unsigned long per_worker_stats[STARPU_NMAXWORKERS]
Definition: starpu_task.h:99
starpu_tag_t
uint64_t starpu_tag_t
Definition: starpu_task.h:62
starpu_task_wait
int starpu_task_wait(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT
starpu_task::callback_arg
void * callback_arg
Definition: starpu_task.h:121
starpu_cpu_func_t
void(* starpu_cpu_func_t)(void **, void *)
Definition: starpu_task.h:64
starpu_task::handles
starpu_data_handle_t handles[STARPU_NMAXBUFS]
Definition: starpu_task.h:109
starpu_codelet::cuda_func
starpu_cuda_func_t cuda_func
Definition: starpu_task.h:81
starpu_task::next
struct starpu_task * next
Definition: starpu_task.h:157
starpu_codelet::cpu_func
starpu_cpu_func_t cpu_func
Definition: starpu_task.h:80
starpu_task::sched_ctx
unsigned sched_ctx
Definition: starpu_task.h:161
starpu_codelet::nodes
int nodes[STARPU_NMAXBUFS]
Definition: starpu_task.h:93
STARPU_NMAXWORKERS
#define STARPU_NMAXWORKERS
Definition: starpu_config.h:74
starpu_parallel_task_barrier_init_n
void starpu_parallel_task_barrier_init_n(struct starpu_task *task, int worker_size)
starpu_task_init
void starpu_task_init(struct starpu_task *task)
starpu_codelet::model
struct starpu_perfmodel * model
Definition: starpu_task.h:96
starpu_codelet_init
void starpu_codelet_init(struct starpu_codelet *cl)
starpu_task_get_current
struct starpu_task * starpu_task_get_current(void)
starpu_codelet::opencl_func
starpu_opencl_func_t opencl_func
Definition: starpu_task.h:82
starpu_task::status
enum starpu_task_status status
Definition: starpu_task.h:147
starpu_task::flops
double flops
Definition: starpu_task.h:163
starpu_task_bundle.h
starpu_codelet::modes
enum starpu_data_access_mode modes[STARPU_NMAXBUFS]
Definition: starpu_task.h:89
starpu_perfmodel
Definition: starpu_perfmodel.h:130
starpu_task::cl
struct starpu_codelet * cl
Definition: starpu_task.h:106
starpu_task::profiling_info
struct starpu_profiling_task_info * profiling_info
Definition: starpu_task.h:149
starpu_tag_wait_array
int starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id)
starpu_task::destroy
int destroy
Definition: starpu_task.h:144
starpu_codelet::where
uint32_t where
Definition: starpu_task.h:75
starpu_task_dup
struct starpu_task * starpu_task_dup(struct starpu_task *task)
STARPU_TASK_FINISHED
Definition: starpu_task.h:56
starpu_task_declare_deps_array
void starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[])
starpu_tag_declare_deps_array
void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array)
STARPU_WARN_UNUSED_RESULT
#define STARPU_WARN_UNUSED_RESULT
Definition: starpu_util.h:79
starpu_task::prologue_callback_func
void(* prologue_callback_func)(void *)
Definition: starpu_task.h:125
starpu_data_access_mode
starpu_data_access_mode
Definition: starpu_data.h:31
starpu_task::priority
int priority
Definition: starpu_task.h:136
starpu_task::use_tag
unsigned use_tag
Definition: starpu_task.h:130
STARPU_TASK_BLOCKED_ON_TASK
Definition: starpu_task.h:58
starpu_task::bundle
starpu_task_bundle_t bundle
Definition: starpu_task.h:141
starpu_data_handle_t
struct _starpu_data_state * starpu_data_handle_t
Definition: starpu_data.h:29
starpu_task::mf_skip
unsigned int mf_skip
Definition: starpu_task.h:154
starpu_task::prologue_callback_arg_free
unsigned prologue_callback_arg_free
Definition: starpu_task.h:128
starpu_codelet_display_stats
void starpu_codelet_display_stats(struct starpu_codelet *cl)
starpu_opencl_func_t
void(* starpu_opencl_func_t)(void **, void *)
Definition: starpu_task.h:66
starpu_codelet_type
starpu_codelet_type
Definition: starpu_task.h:42
starpu_tag_notify_from_apps
void starpu_tag_notify_from_apps(starpu_tag_t id)
starpu_codelet::can_execute
int(* can_execute)(unsigned workerid, struct starpu_task *task, unsigned nimpl)
Definition: starpu_task.h:76
STARPU_NMAXBUFS
#define STARPU_NMAXBUFS
Definition: starpu_config.h:70
starpu_codelet::nbuffers
unsigned nbuffers
Definition: starpu_task.h:88
STARPU_TASK_RUNNING
Definition: starpu_task.h:55
STARPU_TASK_BLOCKED_ON_DATA
Definition: starpu_task.h:59
starpu.h
starpu_data_descr
Definition: starpu_data.h:41
starpu_codelet::cpu_funcs
starpu_cpu_func_t cpu_funcs[STARPU_MAXIMPLEMENTATIONS]
Definition: starpu_task.h:84
starpu_codelet::power_model
struct starpu_perfmodel * power_model
Definition: starpu_task.h:97
starpu_task::starpu_private
void * starpu_private
Definition: starpu_task.h:158
starpu_codelet::type
enum starpu_codelet_type type
Definition: starpu_task.h:77
starpu_task_wait_for_no_ready
int starpu_task_wait_for_no_ready(void)
starpu_task::predicted
double predicted
Definition: starpu_task.h:151