StarPU Internal Handbook
Loading...
Searching...
No Matches
task.h
Go to the documentation of this file.
1/* StarPU --- Runtime system for heterogeneous multicore architectures.
2 *
3 * Copyright (C) 2009-2023 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4 *
5 * StarPU is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation; either version 2.1 of the License, or (at
8 * your option) any later version.
9 *
10 * StarPU is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 *
14 * See the GNU Lesser General Public License in COPYING.LGPL for more details.
15 */
16
17#ifndef __CORE_TASK_H__
18#define __CORE_TASK_H__
19
22#include <starpu.h>
23#include <common/config.h>
24#include <core/jobs.h>
26
27#pragma GCC visibility push(hidden)
28
30void _starpu_task_destroy(struct starpu_task *task);
31
32#ifdef STARPU_OPENMP
35int _starpu_task_test_termination(struct starpu_task *task);
36#endif
37
42void _starpu_task_deinit(void);
43void _starpu_set_current_task(struct starpu_task *task);
44
45int _starpu_submit_job(struct _starpu_job *j, int nodeps);
46
47void _starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[], int check);
48
49#define _STARPU_JOB_UNSET ((struct _starpu_job *) NULL)
50#define _STARPU_JOB_SETTING ((struct _starpu_job *) 1)
51
54struct _starpu_job *_starpu_get_job_associated_to_task_slow(struct starpu_task *task, struct _starpu_job *job);
55static inline struct _starpu_job *_starpu_get_job_associated_to_task(struct starpu_task *task)
56{
57 STARPU_ASSERT(task);
58 struct _starpu_job *job = *(struct _starpu_job * volatile *) &task->starpu_private;
59
60 if (STARPU_LIKELY(job != _STARPU_JOB_UNSET && job != _STARPU_JOB_SETTING))
61 {
62 /* Already available */
63 STARPU_RMB();
64 return job;
65 }
66
68}
69
71int _starpu_task_submit_internally(struct starpu_task *task);
72
73int _starpu_handle_needs_conversion_task(starpu_data_handle_t handle,
74 unsigned int node);
75int
76_starpu_handle_needs_conversion_task_for_arch(starpu_data_handle_t handle,
77 enum starpu_node_kind node_kind);
78
79#ifdef STARPU_OPENMP
82 void (*continuation_callback_on_sleep)(void *arg), void *continuation_callback_on_sleep_arg);
83
84void _starpu_task_prepare_for_continuation(void);
85
86void _starpu_task_set_omp_cleanup_callback(struct starpu_task *task, void (*omp_cleanup_callback)(void *arg),
87 void *omp_cleanup_callback_arg);
88#endif
89
90int _starpu_task_uses_multiformat_handles(struct starpu_task *task);
91
92int _starpu_task_submit_conversion_task(struct starpu_task *task,
93 unsigned int workerid);
94
95void _starpu_task_check_deprecated_fields(struct starpu_task *task);
96void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl);
97
98static inline starpu_cpu_func_t _starpu_task_get_cpu_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
99{
100 return cl->cpu_funcs[nimpl];
101}
102
103static inline starpu_cuda_func_t _starpu_task_get_cuda_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
104{
105 return cl->cuda_funcs[nimpl];
106}
107
108static inline starpu_hip_func_t _starpu_task_get_hip_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
109{
110 return cl->hip_funcs[nimpl];
111}
112
113static inline starpu_opencl_func_t _starpu_task_get_opencl_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
114{
115 return cl->opencl_funcs[nimpl];
116}
117
118static inline starpu_max_fpga_func_t _starpu_task_get_fpga_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
119{
120 return cl->max_fpga_funcs[nimpl];
121}
122
123static inline const char *_starpu_task_get_cpu_name_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
124{
125 return cl->cpu_funcs_name[nimpl];
126}
127
128#define _STARPU_TASK_SET_INTERFACE(task, interface, i) do { if (task->dyn_handles) task->dyn_interfaces[i] = interface; else task->interfaces[i] = interface;} while(0)
129#define _STARPU_TASK_GET_INTERFACES(task) ((task->dyn_handles) ? task->dyn_interfaces : task->interfaces)
130
131void _starpu_watchdog_init(void);
132void _starpu_watchdog_shutdown(void);
133
134int _starpu_task_wait_for_all_and_return_nb_waited_tasks(void);
135int _starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(unsigned sched_ctx);
136
137#pragma GCC visibility pop
138
139#ifdef BUILDING_STARPU
140LIST_CREATE_TYPE_NOSTRUCT(starpu_task, prev, next);
141PRIO_LIST_CREATE_TYPE(starpu_task, priority);
142#endif
143
146{
147 _starpu_trs_uninitialized = 0,
148 _starpu_trs_initialized = 1,
149};
150
168
170 enum _starpu_trs_epoch_state state;
171
175
178
181
185);
186
188{
191 struct _starpu_trs_epoch_list epoch_list;
192
194 starpu_data_handle_t handle;
195
198
201 int (*do_start_func)(void *buffer, void* arg);
202 enum _starpu_trs_state state;
203
205 int flags;
206};
207
208#endif // __CORE_TASK_H__
starpu_node_kind
Definition starpu_worker.h:44
#define LIST_CREATE_TYPE_NOSTRUCT(ENAME, _prev, _next)
Definition list.h:190
Definition starpu_spinlock.h:82
Definition jobs.h:74
int workerid
Definition jobs.h:190
void(* continuation_callback_on_sleep)(void *arg)
Definition jobs.h:146
unsigned nimpl
Definition jobs.h:183
unsigned continuation_resubmit
Definition jobs.h:139
struct starpu_task * task
Definition jobs.h:79
Definition task.h:188
int dummy_data
Definition task.h:197
int(* do_start_func)(void *buffer, void *arg)
Definition task.h:201
struct _starpu_spinlock lock
Definition task.h:190
int flags
Definition task.h:205
starpu_data_handle_t handle
Definition task.h:194
void _starpu_task_prepare_for_continuation_ext(unsigned continuation_resubmit, void(*continuation_callback_on_sleep)(void *arg), void *continuation_callback_on_sleep_arg)
void _starpu_task_init(void)
_starpu_trs_epoch_state
Definition task.h:153
@ _starpu_trs_epoch_terminated
Definition task.h:166
@ _starpu_trs_epoch_confirmed
Definition task.h:160
@ _starpu_trs_epoch_cancelled
Definition task.h:163
@ _starpu_trs_epoch_inactive
Definition task.h:157
int is_begin
Definition task.h:177
int _starpu_task_test_termination(struct starpu_task *task)
void _starpu_task_destroy(struct starpu_task *task)
void * do_start_arg
Definition task.h:184
int is_end
Definition task.h:180
int do_sync
Definition task.h:174
_starpu_trs_state
Definition task.h:146
struct _starpu_job * _starpu_get_job_associated_to_task_slow(struct starpu_task *task, struct _starpu_job *job)
int _starpu_task_submit_internally(struct starpu_task *task)
Definition task.h:169