@@ -492,6 +492,7 @@ static int allocate_state_single (ompi_osc_rdma_module_t *module, void **base, s
492
492
size_t total_size , local_rank_array_size , leader_peer_data_size ;
493
493
ompi_osc_rdma_peer_t * my_peer ;
494
494
int ret , my_rank ;
495
+ bool use_cpu_atomics ;
495
496
496
497
OSC_RDMA_VERBOSE (MCA_BASE_VERBOSE_TRACE , "allocating private internal state" );
497
498
@@ -569,7 +570,9 @@ static int allocate_state_single (ompi_osc_rdma_module_t *module, void **base, s
569
570
my_peer -> flags |= OMPI_OSC_RDMA_PEER_LOCAL_BASE ;
570
571
my_peer -> state = (uint64_t ) (uintptr_t ) module -> state ;
571
572
572
- if (module -> use_cpu_atomics ) {
573
+ assert (NULL != my_peer -> data_btl );
574
+ use_cpu_atomics = (my_peer -> data_btl -> btl_atomic_flags & MCA_BTL_ATOMIC_SUPPORTS_GLOB );
575
+ if (use_cpu_atomics ) {
573
576
/* all peers are local or it is safe to mix cpu and nic atomics */
574
577
my_peer -> flags |= OMPI_OSC_RDMA_PEER_LOCAL_STATE ;
575
578
} else {
@@ -588,7 +591,7 @@ static int allocate_state_single (ompi_osc_rdma_module_t *module, void **base, s
588
591
ex_peer -> size = size ;
589
592
}
590
593
591
- if (!module -> use_cpu_atomics ) {
594
+ if (!use_cpu_atomics ) {
592
595
if (MPI_WIN_FLAVOR_ALLOCATE == module -> flavor ) {
593
596
/* base is local and cpu atomics are available */
594
597
ex_peer -> super .base_handle = module -> state_handle ;
@@ -622,6 +625,7 @@ static int synchronize_errorcode(int errorcode, ompi_communicator_t *comm)
622
625
static int allocate_state_shared (ompi_osc_rdma_module_t * module , void * * base , size_t size )
623
626
{
624
627
ompi_communicator_t * shared_comm ;
628
+ bool use_cpu_atomics_on_peer ;
625
629
unsigned long offset , total_size ;
626
630
unsigned long state_base , data_base ;
627
631
int local_rank , local_size , ret ;
@@ -640,10 +644,8 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
640
644
641
645
/* CPU atomics can be used if every process is on the same node or the NIC allows mixing CPU and NIC atomics */
642
646
module -> single_node = local_size == global_size ;
643
- module -> use_cpu_atomics = module -> single_node ;
644
647
module -> use_local_leader = true;
645
648
for (int i = 0 ; i < module -> btls_in_use ; ++ i ) {
646
- module -> use_cpu_atomics = module -> use_cpu_atomics && !!(module -> selected_btls [i ]-> btl_atomic_flags & MCA_BTL_ATOMIC_SUPPORTS_GLOB );
647
649
/* the usage of local leader means to use different channels to send data to peer and update peer's state.
648
650
* When different channels are used, active message RDMA cannot guarantee that put and atomics are completed
649
651
* in the same order.
@@ -830,8 +832,9 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
830
832
831
833
ex_peer = (ompi_osc_rdma_peer_extended_t * ) peer ;
832
834
835
+ use_cpu_atomics_on_peer = (peer -> data_btl -> btl_atomic_flags & MCA_BTL_ATOMIC_SUPPORTS_GLOB );
833
836
/* set up peer state */
834
- if (module -> use_cpu_atomics ) {
837
+ if (use_cpu_atomics_on_peer ) {
835
838
/* all peers are local or it is safe to mix cpu and nic atomics */
836
839
peer -> flags |= OMPI_OSC_RDMA_PEER_LOCAL_STATE ;
837
840
peer -> state = (osc_rdma_counter_t ) peer_state ;
@@ -864,7 +867,7 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
864
867
}
865
868
866
869
if (MPI_WIN_FLAVOR_DYNAMIC != module -> flavor && MPI_WIN_FLAVOR_CREATE != module -> flavor &&
867
- !module -> use_cpu_atomics && temp [i ].size && i > 0 ) {
870
+ !use_cpu_atomics_on_peer && temp [i ].size && i > 0 ) {
868
871
/* use the local leader's endpoint */
869
872
peer -> data_endpoint = local_leader -> data_endpoint ;
870
873
peer -> data_btl = local_leader -> data_btl ;
@@ -873,7 +876,7 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
873
876
ompi_osc_module_add_peer (module , peer );
874
877
875
878
if (MPI_WIN_FLAVOR_DYNAMIC == module -> flavor ) {
876
- if (module -> use_cpu_atomics && peer_rank == my_rank ) {
879
+ if (use_cpu_atomics_on_peer && peer_rank == my_rank ) {
877
880
peer -> flags |= OMPI_OSC_RDMA_PEER_LOCAL_BASE ;
878
881
}
879
882
/* nothing more to do */
@@ -889,7 +892,7 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
889
892
ex_peer -> size = temp [i ].size ;
890
893
}
891
894
892
- if (module -> use_cpu_atomics && (MPI_WIN_FLAVOR_ALLOCATE == module -> flavor || peer_rank == my_rank )) {
895
+ if (use_cpu_atomics_on_peer && (MPI_WIN_FLAVOR_ALLOCATE == module -> flavor || peer_rank == my_rank )) {
893
896
/* base is local and cpu atomics are available */
894
897
if (MPI_WIN_FLAVOR_ALLOCATE == module -> flavor ) {
895
898
ex_peer -> super .base = (uintptr_t ) module -> segment_base + offset ;
0 commit comments