Skip to content

Commit 7badf4f

Browse files
committed
[closure,readydeque] Remove dead code and unnecessary fields from ReadyDeque and Closure.
1 parent 6941148 commit 7badf4f

File tree

5 files changed

+18
-267
lines changed

5 files changed

+18
-267
lines changed

runtime/closure.h

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,10 @@ struct __attribute__((visibility("hidden"))) Closure {
4040
worker_id owner_ready_deque = NO_WORKER; /* debug only */
4141

4242
enum ClosureStatus status = CLOSURE_PRE_INVALID;
43-
bool has_cilk_callee = false;
4443
bool exception_pending = false;
4544
unsigned int join_counter = 0; /* number of outstanding spawned children */
4645
char *orig_rsp = nullptr; /* rsp one should use when sync successfully */
4746

48-
Closure *callee = nullptr;
49-
5047
Closure *call_parent = nullptr; /* the "parent" closure that called */
5148
Closure *spawn_parent = nullptr; /* the "parent" closure that spawned */
5249

@@ -55,26 +52,6 @@ struct __attribute__((visibility("hidden"))) Closure {
5552
// right most *spawned* child in the closure tree
5653
Closure *right_most_child = nullptr;
5754

58-
/*
59-
* stuff related to ready deque.
60-
*
61-
* ANGE: for top of the ReadyDeque, prev_ready = NULL
62-
* for bottom of the ReadyDeque, next_ready = NULL
63-
* next_ready pointing downward, prev_ready pointing upward
64-
*
65-
* top
66-
* next | ^
67-
* | | prev
68-
* v |
69-
* ...
70-
* next | ^
71-
* | | prev
72-
* v |
73-
* bottom
74-
*/
75-
Closure *next_ready = nullptr;
76-
Closure *prev_ready = nullptr;
77-
7855
hyper_table *right_ht = nullptr;
7956
hyper_table *child_ht = nullptr;
8057
hyper_table *user_ht = nullptr;
@@ -84,7 +61,7 @@ struct __attribute__((visibility("hidden"))) Closure {
8461
= NO_WORKER;
8562

8663
bool has_children() const {
87-
return (has_cilk_callee || join_counter != 0);
64+
return join_counter != 0;
8865
}
8966

9067
void set_status(enum ClosureStatus to) {

runtime/init.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ static void worker_local_destroy(local_state *l, global_state *g) {
6060
static void deques_init(global_state *g) {
6161
cilkrts_alert(BOOT, "(deques_init) Initializing deques");
6262
for (unsigned int i = 0; i < g->options.nproc; i++) {
63-
g->deques[i].top = nullptr;
6463
g->deques[i].bottom = nullptr;
6564
g->deques[i].mutex_owner = NO_WORKER;
6665
}
@@ -587,7 +586,6 @@ void __cilkrts_internal_exit_cilkified_root(global_state *g,
587586
// closure.
588587
ReadyDeque::lock_self(deques, self);
589588
deques[self].bottom = nullptr;
590-
deques[self].top = nullptr;
591589
WHEN_CILK_DEBUG(g->root_closure->owner_ready_deque = NO_WORKER);
592590
ReadyDeque::unlock_self(deques, self);
593591

runtime/readydeque.h

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct ReadyDeque;
1919
// Actual declaration
2020
struct 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

Comments
 (0)