StarPU Handbook
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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
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 {
44  if (list->tail == NULL)
45  {
46  list->tail = task;
47  }
48  else
49  {
50  list->head->prev = task;
51  }
52 
53  task->prev = NULL;
54  task->next = list->head;
55  list->head = task;
56 }
57 
58 static STARPU_INLINE
60 {
61  if (list->head == NULL)
62  {
63  list->head = task;
64  }
65  else
66  {
67  list->tail->next = task;
68  }
69 
70  task->next = NULL;
71  task->prev = list->tail;
72  list->tail = task;
73 }
74 
75 static STARPU_INLINE
77 {
78  return list->head;
79 }
80 
81 static STARPU_INLINE
83 {
84  return list->tail;
85 }
86 
87 static STARPU_INLINE
89 {
90  return (list->head == NULL);
91 }
92 
93 static STARPU_INLINE
94 void starpu_task_list_erase(struct starpu_task_list *list, struct starpu_task *task)
95 {
96  struct starpu_task *p = task->prev;
97 
98  if (p)
99  {
100  p->next = task->next;
101  }
102  else
103  {
104  list->head = task->next;
105  }
106 
107  if (task->next)
108  {
109  task->next->prev = p;
110  }
111  else
112  {
113  list->tail = p;
114  }
115 
116  task->prev = NULL;
117  task->next = NULL;
118 }
119 
120 static STARPU_INLINE
122 {
123  struct starpu_task *task = list->head;
124 
125  if (task)
126  starpu_task_list_erase(list, task);
127 
128  return task;
129 }
130 
131 static STARPU_INLINE
133 {
134  struct starpu_task *task = list->tail;
135 
136  if (task)
137  starpu_task_list_erase(list, task);
138 
139  return task;
140 }
141 
142 static STARPU_INLINE
144 {
145  return list->head;
146 }
147 
148 static STARPU_INLINE
149 struct starpu_task *starpu_task_list_end(struct starpu_task_list *list STARPU_ATTRIBUTE_UNUSED)
150 {
151  return NULL;
152 }
153 
154 static STARPU_INLINE
156 {
157  return task->next;
158 }
159 
160 #ifdef __cplusplus
161 }
162 #endif
163 
164 #endif /* __STARPU_TASK_LIST_H__ */
static STARPU_INLINE int starpu_task_list_empty(struct starpu_task_list *list)
Definition: starpu_task_list.h:88
static STARPU_INLINE struct starpu_task * starpu_task_list_next(struct starpu_task *task)
Definition: starpu_task_list.h:155
static STARPU_INLINE struct starpu_task * starpu_task_list_front(struct starpu_task_list *list)
Definition: starpu_task_list.h:76
Definition: starpu_task_list.h:28
struct starpu_task * prev
Definition: starpu_task.h:195
struct starpu_task * tail
Definition: starpu_task_list.h:31
static STARPU_INLINE struct starpu_task * starpu_task_list_pop_front(struct starpu_task_list *list)
Definition: starpu_task_list.h:121
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:123
struct starpu_task * next
Definition: starpu_task.h:196
static STARPU_INLINE void starpu_task_list_push_back(struct starpu_task_list *list, struct starpu_task *task)
Definition: starpu_task_list.h:59
static STARPU_INLINE void starpu_task_list_erase(struct starpu_task_list *list, struct starpu_task *task)
Definition: starpu_task_list.h:94
static STARPU_INLINE struct starpu_task * starpu_task_list_pop_back(struct starpu_task_list *list)
Definition: starpu_task_list.h:132
#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:143
static STARPU_INLINE struct starpu_task * starpu_task_list_back(struct starpu_task_list *list)
Definition: starpu_task_list.h:82
struct starpu_task * head
Definition: starpu_task_list.h:30