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-2020 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
30 
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 
52 static inline struct _starpu_job *_starpu_get_job_associated_to_task(struct starpu_task *task)
53 {
54  STARPU_ASSERT(task);
55  struct _starpu_job *job = (struct _starpu_job *) task->starpu_private;
56 
57  if (STARPU_UNLIKELY(!job))
58  {
59  job = _starpu_job_create(task);
60  task->starpu_private = job;
61  }
62 
63  return job;
64 }
65 
67 int _starpu_task_submit_internally(struct starpu_task *task);
68 
69 int _starpu_handle_needs_conversion_task(starpu_data_handle_t handle,
70  unsigned int node);
71 int
72 _starpu_handle_needs_conversion_task_for_arch(starpu_data_handle_t handle,
73  enum starpu_node_kind node_kind);
74 
75 #ifdef STARPU_OPENMP
76 
78  void (*continuation_callback_on_sleep)(void *arg), void *continuation_callback_on_sleep_arg);
79 
80 void _starpu_task_prepare_for_continuation(void);
81 
82 void _starpu_task_set_omp_cleanup_callback(struct starpu_task *task, void (*omp_cleanup_callback)(void *arg),
83  void *omp_cleanup_callback_arg);
84 #endif
85 
86 int _starpu_task_uses_multiformat_handles(struct starpu_task *task);
87 
88 int _starpu_task_submit_conversion_task(struct starpu_task *task,
89  unsigned int workerid);
90 
91 void _starpu_task_check_deprecated_fields(struct starpu_task *task);
92 void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl);
93 
94 static inline starpu_cpu_func_t _starpu_task_get_cpu_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
95 {
96  return cl->cpu_funcs[nimpl];
97 }
98 
99 static inline starpu_cuda_func_t _starpu_task_get_cuda_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
100 {
101  return cl->cuda_funcs[nimpl];
102 }
103 
104 static inline starpu_opencl_func_t _starpu_task_get_opencl_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
105 {
106  return cl->opencl_funcs[nimpl];
107 }
108 
109 static inline starpu_mic_func_t _starpu_task_get_mic_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
110 {
111  return cl->mic_funcs[nimpl];
112 }
113 
114 static inline starpu_mpi_ms_func_t _starpu_task_get_mpi_ms_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
115 {
116  return cl->mpi_ms_funcs[nimpl];
117 }
118 
119 static inline const char *_starpu_task_get_cpu_name_nth_implementation(struct starpu_codelet *cl, unsigned nimpl)
120 {
121  return cl->cpu_funcs_name[nimpl];
122 }
123 
124 #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)
125 #define _STARPU_TASK_GET_INTERFACES(task) ((task->dyn_handles) ? task->dyn_interfaces : task->interfaces)
126 
127 void _starpu_watchdog_init(void);
128 void _starpu_watchdog_shutdown(void);
129 
130 int _starpu_task_wait_for_all_and_return_nb_waited_tasks(void);
131 int _starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(unsigned sched_ctx);
132 
133 
134 #ifdef BUILDING_STARPU
135 LIST_CREATE_TYPE_NOSTRUCT(starpu_task, prev, next);
136 PRIO_LIST_CREATE_TYPE(starpu_task, priority);
137 #endif
138 
139 #endif // __CORE_TASK_H__
void _starpu_task_init(void)
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(* continuation_callback_on_sleep)(void *arg)
Definition: jobs.h:151
int _starpu_task_test_termination(struct starpu_task *task)
#define LIST_CREATE_TYPE_NOSTRUCT(ENAME, _prev, _next)
Definition: list.h:187
static struct _starpu_job * _starpu_get_job_associated_to_task(struct starpu_task *task)
Definition: task.h:52
struct _starpu_job * _starpu_job_create(struct starpu_task *task) STARPU_ATTRIBUTE_MALLOC
Definition: jobs.h:78
int _starpu_task_submit_internally(struct starpu_task *task)
void _starpu_task_destroy(struct starpu_task *task)
unsigned continuation_resubmit
Definition: jobs.h:144
unsigned nimpl
Definition: jobs.h:188