Skip to content

Commit 7cfc0e7

Browse files
committed
UCX osc: allow to asynchronously compare-and-swap
Signed-off-by: Joseph Schuchart <[email protected]>
1 parent 557ae80 commit 7cfc0e7

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

ompi/mca/osc/ucx/osc_ucx_comm.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,14 +808,29 @@ int ompi_osc_ucx_compare_and_swap(const void *origin_addr, const void *compare_a
808808
}
809809

810810
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);
814822

815823
if (module->acc_single_intrinsic) {
816824
return ret;
817825
}
818826

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+
819834
return end_atomicity(module, target);
820835
}
821836

0 commit comments

Comments
 (0)