StarPU Handbook
starpu_task_list.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2010-2012,2014,2016-2017 Université de Bordeaux
4  * Copyright (C) 2011-2015 CNRS
5  *
6  * StarPU is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or (at
9  * your option) any later version.
10  *
11  * StarPU is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  *
15  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
16  */
17 
18 #ifndef __STARPU_TASK_LIST_H__
19 #define __STARPU_TASK_LIST_H__
20 
21 #include <starpu_task.h>
22 #include <starpu_util.h>
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 
30 {
31  struct starpu_task *head;
32  struct starpu_task *tail;
33 };
34 
35 static STARPU_INLINE
37 {
38  list->head = NULL;
39  list->tail = NULL;
40 }
41 
42 static STARPU_INLINE
44 {
45  if (list->tail == NULL)
46  {
47  list->tail = task;
48  }
49  else
50  {
51  list->head->prev = task;
52  }
53 
54  task->prev = NULL;
55  task->next = list->head;
56  list->head = task;
57 }
58 
59 static STARPU_INLINE
61 {
62  if (list->head == NULL)
63  {
64  list->head = task;
65  }
66  else
67  {
68  list->tail->next = task;
69  }
70 
71  task->next = NULL;
72  task->prev = list->tail;
73  list->tail = task;
74 }
75 
76 static STARPU_INLINE
78 {
79  return list->head;
80 }
81 
82 static STARPU_INLINE
84 {
85  return list->tail;
86 }
87 
88 static STARPU_INLINE
90 {
91  return list->head == NULL;
92 }
93 
94 static STARPU_INLINE
95 void starpu_task_list_erase(struct starpu_task_list *list, struct starpu_task *task)
96 {
97  struct starpu_task *p = task->prev;
98 
99  if (p)
100  {
101  p->next = task->next;
102  }
103  else
104  {
105  list->head = task->next;
106  }
107 
108  if (task->next)
109  {
110  task->next->prev = p;
111  }
112  else
113  {
114  list->tail = p;
115  }
116 
117  task->prev = NULL;
118  task->next = NULL;
119 }
120 
121 static STARPU_INLINE
123 {
124  struct starpu_task *task = list->head;
125 
126  if (task)
127  starpu_task_list_erase(list, task);
128 
129  return task;
130 }
131 
132 static STARPU_INLINE
134 {
135  struct starpu_task *task = list->tail;
136 
137  if (task)
138  starpu_task_list_erase(list, task);
139 
140  return task;
141 }
142 
143 static STARPU_INLINE
145 {
146  return list->head;
147 }
148 
149 static STARPU_INLINE
150 struct starpu_task *starpu_task_list_end(struct starpu_task_list *list STARPU_ATTRIBUTE_UNUSED)
151 {
152  return NULL;
153 }
154 
155 static STARPU_INLINE
157 {
158  return task->next;
159 }
160 
161 static STARPU_INLINE
163 {
164  struct starpu_task *task;
165 
166  for (task = list->head; task != NULL; task = task->next)
167  if (task == look)
168  return 1;
169  return 0;
170 }
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif /* __STARPU_TASK_LIST_H__ */
static STARPU_INLINE int starpu_task_list_empty(struct starpu_task_list *list)
Definition: starpu_task_list.h:89
static STARPU_INLINE struct starpu_task * starpu_task_list_next(struct starpu_task *task)
Definition: starpu_task_list.h:156
static STARPU_INLINE struct starpu_task * starpu_task_list_front(struct starpu_task_list *list)
Definition: starpu_task_list.h:77
Definition: starpu_task_list.h:29
struct starpu_task * prev
Definition: starpu_task.h:204
struct starpu_task * tail
Definition: starpu_task_list.h:32
static STARPU_INLINE struct starpu_task * starpu_task_list_pop_front(struct starpu_task_list *list)
Definition: starpu_task_list.h:122
static STARPU_INLINE void starpu_task_list_init(struct starpu_task_list *list)
Definition: starpu_task_list.h:36
static STARPU_INLINE void starpu_task_list_push_front(struct starpu_task_list *list, struct starpu_task *task)
Definition: starpu_task_list.h:43
Definition: starpu_task.h:129
struct starpu_task * next
Definition: starpu_task.h:205
static STARPU_INLINE void starpu_task_list_push_back(struct starpu_task_list *list, struct starpu_task *task)
Definition: starpu_task_list.h:60
static STARPU_INLINE void starpu_task_list_erase(struct starpu_task_list *list, struct starpu_task *task)
Definition: starpu_task_list.h:95
static STARPU_INLINE struct starpu_task * starpu_task_list_pop_back(struct starpu_task_list *list)
Definition: starpu_task_list.h:133
#define STARPU_ATTRIBUTE_UNUSED
Definition: starpu_util.h:59
static STARPU_INLINE struct starpu_task * starpu_task_list_begin(struct starpu_task_list *list)
Definition: starpu_task_list.h:144
static STARPU_INLINE int starpu_task_list_ismember(struct starpu_task_list *list, struct starpu_task *look)
Definition: starpu_task_list.h:162
static STARPU_INLINE struct starpu_task * starpu_task_list_back(struct starpu_task_list *list)
Definition: starpu_task_list.h:83
struct starpu_task * head
Definition: starpu_task_list.h:31