1616#endif
1717#include < unistd.h>
1818
19+ #include " busyclosure.h"
1920#include " cilk-internal.h"
2021#include " debug.h"
2122#include " fiber.h"
2223#include " global.h"
2324#include " init.h"
2425#include " local.h"
25- #include " readydeque.h"
2626#include " sched_stats.h"
2727#include " scheduler.h"
2828
@@ -57,11 +57,11 @@ static void worker_local_destroy(local_state *l, global_state *g) {
5757 /* currently nothing to do here */
5858}
5959
60- static void deques_init (global_state *g) {
61- cilkrts_alert (BOOT, " (deques_init ) Initializing deques " );
60+ static void busy_init (global_state *g) {
61+ cilkrts_alert (BOOT, " (busy_init ) Initializing busy closures " );
6262 for (unsigned int i = 0 ; i < g->options .nproc ; i++) {
63- g->deques [i].bottom = nullptr ;
64- g->deques [i].mutex_owner = NO_WORKER;
63+ g->busy [i].closure = nullptr ;
64+ g->busy [i].mutex_owner = NO_WORKER;
6565 }
6666}
6767
@@ -363,7 +363,7 @@ global_state *__cilkrts_startup(int argc, char *argv[]) {
363363 cilkrts_alert (BOOT, " (__cilkrts_startup) argc %d" , argc);
364364 global_state *g = global_state_init (argc, argv);
365365 workers_init (g);
366- deques_init (g);
366+ busy_init (g);
367367
368368 // Create the root closure and a fiber to go with it. Use worker 0 to
369369 // allocate the closure and fiber.
@@ -560,7 +560,7 @@ void __cilkrts_internal_exit_cilkified_root(global_state *g,
560560
561561 worker_id self = w->self ;
562562 const bool is_boss = (0 == self);
563- ReadyDeque *deques = g->deques ;
563+ BusyClosure *busy = g->busy ;
564564
565565 // Mark the computation as done. Also "sleep" the workers: update global
566566 // flags so workers who exit the work-stealing loop will return to waiting
@@ -579,15 +579,15 @@ void __cilkrts_internal_exit_cilkified_root(global_state *g,
579579 w->extension = nullptr ;
580580 }
581581
582- // Clear this worker's deque . Nobody can successfully steal from this deque
583- // at this point, because head == tail, but we still want any subsequent
584- // Cilkified region to start with an empty deque. We go ahead and grab the
585- // deque lock to make sure no other worker has a lingering pointer to the
586- // closure.
587- ReadyDeque ::lock_self (deques , self);
588- deques [self].bottom = nullptr ;
589- WHEN_CILK_DEBUG (g->root_closure ->owner_ready_deque = NO_WORKER);
590- ReadyDeque ::unlock_self (deques , self);
582+ // Clear this worker's busy closure . Nobody can successfully steal from
583+ // this worker's deque at this point, because head == tail, but any
584+ // subsequent Cilkified region should still start with an empty busy
585+ // closure. We go ahead and grab the lock to make sure no other worker
586+ // has a lingering pointer to the closure.
587+ BusyClosure ::lock_self (busy , self);
588+ busy [self].closure = nullptr ;
589+ WHEN_CILK_DEBUG (g->root_closure ->owner = NO_WORKER);
590+ BusyClosure ::unlock_self (busy , self);
591591
592592 // Clear the flags in sf. This routine runs before leave_frame in a Cilk
593593 // function, but leave_frame is executed conditionally in Cilk functions
@@ -682,8 +682,8 @@ static void global_state_deinit(global_state *g) {
682682 free (g->workers );
683683 g->workers = nullptr ;
684684 g->nworkers = 0 ;
685- free (g->deques );
686- g->deques = nullptr ;
685+ free (g->busy );
686+ g->busy = nullptr ;
687687 delete [] g->threads ;
688688 g->threads = nullptr ;
689689 free (g->index_to_worker );
@@ -693,10 +693,10 @@ static void global_state_deinit(global_state *g) {
693693 free (g);
694694}
695695
696- static void deques_deinit (global_state *g) {
697- cilkrts_alert (BOOT, " (deques_deinit ) Clean up deques " );
696+ static void busy_deinit (global_state *g) {
697+ cilkrts_alert (BOOT, " (busy_deinit ) Clean up busy closures " );
698698 for (unsigned int i = 0 ; i < g->options .nproc ; i++) {
699- CILK_ASSERT (g->deques [i].mutex_owner == NO_WORKER);
699+ CILK_ASSERT (g->busy [i].mutex_owner == NO_WORKER);
700700 }
701701}
702702
@@ -790,7 +790,7 @@ void __cilkrts_shutdown(global_state *g) {
790790 // internal-malloc that does not include all the free fibers.
791791 global_state_terminate (g);
792792 workers_deinit (g);
793- deques_deinit (g);
793+ busy_deinit (g);
794794 global_state_deinit (g);
795795}
796796
0 commit comments