StarPU Handbook
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
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 Université de Bordeaux 1
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 __STARPU_TASK_LIST_H__
18 #define __STARPU_TASK_LIST_H__
19 
20 #include <starpu_task.h>
21 #include <starpu_util.h>
22 
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27 
29 {
30  struct starpu_task *head;
31  struct starpu_task *tail;
32 };
33 
34 static STARPU_INLINE
36 {
37  list->head = NULL;
38  list->tail = NULL;
39 }
40 
41 static STARPU_INLINE
43  struct starpu_task *task)
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  struct starpu_task *task)
62 {
63  if (list->head == NULL)
64  {
65  list->head = task;
66  }
67  else
68  {
69  list->tail->next = task;
70  }
71 
72  task->next = NULL;
73  task->prev = list->tail;
74  list->tail = task;
75 }
76 
77 static STARPU_INLINE
79 {
80  return list->head;
81 }
82 
83 static STARPU_INLINE
85 {
86  return list->tail;
87 }
88 
89 static STARPU_INLINE
91 {
92  return (list->head == NULL);
93 }
94 
95 static STARPU_INLINE
97  struct starpu_task *task)
98 {
99  struct starpu_task *p = task->prev;
100 
101  if (p)
102  {
103  p->next = task->next;
104  }
105  else
106  {
107  list->head = task->next;
108  }
109 
110  if (task->next)
111  {
112  task->next->prev = p;
113  }
114  else
115  {
116  list->tail = p;
117  }
118 
119  task->prev = NULL;
120  task->next = NULL;
121 }
122 
123 static STARPU_INLINE
125 {
126  struct starpu_task *task = list->head;
127 
128  if (task)
129  starpu_task_list_erase(list, task);
130 
131  return task;
132 }
133 
134 static STARPU_INLINE
136 {
137  struct starpu_task *task = list->tail;
138 
139  if (task)
140  starpu_task_list_erase(list, task);
141 
142  return task;
143 }
144 
145 static STARPU_INLINE
147 {
148  return list->head;
149 }
150 
151 static STARPU_INLINE
152 struct starpu_task *starpu_task_list_end(struct starpu_task_list *list STARPU_ATTRIBUTE_UNUSED)
153 {
154  return NULL;
155 }
156 
157 static STARPU_INLINE
159 {
160  return task->next;
161 }
162 
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #endif /* __STARPU_TASK_LIST_H__ */
struct starpu_task * head
Definition: starpu_task_list.h:30
static STARPU_INLINE int starpu_task_list_empty(struct starpu_task_list *list)
Definition: starpu_task_list.h:90
static STARPU_INLINE struct starpu_task * starpu_task_list_next(struct starpu_task *task)
Definition: starpu_task_list.h:158
struct starpu_task * tail
Definition: starpu_task_list.h:31
static STARPU_INLINE struct starpu_task * starpu_task_list_front(struct starpu_task_list *list)
Definition: starpu_task_list.h:78
struct starpu_task * prev
Definition: starpu_task.h:156
Definition: starpu_task_list.h:28
static STARPU_INLINE struct starpu_task * starpu_task_list_pop_front(struct starpu_task_list *list)
Definition: starpu_task_list.h:124
static STARPU_INLINE void starpu_task_list_init(struct starpu_task_list *list)
Definition: starpu_task_list.h:35
static STARPU_INLINE void starpu_task_list_push_front(struct starpu_task_list *list, struct starpu_task *task)
Definition: starpu_task_list.h:42
Definition: starpu_task.h:104
struct starpu_task * next
Definition: starpu_task.h:157
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:96
static STARPU_INLINE struct starpu_task * starpu_task_list_pop_back(struct starpu_task_list *list)
Definition: starpu_task_list.h:135
#define STARPU_ATTRIBUTE_UNUSED
Definition: starpu_util.h:52
static STARPU_INLINE struct starpu_task * starpu_task_list_begin(struct starpu_task_list *list)
Definition: starpu_task_list.h:146
static STARPU_INLINE struct starpu_task * starpu_task_list_back(struct starpu_task_list *list)
Definition: starpu_task_list.h:84