Skip to content

Commit 5be3c08

Browse files
committed
Resolve code review comments
1 parent 35f4018 commit 5be3c08

File tree

3 files changed

+26
-85
lines changed

3 files changed

+26
-85
lines changed

runtime/closure.h

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,29 @@ struct __attribute__((visibility("hidden"))) Closure {
3131
CILK_ASSERT(!frame);
3232
frame = sf;
3333
}
34-
struct cilk_fiber *fiber;
35-
struct cilk_fiber *fiber_child;
34+
struct cilk_fiber *fiber = nullptr;
35+
struct cilk_fiber *fiber_child = nullptr;
3636

37-
struct cilk_fiber *ext_fiber;
38-
struct cilk_fiber *ext_fiber_child;
37+
struct cilk_fiber *ext_fiber = nullptr;
38+
struct cilk_fiber *ext_fiber_child = nullptr;
3939

40-
worker_id owner_ready_deque; /* debug only */
40+
worker_id owner_ready_deque = NO_WORKER; /* debug only */
4141

42-
enum ClosureStatus status; /* doubles as magic number */
43-
bool has_cilk_callee;
44-
bool exception_pending;
45-
unsigned int join_counter; /* number of outstanding spawned children */
46-
char *orig_rsp; /* the rsp one should use when sync successfully */
42+
enum ClosureStatus status = CLOSURE_PRE_INVALID;
43+
bool has_cilk_callee = false;
44+
bool exception_pending = false;
45+
unsigned int join_counter = 0; /* number of outstanding spawned children */
46+
char *orig_rsp = nullptr; /* rsp one should use when sync successfully */
4747

48-
Closure *callee;
48+
Closure *callee = nullptr;
4949

50-
Closure *call_parent; /* the "parent" closure that called */
51-
Closure *spawn_parent; /* the "parent" closure that spawned */
50+
Closure *call_parent = nullptr; /* the "parent" closure that called */
51+
Closure *spawn_parent = nullptr; /* the "parent" closure that spawned */
5252

53-
Closure *left_sib; // left *spawned* sibling in the closure tree
54-
Closure *right_sib; // right *spawned* sibling in the closur tree
53+
Closure *left_sib = nullptr; // left *spawned* sibling in the closure tree
54+
Closure *right_sib = nullptr; // right *spawned* sibling in the closur tree
5555
// right most *spawned* child in the closure tree
56-
Closure *right_most_child;
56+
Closure *right_most_child = nullptr;
5757

5858
/*
5959
* stuff related to ready deque.
@@ -72,15 +72,16 @@ struct __attribute__((visibility("hidden"))) Closure {
7272
* v |
7373
* bottom
7474
*/
75-
Closure *next_ready;
76-
Closure *prev_ready;
75+
Closure *next_ready = nullptr;
76+
Closure *prev_ready = nullptr;
7777

78-
hyper_table *right_ht;
79-
hyper_table *child_ht;
80-
hyper_table *user_ht;
78+
hyper_table *right_ht = nullptr;
79+
hyper_table *child_ht = nullptr;
80+
hyper_table *user_ht = nullptr;
8181

8282
std::atomic<worker_id> mutex_owner
83-
__attribute__((aligned(CILK_CACHE_LINE)));
83+
__attribute__((aligned(CILK_CACHE_LINE)))
84+
= NO_WORKER;
8485

8586
bool has_children() const {
8687
return (has_cilk_callee || join_counter != 0);

runtime/scheduler.cpp

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,6 @@ void local_state::change_state(enum __cilkrts_worker_state s) {
8181
state = s;
8282
}
8383

84-
// JFC: The following comment refers to Cilk-M, not OpenCilk.
85-
// need to be careful when calling this function --- we check whether a
86-
// frame is set stolen (i.e., has a full frame associated with it), but note
87-
// that the setting of this can be delayed. A thief can steal a spawned
88-
// frame, but it cannot fully promote it until it remaps its TLMM stack,
89-
// because the flag field is stored in the frame on the TLMM stack. That
90-
// means, a frame can be stolen, in the process of being promoted, and
91-
// mean while, the stolen flag is not set until finish_promote.
9284
static bool Closure_at_top_of_stack(__cilkrts_worker *const w,
9385
__cilkrts_stack_frame *const frame) {
9486
__cilkrts_stack_frame **head = w->head.load(std::memory_order_relaxed);
@@ -436,17 +428,6 @@ static Closure *Closure_return(__cilkrts_worker *const w, worker_id self,
436428
l->provably_good_steal = true; // Use the existing SP in the frame
437429

438430
return child;
439-
440-
// // merge reducers
441-
// if (lht) {
442-
// active_ht = merge_two_hts(lht, active_ht);
443-
// }
444-
// if (rht) {
445-
// active_ht = merge_two_hts(active_ht, rht);
446-
// }
447-
448-
// parent->lock(self);
449-
// child->lock(self);
450431
}
451432

452433
// Cilk_exception_handler ended up pushing a stack frame onto child, to do
@@ -613,25 +594,6 @@ void __cilkrts_do_reductions(__cilkrts_stack_frame *sf) {
613594
}
614595

615596
w->hyper_table = ht;
616-
617-
// hyper_table *ht = Cilk_merge_hts(w);
618-
// while (ht != NULL) {
619-
// // The worker might have changed if the reduce operations executed
620-
// // parallel code. Reload the worker pointer.
621-
// w = get_worker_from_stack(sf);
622-
623-
// if (w->hyper_table == NULL) {
624-
// // The last call to Cilk_merge_hts did not create any new reducer
625-
// // views. Set w's hyper table to be the result and return.
626-
// w->hyper_table = ht;
627-
// break;
628-
// }
629-
630-
// // The last call to Cilk_merge_hts created more reducer views. Reduce
631-
// // those new views on the right of the returned hyper table.
632-
// w->l->lht = ht;
633-
// ht = Cilk_merge_hts(w);
634-
// }
635597
}
636598

637599
static void Cilk_do_reductions_for_return(__cilkrts_worker *w,
@@ -1836,29 +1798,7 @@ void *scheduler_thread_proc(void *arg) {
18361798
}
18371799

18381800
Closure::Closure(__cilkrts_stack_frame *frame)
1839-
: frame(frame),
1840-
fiber(nullptr),
1841-
fiber_child(nullptr),
1842-
ext_fiber(nullptr),
1843-
ext_fiber_child(nullptr),
1844-
owner_ready_deque(NO_WORKER),
1845-
status(CLOSURE_PRE_INVALID),
1846-
has_cilk_callee(false),
1847-
exception_pending(false),
1848-
join_counter(0),
1849-
orig_rsp(nullptr),
1850-
callee(nullptr),
1851-
call_parent(nullptr),
1852-
spawn_parent(nullptr),
1853-
left_sib(nullptr),
1854-
right_sib(nullptr),
1855-
right_most_child(nullptr),
1856-
next_ready(nullptr),
1857-
prev_ready(nullptr),
1858-
right_ht(nullptr),
1859-
child_ht(nullptr),
1860-
user_ht(nullptr),
1861-
mutex_owner(NO_WORKER)
1801+
: frame(frame)
18621802
{
18631803
}
18641804

runtime/worker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ struct __cilkrts_worker {
3939
// H could be moved elsewhere because it is only touched when stealing.
4040
std::atomic<struct __cilkrts_stack_frame **> tail;
4141
std::atomic<struct __cilkrts_stack_frame **> exc
42-
__attribute__((aligned(64)));
42+
__attribute__((aligned(CILK_CACHE_LINE)));
4343
std::atomic<struct __cilkrts_stack_frame **> head
44-
__attribute__((aligned(64)));
44+
__attribute__((aligned(CILK_CACHE_LINE)));
4545

4646
// Limit of the Lazy Task Queue, to detect queue overflow (debug only)
4747
struct __cilkrts_stack_frame **ltq_limit;

0 commit comments

Comments
 (0)