StarPU Internal Handbook
cg.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2010-2022 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 __CG_H__
18 #define __CG_H__
19 
22 #include <starpu.h>
23 #include <common/config.h>
24 
25 #pragma GCC visibility push(hidden)
26 
32 #define STARPU_DYNAMIC_DEPS_SIZE 1
33 
34 /* randomly choosen ! */
35 #ifndef STARPU_DYNAMIC_DEPS_SIZE
36 #define STARPU_NMAXDEPS 256
37 #endif
38 
39 struct _starpu_job;
40 
45 {
47  struct _starpu_spinlock lock;
48 
50  unsigned ndeps; /* how many deps ? */
51  unsigned ndeps_completed; /* how many deps are done ? */
52 #ifdef STARPU_DEBUG
54  struct _starpu_cg **deps;
56  char *done;
57 #endif
58 
62  unsigned terminated;
63 
65  unsigned nsuccs; /* how many successors ? */
66 #ifdef STARPU_DYNAMIC_DEPS_SIZE
68  unsigned succ_list_size;
69  struct _starpu_cg **succ;
70 #else
71  struct _starpu_cg *succ[STARPU_NMAXDEPS];
72 #endif
73 };
74 
75 enum _starpu_cg_type
76 {
77  STARPU_CG_APPS=(1<<0),
78  STARPU_CG_TAG=(1<<1),
79  STARPU_CG_TASK=(1<<2)
80 };
81 
83 struct _starpu_cg
84 {
86  unsigned ntags;
88  unsigned remaining;
89 
90 #ifdef STARPU_DEBUG
91  unsigned ndeps;
93  void **deps;
95  char *done;
96 #endif
97 
98  enum _starpu_cg_type cg_type;
99 
100  union
101  {
103  struct _starpu_tag *tag;
104 
106  struct _starpu_job *job;
107 
112  struct
113  {
114  unsigned completed;
115  starpu_pthread_mutex_t cg_mutex;
116  starpu_pthread_cond_t cg_cond;
117  } succ_apps;
118  } succ;
119 };
120 
121 typedef struct _starpu_notify_job_start_data _starpu_notify_job_start_data;
122 
123 void _starpu_notify_dependencies(struct _starpu_job *j);
124 void _starpu_job_notify_start(struct _starpu_job *j, struct starpu_perfmodel_arch* perf_arch);
125 void _starpu_job_notify_ready_soon(struct _starpu_job *j, _starpu_notify_job_start_data *data);
126 
127 void _starpu_cg_list_init0(struct _starpu_cg_list *list);
128 void _starpu_cg_list_deinit(struct _starpu_cg_list *list);
129 int _starpu_add_successor_to_cg_list(struct _starpu_cg_list *successors, struct _starpu_cg *cg);
130 int _starpu_list_task_successors_in_cg_list(struct _starpu_cg_list *successors, unsigned ndeps, struct starpu_task *task_array[]);
131 int _starpu_list_task_scheduled_successors_in_cg_list(struct _starpu_cg_list *successors, unsigned ndeps, struct starpu_task *task_array[]);
132 int _starpu_list_tag_successors_in_cg_list(struct _starpu_cg_list *successors, unsigned ndeps, starpu_tag_t tag_array[]);
133 void _starpu_notify_cg(void *pred, struct _starpu_cg *cg);
134 void _starpu_notify_cg_list(void *pred, struct _starpu_cg_list *successors);
135 void _starpu_notify_job_start_cg_list(void *pred, struct _starpu_cg_list *successors, _starpu_notify_job_start_data *data);
136 void _starpu_notify_task_dependencies(struct _starpu_job *j);
137 void _starpu_notify_job_start_tasks(struct _starpu_job *j, _starpu_notify_job_start_data *data);
138 
139 #pragma GCC visibility pop
140 
141 #endif // __CG_H__
unsigned ntags
Definition: cg.h:86
unsigned nsuccs
Definition: cg.h:65
struct _starpu_spinlock lock
Definition: cg.h:47
unsigned remaining
Definition: cg.h:88
unsigned succ_list_size
Definition: cg.h:68
unsigned terminated
Definition: cg.h:62
unsigned ndeps
Definition: cg.h:50
Definition: cg.h:84
Definition: cg.h:45
Definition: starpu_spinlock.h:82
Definition: jobs.h:74
Definition: tags.h:51