StarPU Internal Handbook
jobs.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2008-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4  * Copyright (C) 2011 Télécom-SudParis
5  * Copyright (C) 2013 Thibaut Lambert
6  *
7  * StarPU is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at
10  * your option) any later version.
11  *
12  * StarPU is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
17  */
18 
19 #ifndef __JOBS_H__
20 #define __JOBS_H__
21 
24 #include <starpu.h>
25 #include <semaphore.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <stdint.h>
29 #include <string.h>
30 #include <stdarg.h>
31 #include <common/config.h>
32 #ifdef HAVE_UNISTD_H
33 #include <unistd.h>
34 #endif
35 #include <common/timing.h>
36 #include <common/list.h>
37 #include <common/fxt.h>
38 #include <core/dependencies/tags.h>
39 #include <datawizard/datawizard.h>
41 #include <core/errorcheck.h>
42 #include <common/barrier.h>
43 #include <common/utils.h>
44 #include <common/list.h>
45 
46 #ifdef STARPU_USE_CUDA
47 #include <cuda.h>
48 #endif
49 
50 struct _starpu_worker;
51 
53 typedef void (*_starpu_cl_func_t)(void **, void *);
54 
55 #define _STARPU_CPU_MAY_PERFORM(j) ((j)->task->where & STARPU_CPU)
56 #define _STARPU_CUDA_MAY_PERFORM(j) ((j)->task->where & STARPU_CUDA)
57 #define _STARPU_OPENCL_MAY_PERFORM(j) ((j)->task->where & STARPU_OPENCL)
58 #define _STARPU_MIC_MAY_PERFORM(j) ((j)->task->where & STARPU_MIC)
59 
61 {
62  starpu_data_handle_t handle;
63  enum starpu_data_access_mode mode;
64  int node;
67  int index;
68 
69  int orderedindex;
72 };
73 
74 #ifdef STARPU_DEBUG
75 MULTILIST_CREATE_TYPE(_starpu_job, all_submitted)
76 #endif
79 {
81  unsigned long job_id;
82 
84  struct starpu_task *task;
85 
91 
94  starpu_pthread_mutex_t sync_mutex;
95  starpu_pthread_cond_t sync_cond;
96 
100  struct _starpu_data_descr ordered_buffers[STARPU_NMAXBUFS];
101  struct _starpu_task_wrapper_dlist dep_slots[STARPU_NMAXBUFS];
102  struct _starpu_data_descr *dyn_ordered_buffers;
103  struct _starpu_task_wrapper_dlist *dyn_dep_slots;
104 
107  struct _starpu_tag *tag;
108 
112 
114  struct starpu_task *end_rdep;
115 
119  starpu_data_handle_t implicit_dep_handle;
120  struct _starpu_task_wrapper_dlist implicit_dep_slot;
121 
128  unsigned submitted:2;
129 
135  unsigned terminated:2;
136 
137 #ifdef STARPU_OPENMP
139  unsigned continuation;
140 
145 
151  void (*continuation_callback_on_sleep)(void *arg);
152  void *continuation_callback_on_sleep_arg;
153 
154  void (*omp_cleanup_callback)(void *arg);
155  void *omp_cleanup_callback_arg;
156 
158  unsigned discontinuous;
159 
161  struct timespec cumulated_ts;
162 
165 #endif
166 
169  uint32_t footprint;
170  unsigned footprint_is_computed:1;
171 
174  unsigned exclude_from_dag:1;
175 
177  unsigned internal:1;
180 
185  unsigned reduction_task:1;
186 
188  unsigned nimpl;
189 
193 
196 
200 
201  struct bound_task *bound_task;
202 
204  starpu_pthread_barrier_t before_work_barrier;
205  starpu_pthread_barrier_t after_work_barrier;
206  unsigned after_work_busy_barrier;
207 
208  struct _starpu_graph_node *graph_node;
209 
210 #ifdef STARPU_DEBUG
212  struct _starpu_job_multilist_all_submitted all_submitted;
213 #endif
214 };
215 
216 #ifdef STARPU_DEBUG
217 MULTILIST_CREATE_INLINES(struct _starpu_job, _starpu_job, all_submitted)
218 #endif
219 
220 void _starpu_job_init(void);
221 void _starpu_job_fini(void);
222 
224 struct _starpu_job* _starpu_job_create(struct starpu_task *task) STARPU_ATTRIBUTE_MALLOC;
225 
228 
231 
234 
235 #ifdef STARPU_OPENMP
238 
242  void (*continuation_callback_on_sleep)(void *arg), void *continuation_callback_on_sleep_arg);
243 void _starpu_job_prepare_for_continuation(struct _starpu_job *j);
244 void _starpu_job_set_omp_cleanup_callback(struct _starpu_job *j,
245  void (*omp_cleanup_callback)(void *arg), void *omp_cleanup_callback_arg);
246 #endif
247 
249 void _starpu_exclude_task_from_dag(struct starpu_task *task);
250 
253 unsigned _starpu_enforce_deps_starting_from_task(struct _starpu_job *j);
254 #ifdef STARPU_OPENMP
257 #endif
258 void _starpu_enforce_deps_notify_job_ready_soon(struct _starpu_job *j, _starpu_notify_job_start_data *data, int tag);
259 
265 
267 size_t _starpu_job_get_data_size(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, unsigned nimpl, struct _starpu_job *j);
268 
271 struct starpu_task *_starpu_pop_local_task(struct _starpu_worker *worker);
272 
277 int _starpu_push_local_task(struct _starpu_worker *worker, struct starpu_task *task, int prio);
278 
279 #define _STARPU_JOB_GET_ORDERED_BUFFER_INDEX(job, i) ((job->dyn_ordered_buffers) ? job->dyn_ordered_buffers[i].index : job->ordered_buffers[i].index)
280 #define _STARPU_JOB_GET_ORDERED_BUFFER_HANDLE(job, i) ((job->dyn_ordered_buffers) ? job->dyn_ordered_buffers[i].handle : job->ordered_buffers[i].handle)
281 #define _STARPU_JOB_GET_ORDERED_BUFFER_MODE(job, i) ((job->dyn_ordered_buffers) ? job->dyn_ordered_buffers[i].mode : job->ordered_buffers[i].mode)
282 #define _STARPU_JOB_GET_ORDERED_BUFFER_NODE(job, i) ((job->dyn_ordered_buffers) ? job->dyn_ordered_buffers[i].node : job->ordered_buffers[i].node)
283 
284 #define _STARPU_JOB_SET_ORDERED_BUFFER_INDEX(job, __index, i) do { if (job->dyn_ordered_buffers) job->dyn_ordered_buffers[i].index = (__index); else job->ordered_buffers[i].index = (__index);} while(0)
285 #define _STARPU_JOB_SET_ORDERED_BUFFER_HANDLE(job, __handle, i) do { if (job->dyn_ordered_buffers) job->dyn_ordered_buffers[i].handle = (__handle); else job->ordered_buffers[i].handle = (__handle);} while(0)
286 #define _STARPU_JOB_SET_ORDERED_BUFFER_MODE(job, __mode, i) do { if (job->dyn_ordered_buffers) job->dyn_ordered_buffers[i].mode = __mode; else job->ordered_buffers[i].mode = __mode;} while(0)
287 #define _STARPU_JOB_SET_ORDERED_BUFFER_NODE(job, __node, i) do { if (job->dyn_ordered_buffers) job->dyn_ordered_buffers[i].node = __node; else job->ordered_buffers[i].node = __node;} while(0)
288 
289 #define _STARPU_JOB_SET_ORDERED_BUFFER(job, buffer, i) do { if (job->dyn_ordered_buffers) job->dyn_ordered_buffers[i] = buffer; else job->ordered_buffers[i] = buffer;} while(0)
290 #define _STARPU_JOB_GET_ORDERED_BUFFERS(job) ((job->dyn_ordered_buffers) ? job->dyn_ordered_buffers : &job->ordered_buffers[0])
291 
292 #define _STARPU_JOB_GET_DEP_SLOTS(job) (((job)->dyn_dep_slots) ? (job)->dyn_dep_slots : (job)->dep_slots)
293 
294 #endif // __JOBS_H__
Definition: cg.h:41
Definition: coherency.h:105
Definition: graph.h:30
void _starpu_handle_job_submission(struct _starpu_job *j)
struct _starpu_job * _starpu_job_create(struct starpu_task *task) STARPU_ATTRIBUTE_MALLOC
void _starpu_job_prepare_for_continuation_ext(struct _starpu_job *j, unsigned continuation_resubmit, void(*continuation_callback_on_sleep)(void *arg), void *continuation_callback_on_sleep_arg)
int _starpu_test_job_termination(struct _starpu_job *j)
unsigned _starpu_reenforce_task_deps_and_schedule(struct _starpu_job *j)
void _starpu_job_destroy(struct _starpu_job *j)
int _starpu_job_finished(struct _starpu_job *j)
void _starpu_exclude_task_from_dag(struct starpu_task *task)
unsigned _starpu_enforce_deps_and_schedule(struct _starpu_job *j)
int _starpu_push_local_task(struct _starpu_worker *worker, struct starpu_task *task, int prio)
void _starpu_wait_job(struct _starpu_job *j)
struct starpu_task * _starpu_pop_local_task(struct _starpu_worker *worker)
int index
Definition: jobs.h:67
size_t _starpu_job_get_data_size(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, struct _starpu_job *j)
void(* _starpu_cl_func_t)(void **, void *)
Definition: jobs.h:53
void _starpu_handle_job_termination(struct _starpu_job *j)
Definition: jobs.h:61
Definition: jobs.h:79
struct starpu_task * end_rdep
Definition: jobs.h:114
struct _starpu_cg_list job_successors
Definition: jobs.h:111
double cumulated_energy_consumed
Definition: jobs.h:164
void(* continuation_callback_on_sleep)(void *arg)
Definition: jobs.h:151
uint32_t footprint
Definition: jobs.h:169
starpu_pthread_barrier_t before_work_barrier
Definition: jobs.h:204
struct timespec cumulated_ts
Definition: jobs.h:161
int combined_workerid
Definition: jobs.h:195
unsigned submitted
Definition: jobs.h:128
unsigned nimpl
Definition: jobs.h:188
unsigned continuation_resubmit
Definition: jobs.h:144
struct _starpu_data_descr ordered_buffers[STARPU_NMAXBUFS]
Definition: jobs.h:100
unsigned terminated
Definition: jobs.h:135
unsigned reduction_task
Definition: jobs.h:185
struct _starpu_job * quick_next
Definition: jobs.h:90
unsigned long job_id
Definition: jobs.h:81
struct _starpu_tag * tag
Definition: jobs.h:107
starpu_pthread_mutex_t sync_mutex
Definition: jobs.h:94
unsigned exclude_from_dag
Definition: jobs.h:174
starpu_data_handle_t implicit_dep_handle
Definition: jobs.h:119
int active_task_alias_count
Definition: jobs.h:199
unsigned sequential_consistency
Definition: jobs.h:179
struct starpu_task * task
Definition: jobs.h:84
int task_size
Definition: jobs.h:192
unsigned discontinuous
Definition: jobs.h:158
unsigned continuation
Definition: jobs.h:139
Definition: workers.h:70
Definition: tags.h:49