@@ -30,20 +30,13 @@ SLB4MPI::WorkStealingLoadBalancer::WorkStealingLoadBalancer(const MPI_Comm commu
3030#ifdef SLB4MPI_WITH_MPI
3131 this ->actual_rank = this ->rank ;
3232 this ->done = false ;
33+ this ->num_active = this ->nranks ;
3334
34- void * baseaddr;
35-
36- MPI_Win_allocate (sizeof (int ), sizeof (int ), MPI_INFO_NULL , this ->communicator , baseaddr, &(this ->window_num_active ));
35+ MPI_Win_create (&(this ->num_active ), sizeof (int ), sizeof (int ), MPI_INFO_NULL , this ->communicator , &(this ->window_num_active ));
3736 MPI_Win_create (&(this ->actual_rank ), sizeof (int ), sizeof (int ), MPI_INFO_NULL , this ->communicator , &(this ->window_actual_rank ));
3837 MPI_Win_create (&(this ->bounds ), 2 *sizeof (int64_t ), sizeof (int64_t ), MPI_INFO_NULL , this ->communicator , &(this ->window_bounds ));
3938 MPI_Win_create (&(this ->done ), sizeof (bool ), sizeof (bool ), MPI_INFO_NULL , this ->communicator , &(this ->window_done ));
4039
41- if (this ->rank == this ->root ) {
42- MPI_Win_lock (MPI_LOCK_EXCLUSIVE , this ->root , 0 , this ->window_num_active );
43- MPI_Put (&(this ->nranks ), 1 , MPI_INT , this ->root , 0 , 1 , MPI_INT , this ->window_num_active );
44- MPI_Win_unlock (this ->root , this ->window_num_active );
45- }
46-
4740 MPI_Barrier (this ->communicator );
4841#endif
4942}
@@ -83,8 +76,7 @@ bool SLB4MPI::WorkStealingLoadBalancer::get_range(int64_t& lower_bound, int64_t&
8376 if (upper_bound + 1 > this ->upper_bound && !this ->done ) {
8477 MPI_Win_lock (MPI_LOCK_EXCLUSIVE , this ->root , 0 , this ->window_num_active );
8578 int minus_one = -1 ;
86- int num_active;
87- MPI_Fetch_and_op (&minus_one, &num_active, MPI_INT , this ->root , 0 , MPI_SUM , this ->window_num_active );
79+ MPI_Fetch_and_op (&minus_one, &(this ->num_active ), MPI_INT , this ->root , 0 , MPI_SUM , this ->window_num_active );
8880 MPI_Win_unlock (this ->root , this ->window_num_active );
8981 this ->actual_rank = (this ->actual_rank + 1 ) % this ->nranks ;
9082 this ->done = true ;
@@ -141,11 +133,10 @@ bool SLB4MPI::WorkStealingLoadBalancer::get_range(int64_t& lower_bound, int64_t&
141133 }
142134 }
143135 // if could not steal job, check how many threads finished job
144- int num_active;
145136 MPI_Win_lock (MPI_LOCK_SHARED , this ->root , 0 , this ->window_num_active );
146- MPI_Get (&num_active, 1 , MPI_INT , this ->root , 0 , 1 , MPI_INT , this ->window_num_active );
137+ MPI_Get (&( this -> num_active ) , 1 , MPI_INT , this ->root , 0 , 1 , MPI_INT , this ->window_num_active );
147138 MPI_Win_unlock (this ->root , this ->window_num_active );
148- if (num_active == 0 ) return false ;
139+ if (this -> num_active == 0 ) return false ;
149140 this ->actual_rank = (this ->actual_rank + 1 ) % this ->nranks ;
150141 hop_count = 0 ;
151142 nohop_count = nohop_count + 1 ;
0 commit comments