Skip to content

Commit 5d9e5a2

Browse files
committed
osc/rdma: adjust the way use_cpu_atomics is evaluated
Currently, use_cpu_atomics is a variable in osc_rdma_module. However, whether CPU atomics can be used is a peer level decision. So this patch remove use_cpu_atomics from osc_rdma_module, and evaluate it for each peer. Signed-off-by: Wei Zhang <[email protected]>
1 parent ef501d8 commit 5d9e5a2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

ompi/mca/osc/rdma/osc_rdma.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ struct ompi_osc_rdma_module_t {
148148
/** value of same_size info key for this window */
149149
bool same_size;
150150

151-
/** CPU atomics can be used */
152-
bool use_cpu_atomics;
153-
154151
/** passive-target synchronization will not be used in this window */
155152
bool no_locks;
156153

ompi/mca/osc/rdma/osc_rdma_component.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ static int allocate_state_single (ompi_osc_rdma_module_t *module, void **base, s
492492
size_t total_size, local_rank_array_size, leader_peer_data_size;
493493
ompi_osc_rdma_peer_t *my_peer;
494494
int ret, my_rank;
495+
bool use_cpu_atomics;
495496

496497
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "allocating private internal state");
497498

@@ -569,7 +570,9 @@ static int allocate_state_single (ompi_osc_rdma_module_t *module, void **base, s
569570
my_peer->flags |= OMPI_OSC_RDMA_PEER_LOCAL_BASE;
570571
my_peer->state = (uint64_t) (uintptr_t) module->state;
571572

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) {
573576
/* all peers are local or it is safe to mix cpu and nic atomics */
574577
my_peer->flags |= OMPI_OSC_RDMA_PEER_LOCAL_STATE;
575578
} else {
@@ -588,7 +591,7 @@ static int allocate_state_single (ompi_osc_rdma_module_t *module, void **base, s
588591
ex_peer->size = size;
589592
}
590593

591-
if (!module->use_cpu_atomics) {
594+
if (!use_cpu_atomics) {
592595
if (MPI_WIN_FLAVOR_ALLOCATE == module->flavor) {
593596
/* base is local and cpu atomics are available */
594597
ex_peer->super.base_handle = module->state_handle;
@@ -622,6 +625,7 @@ static int synchronize_errorcode(int errorcode, ompi_communicator_t *comm)
622625
static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, size_t size)
623626
{
624627
ompi_communicator_t *shared_comm;
628+
bool use_cpu_atomics_on_peer;
625629
unsigned long offset, total_size;
626630
unsigned long state_base, data_base;
627631
int local_rank, local_size, ret;
@@ -640,10 +644,8 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
640644

641645
/* CPU atomics can be used if every process is on the same node or the NIC allows mixing CPU and NIC atomics */
642646
module->single_node = local_size == global_size;
643-
module->use_cpu_atomics = module->single_node;
644647
module->use_local_leader = true;
645648
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);
647649
/* the usage of local leader means to use different channels to send data to peer and update peer's state.
648650
* When different channels are used, active message RDMA cannot guarantee that put and atomics are completed
649651
* in the same order.
@@ -830,8 +832,9 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
830832

831833
ex_peer = (ompi_osc_rdma_peer_extended_t *) peer;
832834

835+
use_cpu_atomics_on_peer = (peer->data_btl->btl_atomic_flags & MCA_BTL_ATOMIC_SUPPORTS_GLOB);
833836
/* set up peer state */
834-
if (module->use_cpu_atomics) {
837+
if (use_cpu_atomics_on_peer) {
835838
/* all peers are local or it is safe to mix cpu and nic atomics */
836839
peer->flags |= OMPI_OSC_RDMA_PEER_LOCAL_STATE;
837840
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
864867
}
865868

866869
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) {
868871
/* use the local leader's endpoint */
869872
peer->data_endpoint = local_leader->data_endpoint;
870873
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
873876
ompi_osc_module_add_peer (module, peer);
874877

875878
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) {
877880
peer->flags |= OMPI_OSC_RDMA_PEER_LOCAL_BASE;
878881
}
879882
/* nothing more to do */
@@ -889,7 +892,7 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
889892
ex_peer->size = temp[i].size;
890893
}
891894

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)) {
893896
/* base is local and cpu atomics are available */
894897
if (MPI_WIN_FLAVOR_ALLOCATE == module->flavor) {
895898
ex_peer->super.base = (uintptr_t) module->segment_base + offset;

0 commit comments

Comments
 (0)