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