@@ -808,14 +808,29 @@ int ompi_osc_ucx_compare_and_swap(const void *origin_addr, const void *compare_a
808
808
}
809
809
810
810
ompi_datatype_type_size (dt , & dt_bytes );
811
- ret = opal_common_ucx_wpmem_cmpswp (module -> mem ,* (uint64_t * )compare_addr ,
812
- * (uint64_t * )origin_addr , target ,
813
- result_addr , dt_bytes , remote_addr );
811
+ if (sizeof (uint64_t ) < dt_bytes ) {
812
+ return OMPI_ERR_NOT_SUPPORTED ;
813
+ }
814
+
815
+ uint64_t compare_val ;
816
+ memcpy (& compare_val , compare_addr , dt_bytes );
817
+ memcpy (result_addr , origin_addr , dt_bytes );
818
+ ret = opal_common_ucx_wpmem_fetch_nb (module -> mem , UCP_ATOMIC_FETCH_OP_CSWAP ,
819
+ compare_val , target ,
820
+ result_addr , dt_bytes , remote_addr ,
821
+ NULL , NULL );
814
822
815
823
if (module -> acc_single_intrinsic ) {
816
824
return ret ;
817
825
}
818
826
827
+ // fence before releasing the accumulate lock
828
+ ret = opal_common_ucx_wpmem_fence (module -> mem );
829
+ if (ret != OMPI_SUCCESS ) {
830
+ OSC_UCX_VERBOSE (1 , "opal_common_ucx_mem_fence failed: %d" , ret );
831
+ // don't return error, try to release the accumulate lock
832
+ }
833
+
819
834
return end_atomicity (module , target );
820
835
}
821
836
0 commit comments