Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-singer committed Jan 22, 2025
1 parent c558ed6 commit f9b4c18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 6 additions & 6 deletions runtime/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1606,10 +1606,10 @@ void worker_scheduler(__cilkrts_worker *w) {
busy_pause();
}
const uint32_t local_wake = take_current_wake_value(rts);
if (local_wake == (nworkers - 1u)) {
finish_waking_thieves(rts);
} else if (thief_should_wait(local_wake)) {
if (thief_should_wait(local_wake)) {
break;
} else {
maybe_finish_waking_thieves(rts, local_wake, nworkers);
}
}
}
Expand Down Expand Up @@ -1656,16 +1656,16 @@ void *scheduler_thread_proc(void *arg) {
// use a condition variable to wait on g->start, because this approach
// seems to result in better performance.
uint32_t local_wake = take_current_wake_value(rts);

if (thief_should_wait(local_wake)) {
disengage_worker(rts, nworkers, self);
local_wake = thief_wait(rts);
l->wake_val = local_wake;
reengage_worker(rts, nworkers, self);
}

if (local_wake == (rts->nworkers - 1u)) {
finish_waking_thieves(rts);
}
maybe_finish_waking_thieves(rts, local_wake, nworkers);

CILK_STOP_TIMING(w, INTERVAL_SLEEP_UNCILK);

// Check if we should exit this scheduling function.
Expand Down
6 changes: 6 additions & 0 deletions runtime/worker_coord.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,10 @@ static inline void finish_waking_thieves(global_state *const g) {
#endif
}

static inline void maybe_finish_waking_thieves(global_state *const g, uint32_t nworkers, uint32_t local_wake) {
if (local_wake == (nworkers - 1u)) {
finish_waking_thieves(g);
}
}

#endif /* _WORKER_COORD_H */

0 comments on commit f9b4c18

Please sign in to comment.