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-2025 University of Bordeaux, CNRS (LaBRI UMR 5800), Inria
4 * Copyright (C) 2013-2013 Thibaut Lambert
5 * Copyright (C) 2011-2011 Télécom Sud Paris
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>
41#include <core/errorcheck.h>
42#include <common/barrier.h>
43#include <common/utils.h>
44#include <common/list.h>
45
46#pragma GCC visibility push(hidden)
47
48struct _starpu_worker;
49
51typedef void (*_starpu_cl_func_t)(void **, void *);
52
53#define _STARPU_MAY_PERFORM(j, arch) ((j)->task->where & STARPU_##arch)
54
56{
57 starpu_data_handle_t handle;
58 enum starpu_data_access_mode mode;
59 int orig_node;
60 int node;
63 int index;
64
65 int orderedindex;
68};
69
70#ifdef STARPU_DEBUG
71MULTILIST_CREATE_TYPE(_starpu_job, all_submitted)
72#endif
75{
77 unsigned long job_id;
78
80 struct starpu_task *task;
81
87
90 starpu_pthread_mutex_t sync_mutex;
91 starpu_pthread_cond_t sync_cond;
92
96 struct _starpu_data_descr ordered_buffers[STARPU_NMAXBUFS];
97 struct _starpu_task_wrapper_dlist dep_slots[STARPU_NMAXBUFS];
98 struct _starpu_data_descr *dyn_ordered_buffers;
99 struct _starpu_task_wrapper_dlist *dyn_dep_slots;
100
104
108
110 struct starpu_task *end_rdep;
111
115 starpu_data_handle_t implicit_dep_handle;
116 struct _starpu_task_wrapper_dlist implicit_dep_slot;
117
124 unsigned submitted:2;
125
131 unsigned terminated:2;
132
133#ifdef STARPU_OPENMP
135 unsigned continuation;
136
141
148 void *continuation_callback_on_sleep_arg;
149
150 void (*omp_cleanup_callback)(void *arg);
151 void *omp_cleanup_callback_arg;
152
155
157 struct timespec cumulated_ts;
158
161#endif
162
165 uint32_t footprint;
166 unsigned footprint_is_computed:1;
167
171
173 unsigned internal:1;
176
181 unsigned reduction_task:1;
182
184 unsigned nimpl;
185
189
192
195
199
200 struct bound_task *bound_task;
201
203 starpu_pthread_barrier_t before_work_barrier;
204 starpu_pthread_barrier_t after_work_barrier;
205 unsigned after_work_busy_barrier;
206
207 struct _starpu_graph_node *graph_node;
208
209#ifdef STARPU_DEBUG
211 struct _starpu_job_multilist_all_submitted all_submitted;
212#endif
213
214#ifdef STARPU_BUBBLE
215 int already_turned_into_bubble;
216 unsigned is_bubble:1;
217#endif
218};
219
220#ifdef STARPU_DEBUG
221MULTILIST_CREATE_INLINES(struct _starpu_job, _starpu_job, all_submitted)
222#endif
223
224void _starpu_job_init(void);
225void _starpu_job_fini(void);
226
228struct _starpu_job* _starpu_job_create(struct starpu_task *task) STARPU_ATTRIBUTE_MALLOC;
229
232
235
238
239#ifdef STARPU_OPENMP
242
246 void (*continuation_callback_on_sleep)(void *arg), void *continuation_callback_on_sleep_arg);
247void _starpu_job_prepare_for_continuation(struct _starpu_job *j);
248void _starpu_job_set_omp_cleanup_callback(struct _starpu_job *j,
249 void (*omp_cleanup_callback)(void *arg), void *omp_cleanup_callback_arg);
250#endif
251
253void _starpu_exclude_task_from_dag(struct starpu_task *task);
254
257unsigned _starpu_enforce_deps_starting_from_task(struct _starpu_job *j);
258#ifdef STARPU_OPENMP
261#endif
262
263unsigned _starpu_take_deps_and_schedule(struct _starpu_job *j);
264void _starpu_enforce_deps_notify_job_ready_soon(struct _starpu_job *j, _starpu_notify_job_start_data *data, int tag);
265
271
273size_t _starpu_job_get_data_size(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, unsigned nimpl, struct _starpu_job *j);
274
277struct starpu_task *_starpu_pop_local_task(struct _starpu_worker *worker);
278
281int _starpu_push_local_task(struct _starpu_worker *worker, struct starpu_task *task);
282
283#define _STARPU_JOB_GET_ORDERED_BUFFER_INDEX(job, i) ((job->dyn_ordered_buffers) ? job->dyn_ordered_buffers[i].index : job->ordered_buffers[i].index)
284#define _STARPU_JOB_GET_ORDERED_BUFFER_HANDLE(job, i) ((job->dyn_ordered_buffers) ? job->dyn_ordered_buffers[i].handle : job->ordered_buffers[i].handle)
285#define _STARPU_JOB_GET_ORDERED_BUFFER_MODE(job, i) ((job->dyn_ordered_buffers) ? job->dyn_ordered_buffers[i].mode : job->ordered_buffers[i].mode)
286#define _STARPU_JOB_GET_ORDERED_BUFFER_NODE(job, i) ((job->dyn_ordered_buffers) ? job->dyn_ordered_buffers[i].node : job->ordered_buffers[i].node)
287#define _STARPU_JOB_GET_ORDERED_BUFFER_ORIG_NODE(job, i) ((job->dyn_ordered_buffers) ? job->dyn_ordered_buffers[i].orig_node : job->ordered_buffers[i].orig_node)
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#pragma GCC visibility pop
295
296#endif // __JOBS_H__
Definition: cg.h:45
Definition: coherency.h:133
Definition: graph.h:33
void _starpu_handle_job_submission(struct _starpu_job *j)
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)
struct starpu_task * _starpu_pop_local_task(struct _starpu_worker *worker)
int node
Definition: jobs.h:60
int _starpu_job_finished(struct _starpu_job *j)
struct _starpu_job * _starpu_job_create(struct starpu_task *task) STARPU_ATTRIBUTE_MALLOC
void _starpu_exclude_task_from_dag(struct starpu_task *task)
unsigned _starpu_enforce_deps_and_schedule(struct _starpu_job *j)
void _starpu_wait_job(struct _starpu_job *j)
int _starpu_push_local_task(struct _starpu_worker *worker, struct starpu_task *task)
int index
Definition: jobs.h:63
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:51
void _starpu_handle_job_termination(struct _starpu_job *j)
Definition: jobs.h:56
Definition: jobs.h:75
struct starpu_task * end_rdep
Definition: jobs.h:110
struct _starpu_cg_list job_successors
Definition: jobs.h:107
int workerid
Definition: jobs.h:191
double cumulated_energy_consumed
Definition: jobs.h:160
void(* continuation_callback_on_sleep)(void *arg)
Definition: jobs.h:147
uint32_t footprint
Definition: jobs.h:165
starpu_pthread_barrier_t before_work_barrier
Definition: jobs.h:203
struct timespec cumulated_ts
Definition: jobs.h:157
int combined_workerid
Definition: jobs.h:194
unsigned submitted
Definition: jobs.h:124
unsigned nimpl
Definition: jobs.h:184
unsigned continuation_resubmit
Definition: jobs.h:140
struct _starpu_data_descr ordered_buffers[STARPU_NMAXBUFS]
Definition: jobs.h:96
unsigned terminated
Definition: jobs.h:131
unsigned reduction_task
Definition: jobs.h:181
struct _starpu_job * quick_next
Definition: jobs.h:86
unsigned long job_id
Definition: jobs.h:77
struct _starpu_tag * tag
Definition: jobs.h:103
starpu_pthread_mutex_t sync_mutex
Definition: jobs.h:90
unsigned exclude_from_dag
Definition: jobs.h:170
starpu_data_handle_t implicit_dep_handle
Definition: jobs.h:115
int active_task_alias_count
Definition: jobs.h:198
unsigned sequential_consistency
Definition: jobs.h:175
unsigned internal
Definition: jobs.h:173
struct starpu_task * task
Definition: jobs.h:80
int task_size
Definition: jobs.h:188
unsigned discontinuous
Definition: jobs.h:154
unsigned continuation
Definition: jobs.h:135
Definition: workers.h:155
Definition: tags.h:51