@@ -812,14 +812,24 @@ int ompi_osc_rdma_compare_and_swap (const void *origin_addr, const void *compare
812
812
lock_acquired = true;
813
813
}
814
814
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
+ }
823
833
}
824
834
825
835
if (!(lock_acquired || ompi_osc_rdma_peer_is_exclusive (peer ))) {
0 commit comments