@@ -19,7 +19,6 @@ struct ReadyDeque;
1919// Actual declaration
2020struct ReadyDeque {
2121 Closure *bottom;
22- Closure *top __attribute__ ((aligned(CILK_CACHE_LINE)));
2322 std::atomic<worker_id> mutex_owner
2423 __attribute__ ((aligned(CILK_CACHE_LINE)));
2524
@@ -93,54 +92,19 @@ struct ReadyDeque {
9392 * must have locked worker pn's deque before entering the function
9493 */
9594
96- Closure *xtract_top (worker_id self) {
97- /* ANGE: make sure w has the lock on worker pn's deque */
98- assert_ownership (self);
99-
100- if (Closure *cl = top) {
101- top = cl->next_ready ;
102- /* ANGE: if there is only one entry in the deque ... */
103- if (cl == bottom) {
104- CILK_ASSERT_NULL (cl->next_ready );
105- bottom = nullptr ;
106- } else {
107- CILK_ASSERT (cl->next_ready );
108- (cl->next_ready )->prev_ready = nullptr ;
109- }
110- cl->owner_ready_deque = NO_WORKER;
111- return cl;
112- }
113- CILK_ASSERT_NULL (bottom);
114- return nullptr ;
95+ static Closure *xtract (ReadyDeque *deques, worker_id self, worker_id pn) {
96+ return deques[pn].xtract (self);
11597 }
11698
117- static Closure *xtract_top (ReadyDeque *deques, worker_id self,
118- worker_id pn) {
119- return deques[pn].xtract_top (self);
120- }
121-
122- static Closure *xtract_bottom (ReadyDeque *deques, worker_id self,
123- worker_id pn) {
124- return deques[pn].xtract_bottom (self);
125- }
126-
127- Closure *xtract_bottom (worker_id self) {
99+ Closure *xtract (worker_id self) {
128100 /* ANGE: make sure w has the lock on worker pn's deque */
129101 assert_ownership (self);
130102
131103 if (Closure *cl = bottom) {
132- bottom = cl->prev_ready ;
133- if (cl == top) {
134- CILK_ASSERT_NULL (cl->prev_ready );
135- top = nullptr ;
136- } else {
137- CILK_ASSERT (cl->prev_ready );
138- (cl->prev_ready )->next_ready = nullptr ;
139- }
104+ bottom = nullptr ;
140105 cl->owner_ready_deque = NO_WORKER;
141106 return cl;
142107 }
143- CILK_ASSERT_NULL (top);
144108 return nullptr ;
145109 }
146110
@@ -149,7 +113,7 @@ struct ReadyDeque {
149113 assert_ownership (self);
150114
151115 /* ANGE: return the top but does not unlink it from the rest */
152- if (Closure *cl = top ) {
116+ if (Closure *cl = bottom ) {
153117 // If w is stealing, then it may peek the top of the deque
154118 // of the worker who is in the midst of exiting a
155119 // Cilkified region. In that case, cl will be the root
@@ -175,7 +139,6 @@ struct ReadyDeque {
175139 if (Closure *cl = bottom) {
176140 return cl;
177141 }
178- CILK_ASSERT_NULL (top);
179142 return nullptr ;
180143 }
181144
@@ -192,17 +155,9 @@ struct ReadyDeque {
192155 assert_ownership (self);
193156
194157 CILK_ASSERT (cl->owner_ready_deque == NO_WORKER);
195-
196- cl->prev_ready = bottom;
197- cl->next_ready = nullptr ;
158+ CILK_ASSERT_NULL (bottom);
198159 bottom = cl;
199160 cl->owner_ready_deque = pn;
200- if (top) {
201- CILK_ASSERT (cl->prev_ready );
202- (cl->prev_ready )->next_ready = cl;
203- } else {
204- top = cl;
205- }
206161 }
207162
208163 static void add_bottom (ReadyDeque *deques, Closure *cl,
0 commit comments