StarPU Handbook

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

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
28 struct starpu_task_list
29 {
30 struct starpu_task *head;
31 struct starpu_task *tail;
32 };
33
34 static STARPU_INLINE
35 void starpu_task_list_init(struct starpu_task_list *list)
36 {
37 list->head = NULL;
38 list->tail = NULL;
39 }
40
41 static STARPU_INLINE
42 void starpu_task_list_push_front(struct starpu_task_list *list,
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
60 void starpu_task_list_push_back(struct starpu_task_list *list,
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
78 struct starpu_task *starpu_task_list_front(struct starpu_task_list *list)
79 {
80 return list->head;
81 }
82
83 static STARPU_INLINE
84 struct starpu_task *starpu_task_list_back(struct starpu_task_list *list)
85 {
86 return list->tail;
87 }
88
89 static STARPU_INLINE
90 int starpu_task_list_empty(struct starpu_task_list *list)
91 {
92 return (list->head == NULL);
93 }
94
95 static STARPU_INLINE
96 void starpu_task_list_erase(struct starpu_task_list *list,
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
124 struct starpu_task *starpu_task_list_pop_front(struct starpu_task_list *list)
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
135 struct starpu_task *starpu_task_list_pop_back(struct starpu_task_list *list)
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
146 struct starpu_task *starpu_task_list_begin(struct starpu_task_list *list)
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
158 struct starpu_task *starpu_task_list_next(struct starpu_task *task)
159 {
160 return task->next;
161 }
162
163 #ifdef __cplusplus
164 }
165 #endif
166
167 #endif /* __STARPU_TASK_LIST_H__ */
starpu_task_list::head
struct starpu_task * head
Definition: starpu_task_list.h:30
starpu_task.h
starpu_task_list_empty
static STARPU_INLINE int starpu_task_list_empty(struct starpu_task_list *list)
Definition: starpu_task_list.h:90
starpu_task_list_next
static STARPU_INLINE struct starpu_task * starpu_task_list_next(struct starpu_task *task)
Definition: starpu_task_list.h:158
starpu_task_list::tail
struct starpu_task * tail
Definition: starpu_task_list.h:31
starpu_task_list_front
static STARPU_INLINE struct starpu_task * starpu_task_list_front(struct starpu_task_list *list)
Definition: starpu_task_list.h:78
starpu_task::prev
struct starpu_task * prev
Definition: starpu_task.h:156
starpu_task_list
Definition: starpu_task_list.h:28
starpu_task_list_pop_front
static STARPU_INLINE struct starpu_task * starpu_task_list_pop_front(struct starpu_task_list *list)
Definition: starpu_task_list.h:124
starpu_task_list_init
static STARPU_INLINE void starpu_task_list_init(struct starpu_task_list *list)
Definition: starpu_task_list.h:35
starpu_task_list_push_front
static STARPU_INLINE void starpu_task_list_push_front(struct starpu_task_list *list, struct starpu_task *task)
Definition: starpu_task_list.h:42
starpu_task
Definition: starpu_task.h:104
starpu_util.h
starpu_task::next
struct starpu_task * next
Definition: starpu_task.h:157
starpu_task_list_push_back
static STARPU_INLINE void starpu_task_list_push_back(struct starpu_task_list *list, struct starpu_task *task)
Definition: starpu_task_list.h:60
starpu_task_list_erase
static STARPU_INLINE void starpu_task_list_erase(struct starpu_task_list *list, struct starpu_task *task)
Definition: starpu_task_list.h:96
starpu_task_list_pop_back
static STARPU_INLINE struct starpu_task * starpu_task_list_pop_back(struct starpu_task_list *list)
Definition: starpu_task_list.h:135
STARPU_ATTRIBUTE_UNUSED
#define STARPU_ATTRIBUTE_UNUSED
Definition: starpu_util.h:52
starpu_task_list_begin
static STARPU_INLINE struct starpu_task * starpu_task_list_begin(struct starpu_task_list *list)
Definition: starpu_task_list.h:146
starpu_task_list_back
static STARPU_INLINE struct starpu_task * starpu_task_list_back(struct starpu_task_list *list)
Definition: starpu_task_list.h:84