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-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 __CG_H__
18 #define __CG_H__
19 
22 #include <starpu.h>
23 #include <common/config.h>
24 
28 #define STARPU_DYNAMIC_DEPS_SIZE 1
29 
30 /* randomly choosen ! */
31 #ifndef STARPU_DYNAMIC_DEPS_SIZE
32 #define STARPU_NMAXDEPS 256
33 #endif
34 
35 struct _starpu_job;
36 
41 {
43  struct _starpu_spinlock lock;
44 
46  unsigned ndeps; /* how many deps ? */
47  unsigned ndeps_completed; /* how many deps are done ? */
48 #ifdef STARPU_DEBUG
49 
50  struct _starpu_cg **deps;
52  char *done;
53 #endif
54 
58  unsigned terminated;
59 
61  unsigned nsuccs; /* how many successors ? */
62 #ifdef STARPU_DYNAMIC_DEPS_SIZE
63  unsigned succ_list_size; /* How many allocated items in succ */
64  struct _starpu_cg **succ;
65 #else
66  struct _starpu_cg *succ[STARPU_NMAXDEPS];
67 #endif
68 };
69 
70 enum _starpu_cg_type
71 {
72  STARPU_CG_APPS=(1<<0),
73  STARPU_CG_TAG=(1<<1),
74  STARPU_CG_TASK=(1<<2)
75 };
76 
78 struct _starpu_cg
79 {
80  unsigned ntags; /* number of tags depended on */
81  unsigned remaining; /* number of remaining tags */
82 
83 #ifdef STARPU_DEBUG
84  unsigned ndeps;
85  void **deps; /* array of predecessors, size ndeps */
86  char *done; /* which ones have notified, size ndeps */
87 #endif
88 
89  enum _starpu_cg_type cg_type;
90 
91  union
92  {
93  /* STARPU_CG_TAG */
94  struct _starpu_tag *tag;
95 
96  /* STARPU_CG_TASK */
97  struct _starpu_job *job;
98 
99  /* STARPU_CG_APPS */
100  /* in case this completion group is related to an application,
101  * we have to explicitely wake the waiting thread instead of
102  * reschedule the corresponding task */
103  struct
104  {
105  unsigned completed;
106  starpu_pthread_mutex_t cg_mutex;
107  starpu_pthread_cond_t cg_cond;
108  } succ_apps;
109  } succ;
110 };
111 
112 typedef struct _starpu_notify_job_start_data _starpu_notify_job_start_data;
113 
114 void _starpu_notify_dependencies(struct _starpu_job *j);
115 void _starpu_job_notify_start(struct _starpu_job *j, struct starpu_perfmodel_arch* perf_arch);
116 void _starpu_job_notify_ready_soon(struct _starpu_job *j, _starpu_notify_job_start_data *data);
117 
118 void _starpu_cg_list_init(struct _starpu_cg_list *list);
119 void _starpu_cg_list_deinit(struct _starpu_cg_list *list);
120 int _starpu_add_successor_to_cg_list(struct _starpu_cg_list *successors, struct _starpu_cg *cg);
121 int _starpu_list_task_successors_in_cg_list(struct _starpu_cg_list *successors, unsigned ndeps, struct starpu_task *task_array[]);
122 int _starpu_list_task_scheduled_successors_in_cg_list(struct _starpu_cg_list *successors, unsigned ndeps, struct starpu_task *task_array[]);
123 int _starpu_list_tag_successors_in_cg_list(struct _starpu_cg_list *successors, unsigned ndeps, starpu_tag_t tag_array[]);
124 void _starpu_notify_cg(void *pred, struct _starpu_cg *cg);
125 void _starpu_notify_cg_list(void *pred, struct _starpu_cg_list *successors);
126 void _starpu_notify_job_start_cg_list(void *pred, struct _starpu_cg_list *successors, _starpu_notify_job_start_data *data);
127 void _starpu_notify_task_dependencies(struct _starpu_job *j);
128 void _starpu_notify_job_start_tasks(struct _starpu_job *j, _starpu_notify_job_start_data *data);
129 
130 #endif // __CG_H__
_starpu_cg_list
Definition: cg.h:41
_starpu_cg_list::lock
struct _starpu_spinlock lock
Definition: cg.h:43
_starpu_cg_list::nsuccs
unsigned nsuccs
Definition: cg.h:61
_starpu_cg_list::terminated
unsigned terminated
Definition: cg.h:58
_starpu_tag
Definition: tags.h:50
_starpu_spinlock
Definition: starpu_spinlock.h:82
_starpu_job
Definition: jobs.h:79
_starpu_cg_list::ndeps
unsigned ndeps
Definition: cg.h:46
_starpu_cg
Definition: cg.h:79