Skip to content

Commit 3c0fa53

Browse files
authored
Merge pull request #7113 from devreal/osc_rdma_cas
RDMA osc: perform CAS in shared memory if possible
2 parents d768d82 + 02dd877 commit 3c0fa53

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

ompi/mca/osc/rdma/osc_rdma_accumulate.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -812,14 +812,24 @@ int ompi_osc_rdma_compare_and_swap (const void *origin_addr, const void *compare
812812
lock_acquired = true;
813813
}
814814

815-
/* either we have and exclusive lock (via MPI_Win_lock() or the accumulate lock) or the
816-
* user has indicated that they will only use the same op (or same op and no op) for
817-
* operations on overlapping memory ranges. that indicates it is safe to go ahead and
818-
* use network atomic operations. */
819-
ret = ompi_osc_rdma_cas_atomic (sync, origin_addr, compare_addr, result_addr, dt,
820-
peer, target_address, target_handle, lock_acquired);
821-
if (OMPI_SUCCESS == ret) {
822-
return OMPI_SUCCESS;
815+
/* operate in (shared) memory if there is only a single node
816+
* OR if we have an exclusive lock
817+
* OR if other processes won't try to use the network either */
818+
bool use_shared_mem = module->single_node ||
819+
(ompi_osc_rdma_peer_local_base (peer) &&
820+
(ompi_osc_rdma_peer_is_exclusive (peer) ||
821+
!module->acc_single_intrinsic));
822+
823+
if (!use_shared_mem) {
824+
/* either we have an exclusive lock (via MPI_Win_lock() or the accumulate lock) or the
825+
* user has indicated that they will only use the same op (or same op and no op) for
826+
* operations on overlapping memory ranges. that indicates it is safe to go ahead and
827+
* use network atomic operations. */
828+
ret = ompi_osc_rdma_cas_atomic (sync, origin_addr, compare_addr, result_addr, dt,
829+
peer, target_address, target_handle, lock_acquired);
830+
if (OMPI_SUCCESS == ret) {
831+
return OMPI_SUCCESS;
832+
}
823833
}
824834

825835
if (!(lock_acquired || ompi_osc_rdma_peer_is_exclusive (peer))) {

0 commit comments

Comments
 (0)