MCA/UCX: cswap call if updated to non-blocking API
- minor fixes Signed-off-by: Sergey Oblomov <sergeyo@mellanox.com>
Этот коммит содержится в:
родитель
b668e19cd1
Коммит
6be4066e23
@ -31,37 +31,43 @@ int mca_atomic_ucx_cswap(void *target,
|
||||
spml_ucx_mkey_t *ucx_mkey;
|
||||
uint64_t rva;
|
||||
uint64_t val;
|
||||
uint64_t cmp;
|
||||
|
||||
if ((8 != nlong) && (4 != nlong)) {
|
||||
if (8 == nlong) {
|
||||
val = *(uint64_t*)value;
|
||||
} else if (4 == nlong) {
|
||||
val = *(uint32_t*)value;
|
||||
} else {
|
||||
ATOMIC_ERROR("[#%d] Type size must be 4 or 8 bytes.", my_pe);
|
||||
return OSHMEM_ERROR;
|
||||
}
|
||||
|
||||
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva);
|
||||
val = (8 == nlong) ? *(uint64_t*)value : *(uint32_t*)value;
|
||||
if (NULL == cond) {
|
||||
status_ptr = ucp_atomic_fetch_nb(mca_spml_self->ucp_peers[pe].ucp_conn,
|
||||
UCP_ATOMIC_FETCH_OP_SWAP, val, prev, nlong,
|
||||
rva, ucx_mkey->rkey, mca_atomic_ucx_complete_cb);
|
||||
UCP_ATOMIC_FETCH_OP_SWAP, val, prev, nlong,
|
||||
rva, ucx_mkey->rkey, mca_atomic_ucx_complete_cb);
|
||||
status = mca_atomic_ucx_wait_request(status_ptr);
|
||||
}
|
||||
else {
|
||||
switch (nlong) {
|
||||
case 4:
|
||||
status = ucp_atomic_cswap32(mca_spml_self->ucp_peers[pe].ucp_conn,
|
||||
*(uint32_t *)cond, *(uint32_t *)value, rva, ucx_mkey->rkey, prev);
|
||||
break;
|
||||
case 8:
|
||||
status = ucp_atomic_cswap64(mca_spml_self->ucp_peers[pe].ucp_conn,
|
||||
*(uint64_t *)cond, *(uint64_t *)value, rva, ucx_mkey->rkey, prev);
|
||||
break;
|
||||
default:
|
||||
assert(0); /* should not be here */
|
||||
status = UCS_ERR_INVALID_PARAM;
|
||||
break;
|
||||
if (8 == nlong) {
|
||||
cmp = *(uint64_t*)cond;
|
||||
} else {
|
||||
cmp = *(uint32_t*)cond;
|
||||
}
|
||||
status_ptr = ucp_atomic_fetch_nb(mca_spml_self->ucp_peers[pe].ucp_conn,
|
||||
UCP_ATOMIC_FETCH_OP_CSWAP, cmp, &val, nlong,
|
||||
rva, ucx_mkey->rkey, mca_atomic_ucx_complete_cb);
|
||||
status = mca_atomic_ucx_wait_request(status_ptr);
|
||||
if (UCS_OK == status) {
|
||||
assert(NULL != prev);
|
||||
if (8 == nlong) {
|
||||
*(uint64_t*)prev = val;
|
||||
} else {
|
||||
*(uint32_t*)prev = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ucx_status_to_oshmem(status);
|
||||
}
|
||||
|
||||
|
@ -31,22 +31,25 @@ int mca_atomic_ucx_fadd(void *target,
|
||||
uint64_t rva;
|
||||
uint64_t val;
|
||||
|
||||
if ((8 != nlong) && (4 != nlong)) {
|
||||
if (8 == nlong) {
|
||||
val = *(uint64_t*)value;
|
||||
} else if (4 == nlong) {
|
||||
val = *(uint32_t*)value;
|
||||
} else {
|
||||
ATOMIC_ERROR("[#%d] Type size must be 4 or 8 bytes.", my_pe);
|
||||
return OSHMEM_ERROR;
|
||||
}
|
||||
|
||||
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva);
|
||||
val = (8 == nlong) ? *(uint64_t*)value : *(uint32_t*)value;
|
||||
|
||||
if (NULL == prev) {
|
||||
status = ucp_atomic_post(mca_spml_self->ucp_peers[pe].ucp_conn,
|
||||
UCP_ATOMIC_POST_OP_ADD, val, nlong, rva, ucx_mkey->rkey);
|
||||
UCP_ATOMIC_POST_OP_ADD, val, nlong, rva,
|
||||
ucx_mkey->rkey);
|
||||
}
|
||||
else {
|
||||
status_ptr = ucp_atomic_fetch_nb(mca_spml_self->ucp_peers[pe].ucp_conn,
|
||||
UCP_ATOMIC_FETCH_OP_FADD, val, prev, nlong,
|
||||
rva, ucx_mkey->rkey, mca_atomic_ucx_complete_cb);
|
||||
UCP_ATOMIC_FETCH_OP_FADD, val, prev, nlong,
|
||||
rva, ucx_mkey->rkey, mca_atomic_ucx_complete_cb);
|
||||
status = mca_atomic_ucx_wait_request(status_ptr);
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user