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;
|
spml_ucx_mkey_t *ucx_mkey;
|
||||||
uint64_t rva;
|
uint64_t rva;
|
||||||
uint64_t val;
|
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);
|
ATOMIC_ERROR("[#%d] Type size must be 4 or 8 bytes.", my_pe);
|
||||||
return OSHMEM_ERROR;
|
return OSHMEM_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva);
|
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva);
|
||||||
val = (8 == nlong) ? *(uint64_t*)value : *(uint32_t*)value;
|
|
||||||
if (NULL == cond) {
|
if (NULL == cond) {
|
||||||
status_ptr = ucp_atomic_fetch_nb(mca_spml_self->ucp_peers[pe].ucp_conn,
|
status_ptr = ucp_atomic_fetch_nb(mca_spml_self->ucp_peers[pe].ucp_conn,
|
||||||
UCP_ATOMIC_FETCH_OP_SWAP, val, prev, nlong,
|
UCP_ATOMIC_FETCH_OP_SWAP, val, prev, nlong,
|
||||||
rva, ucx_mkey->rkey, mca_atomic_ucx_complete_cb);
|
rva, ucx_mkey->rkey, mca_atomic_ucx_complete_cb);
|
||||||
status = mca_atomic_ucx_wait_request(status_ptr);
|
status = mca_atomic_ucx_wait_request(status_ptr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (nlong) {
|
if (8 == nlong) {
|
||||||
case 4:
|
cmp = *(uint64_t*)cond;
|
||||||
status = ucp_atomic_cswap32(mca_spml_self->ucp_peers[pe].ucp_conn,
|
} else {
|
||||||
*(uint32_t *)cond, *(uint32_t *)value, rva, ucx_mkey->rkey, prev);
|
cmp = *(uint32_t*)cond;
|
||||||
break;
|
}
|
||||||
case 8:
|
status_ptr = ucp_atomic_fetch_nb(mca_spml_self->ucp_peers[pe].ucp_conn,
|
||||||
status = ucp_atomic_cswap64(mca_spml_self->ucp_peers[pe].ucp_conn,
|
UCP_ATOMIC_FETCH_OP_CSWAP, cmp, &val, nlong,
|
||||||
*(uint64_t *)cond, *(uint64_t *)value, rva, ucx_mkey->rkey, prev);
|
rva, ucx_mkey->rkey, mca_atomic_ucx_complete_cb);
|
||||||
break;
|
status = mca_atomic_ucx_wait_request(status_ptr);
|
||||||
default:
|
if (UCS_OK == status) {
|
||||||
assert(0); /* should not be here */
|
assert(NULL != prev);
|
||||||
status = UCS_ERR_INVALID_PARAM;
|
if (8 == nlong) {
|
||||||
break;
|
*(uint64_t*)prev = val;
|
||||||
|
} else {
|
||||||
|
*(uint32_t*)prev = val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ucx_status_to_oshmem(status);
|
return ucx_status_to_oshmem(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,22 +31,25 @@ int mca_atomic_ucx_fadd(void *target,
|
|||||||
uint64_t rva;
|
uint64_t rva;
|
||||||
uint64_t val;
|
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);
|
ATOMIC_ERROR("[#%d] Type size must be 4 or 8 bytes.", my_pe);
|
||||||
return OSHMEM_ERROR;
|
return OSHMEM_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva);
|
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva);
|
||||||
val = (8 == nlong) ? *(uint64_t*)value : *(uint32_t*)value;
|
|
||||||
|
|
||||||
if (NULL == prev) {
|
if (NULL == prev) {
|
||||||
status = ucp_atomic_post(mca_spml_self->ucp_peers[pe].ucp_conn,
|
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 {
|
else {
|
||||||
status_ptr = ucp_atomic_fetch_nb(mca_spml_self->ucp_peers[pe].ucp_conn,
|
status_ptr = ucp_atomic_fetch_nb(mca_spml_self->ucp_peers[pe].ucp_conn,
|
||||||
UCP_ATOMIC_FETCH_OP_FADD, val, prev, nlong,
|
UCP_ATOMIC_FETCH_OP_FADD, val, prev, nlong,
|
||||||
rva, ucx_mkey->rkey, mca_atomic_ucx_complete_cb);
|
rva, ucx_mkey->rkey, mca_atomic_ucx_complete_cb);
|
||||||
status = mca_atomic_ucx_wait_request(status_ptr);
|
status = mca_atomic_ucx_wait_request(status_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user