1
1

ATOMIC/UCX: minor optimization and code cleaning

Signed-off-by: Sergey Oblomov <sergeyo@mellanox.com>
Этот коммит содержится в:
Sergey Oblomov 2018-06-27 12:33:31 +03:00
родитель eb0abfcf92
Коммит a0ea368464
2 изменённых файлов: 19 добавлений и 35 удалений

Просмотреть файл

@ -92,34 +92,6 @@ int mca_atomic_basic_finalize(void)
return OSHMEM_SUCCESS;
}
static inline
int mca_atomic_basic_op(void *target,
const void *value,
size_t size,
int pe,
struct oshmem_op_t *op)
{
int rc = OSHMEM_SUCCESS;
long long temp_value = 0;
atomic_basic_lock(pe);
rc = MCA_SPML_CALL(get(target, size, (void*)&temp_value, pe));
op->o_func.c_fn((void*) value,
(void*) &temp_value,
size / op->dt_size);
if (rc == OSHMEM_SUCCESS) {
rc = MCA_SPML_CALL(put(target, size, (void*)&temp_value, pe));
shmem_quiet();
}
atomic_basic_unlock(pe);
return rc;
}
static inline
int mca_atomic_basic_fop(void *target,
void *prev,
@ -151,6 +123,18 @@ int mca_atomic_basic_fop(void *target,
return rc;
}
static inline
int mca_atomic_basic_op(void *target,
const void *value,
size_t size,
int pe,
struct oshmem_op_t *op)
{
long long prev;
return mca_atomic_basic_fop(target, &prev, value, size, pe, op);
}
static int mca_atomic_basic_add(void *target, const void *value,
size_t size, int pe)
{

Просмотреть файл

@ -36,8 +36,8 @@ int mca_atomic_ucx_cswap_inner(void *target,
uint64_t val;
uint64_t cmp;
val = (4 == size) ? *(uint32_t*)value : *(uint64_t*)value;
cmp = (4 == size) ? *(uint32_t*)cond : *(uint64_t*)cond;
val = (sizeof(uint32_t) == size) ? *(uint32_t*)value : *(uint64_t*)value;
cmp = (sizeof(uint32_t) == size) ? *(uint32_t*)cond : *(uint64_t*)cond;
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva);
status_ptr = ucp_atomic_fetch_nb(mca_spml_self->ucp_peers[pe].ucp_conn,
UCP_ATOMIC_FETCH_OP_CSWAP, cmp, &val, size,
@ -47,7 +47,7 @@ int mca_atomic_ucx_cswap_inner(void *target,
if (UCS_OK == status) {
assert(NULL != prev);
memcpy(prev, &val, size);
if (4 == size) {
if (sizeof(uint32_t) == size) {
*(uint32_t*)prev = val;
} else {
*(uint64_t*)prev = val;
@ -63,10 +63,10 @@ int mca_atomic_ucx_cswap(void *target,
size_t size,
int pe)
{
if (8 == size) {
return mca_atomic_ucx_cswap_inner(target, prev, cond, value, 8, pe);
} else if (4 == size) {
return mca_atomic_ucx_cswap_inner(target, prev, cond, value, 4, pe);
if (sizeof(uint64_t) == size) {
return mca_atomic_ucx_cswap_inner(target, prev, cond, value, sizeof(uint64_t), pe);
} else if (sizeof(uint32_t) == size) {
return mca_atomic_ucx_cswap_inner(target, prev, cond, value, sizeof(uint32_t), pe);
} else {
ATOMIC_ERROR("[#%d] Type size must be 4 or 8 bytes.", my_pe);
return OSHMEM_ERROR;