StarPU Internal Handbook
task.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2009-2021 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>
25 
27 void _starpu_task_destroy(struct starpu_task *task);
28 
29 #ifdef STARPU_OPENMP
32 int _starpu_task_test_termination(struct starpu_task *task);
33 #endif
34 
38 void _starpu_task_init(void);
39 void _starpu_task_deinit(void);
40 void _starpu_set_current_task(struct starpu_task *task);
41 
42 /* NB the second argument makes it possible to count regenerable tasks only
43  * once. */
44 int _starpu_submit_job(struct _starpu_job *j);
45 
46 int _starpu_task_submit_nodeps(struct starpu_task *task);
47 
48 void _starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[], int check);
49 
50 #define _STARPU_JOB_UNSET ((struct _starpu_job *) NULL)
51 #define _STARPU_JOB_SETTING ((struct _starpu_job *) 1)
52 
55 struct _starpu_job *_starpu_get_job_associated_to_task_slow(struct starpu_task *task, struct _starpu_job *job);
56 static inline struct _starpu_job *_starpu_get_job_associated_to_task(struct starpu_task *task)
57 {
58  STARPU_ASSERT(task);
59  struct _starpu_job *job = (struct _starpu_job *) task->starpu_private;
60 
61  if (STARPU_LIKELY(job != _STARPU_JOB_UNSET && job != _STARPU_JOB_SETTING))
62  {
63  /* Already available */
64  STARPU_RMB();
65  return job;
66  }
67 
69 }
70 
72 int _starpu_task_submit_internally(struct starpu_task *task);
73 
74 int _starpu_handle_needs_conversion_task(starpu_data_handle_t handle,
75  unsigned int node);
76 int
77 _starpu_handle_needs_conversion_task_for_arch(starpu_data_handle_t handle,
78  enum starpu_node_kind node_kind);
79 
80 #ifdef STARPU_OPENMP
83  void (*continuation_callback_on_sleep)(void *arg), void *continuation_callback_on_sleep_arg);
84 
85 void _starpu_task_prepare_for_continuation(void);
86 
87 void _starpu_task_set_omp_cleanup_callback(struct starpu_task *task, void (*omp_cleanup_callback)(void *arg),
88  void *omp_cleanup_callback_arg);
89 #endif
90 
91 int _starpu_task_uses_multiformat_handles(struct starpu_task *task);
92 
93 int _starpu_task_submit_conversion_task(struct starpu_task *task,
94  unsigned int workerid);
95 
96 void _starpu_task_check_deprecated_fields(struct starpu_task *task);
97 void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl);
98 
99 static inline starpu_cpu_func_t _starpu_task_get_cpu_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
100 {
101  return cl->cpu_funcs[nimpl];
102 }
103 
104 static inline starpu_cuda_func_t _starpu_task_get_cuda_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
105 {
106  return cl->cuda_funcs[nimpl];
107 }
108 
109 static inline starpu_opencl_func_t _starpu_task_get_opencl_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
110 {
111  return cl->opencl_funcs[nimpl];
112 }
113 
114 static inline starpu_mic_func_t _starpu_task_get_mic_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
115 {
116  return cl->mic_funcs[nimpl];
117 }
118 
119 static inline starpu_mpi_ms_func_t _starpu_task_get_mpi_ms_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
120 {
121  return cl->mpi_ms_funcs[nimpl];
122 }
123 
124 static inline const char *_starpu_task_get_cpu_name_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
125 {
126  return cl->cpu_funcs_name[nimpl];
127 }
128 
129 #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)
130 #define _STARPU_TASK_GET_INTERFACES(task) ((task->dyn_handles) ? task->dyn_interfaces : task->interfaces)
131 
132 void _starpu_watchdog_init(void);
133 void _starpu_watchdog_shutdown(void);
134 
135 int _starpu_task_wait_for_all_and_return_nb_waited_tasks(void);
136 int _starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(unsigned sched_ctx);
137 
138 
139 #ifdef BUILDING_STARPU
140 LIST_CREATE_TYPE_NOSTRUCT(starpu_task, prev, next);
141 PRIO_LIST_CREATE_TYPE(starpu_task, priority);
142 #endif
143 
144 #endif // __CORE_TASK_H__
#define LIST_CREATE_TYPE_NOSTRUCT(ENAME, _prev, _next)
Definition: list.h:187
Definition: jobs.h:79
void(* continuation_callback_on_sleep)(void *arg)
Definition: jobs.h:151
unsigned nimpl
Definition: jobs.h:188
unsigned continuation_resubmit
Definition: jobs.h:144
struct starpu_task * task
Definition: jobs.h:84
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)
int _starpu_task_test_termination(struct starpu_task *task)
void _starpu_task_destroy(struct starpu_task *task)
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)