Skip to content

Commit c793e21

Browse files
committed
OMPI/OSC/UCX: adding atomic lock for fetch_and_op and compare_and_swap
1 parent dbefb35 commit c793e21

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

ompi/mca/osc/ucx/osc_ucx_comm.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,11 @@ int ompi_osc_ucx_compare_and_swap(const void *origin_addr, const void *compare_a
567567
return ret;
568568
}
569569

570+
ret = start_atomicity(module, ep, target);
571+
if (ret != OMPI_SUCCESS) {
572+
return ret;
573+
}
574+
570575
ompi_datatype_type_size(dt, &dt_bytes);
571576
memcpy(result_addr, origin_addr, dt_bytes);
572577
req = ucp_atomic_fetch_nb(ep, UCP_ATOMIC_FETCH_OP_CSWAP, *(uint64_t *)compare_addr,
@@ -575,7 +580,12 @@ int ompi_osc_ucx_compare_and_swap(const void *origin_addr, const void *compare_a
575580
ucp_request_release(req);
576581
}
577582

578-
return incr_and_check_ops_num(module, target, ep);
583+
ret = incr_and_check_ops_num(module, target, ep);
584+
if (ret != OMPI_SUCCESS) {
585+
return ret;
586+
}
587+
588+
return end_atomicity(module, ep, target);
579589
}
580590

581591
int ompi_osc_ucx_fetch_and_op(const void *origin_addr, void *result_addr,
@@ -600,6 +610,11 @@ int ompi_osc_ucx_fetch_and_op(const void *origin_addr, void *result_addr,
600610
size_t dt_bytes;
601611
ompi_osc_ucx_internal_request_t *req = NULL;
602612

613+
ret = start_atomicity(module, ep, target);
614+
if (ret != OMPI_SUCCESS) {
615+
return ret;
616+
}
617+
603618
ompi_datatype_type_size(dt, &dt_bytes);
604619

605620
if (op == &ompi_mpi_op_replace.op) {
@@ -617,7 +632,12 @@ int ompi_osc_ucx_fetch_and_op(const void *origin_addr, void *result_addr,
617632
ucp_request_release(req);
618633
}
619634

620-
return incr_and_check_ops_num(module, target, ep);
635+
ret = incr_and_check_ops_num(module, target, ep);
636+
if (ret != OMPI_SUCCESS) {
637+
return ret;
638+
}
639+
640+
return end_atomicity(module, ep, target);
621641
} else {
622642
return ompi_osc_ucx_get_accumulate(origin_addr, 1, dt, result_addr, 1, dt,
623643
target, target_disp, 1, dt, op, win);

0 commit comments

Comments
 (0)