Skip to content

ikrit spml cleanup, mkey cache and assorted bug fixes #2354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 68 additions & 7 deletions oshmem/mca/atomic/mxm/atomic_mxm.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

/* This component does uses SPML:IKRIT */
#include "oshmem/mca/spml/ikrit/spml_ikrit.h"
#include "oshmem/runtime/runtime.h"


BEGIN_C_DECLS
Expand Down Expand Up @@ -60,16 +61,76 @@ struct mca_atomic_mxm_module_t {
typedef struct mca_atomic_mxm_module_t mca_atomic_mxm_module_t;
OBJ_CLASS_DECLARATION(mca_atomic_mxm_module_t);

END_C_DECLS

#if MXM_API >= MXM_VERSION(2,0)
static inline mxm_mem_key_t *to_mxm_mkey(sshmem_mkey_t *mkey) {
static inline uint8_t mca_atomic_mxm_order(size_t nlong)
{
if (OPAL_LIKELY(8 == nlong)) {
return 3;
}

if (OPAL_LIKELY(4 == nlong)) {
return 2;
}

if (2 == nlong) {
return 1;
}

if (0 == mkey->len) {
return &mxm_empty_mem_key;
if (1 == nlong) {
return 0;
}
return (mxm_mem_key_t *)mkey->u.data;

ATOMIC_ERROR("Type size must be 1/2/4 or 8 bytes.");
oshmem_shmem_abort(-1);
return OSHMEM_ERR_BAD_PARAM;
}
#endif

static inline void mca_atomic_mxm_req_init(mxm_send_req_t *sreq, int pe, void *target, size_t nlong)
{
uint8_t nlong_order;
void *remote_addr;
mxm_mem_key_t *mkey;

nlong_order = mca_atomic_mxm_order(nlong);

mkey = mca_spml_ikrit_get_mkey(pe, target, MXM_PTL_RDMA, &remote_addr);

/* mxm request init */
sreq->base.state = MXM_REQ_NEW;
sreq->base.mq = mca_atomic_mxm_spml_self->mxm_mq;
sreq->base.conn = mca_atomic_mxm_spml_self->mxm_peers[pe].mxm_hw_rdma_conn;
sreq->base.completed_cb = NULL;
sreq->base.data_type = MXM_REQ_DATA_BUFFER;

sreq->base.data.buffer.memh = MXM_INVALID_MEM_HANDLE;
sreq->base.data.buffer.length = nlong;

sreq->op.atomic.remote_vaddr = (uintptr_t) remote_addr;
sreq->op.atomic.remote_mkey = mkey;
sreq->op.atomic.order = nlong_order;

sreq->flags = 0;
}

static inline void mca_atomic_mxm_post(mxm_send_req_t *sreq)
{
mxm_error_t mxm_err;

mxm_err = mxm_req_send(sreq);
if (OPAL_UNLIKELY(MXM_OK != mxm_err)) {
ATOMIC_ERROR("mxm_req_send failed, mxm_error = %d",
mxm_err);
oshmem_shmem_abort(-1);
}

mxm_req_wait(&sreq->base);
if (OPAL_UNLIKELY(MXM_OK != sreq->base.error)) {
ATOMIC_ERROR("mxm_req_wait got non MXM_OK error: %d",
sreq->base.error);
oshmem_shmem_abort(-1);
}
}

END_C_DECLS

#endif /* MCA_ATOMIC_MXM_H */
80 changes: 2 additions & 78 deletions oshmem/mca/atomic/mxm/atomic_mxm_cswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,96 +31,20 @@ int mca_atomic_mxm_cswap(void *target,
size_t nlong,
int pe)
{
unsigned my_pe;
uint8_t nlong_order;
void *remote_addr;
int ptl_id;
mxm_send_req_t sreq;
mxm_error_t mxm_err;
sshmem_mkey_t *r_mkey;

my_pe = oshmem_my_proc_id();
ptl_id = -1;
mxm_err = MXM_OK;
mca_atomic_mxm_req_init(&sreq, pe, target, nlong);

switch (nlong) {
case 1:
nlong_order = 0;
break;
case 2:
nlong_order = 1;
break;
case 4:
nlong_order = 2;
break;
case 8:
nlong_order = 3;
break;
default:
ATOMIC_ERROR("[#%d] Type size must be 1/2/4 or 8 bytes.", my_pe);
oshmem_shmem_abort(-1);
return OSHMEM_ERR_BAD_PARAM;
}

ptl_id = OSHMEM_PROC_DATA(oshmem_proc_group_all(pe))->transport_ids[0];
if (MXM_PTL_SHM == ptl_id) {
ptl_id = MXM_PTL_RDMA;
}
r_mkey = mca_memheap_base_get_cached_mkey(pe, target, ptl_id, &remote_addr);
if (!r_mkey) {
ATOMIC_ERROR("[#%d] %p is not address of symmetric variable",
my_pe, target);
oshmem_shmem_abort(-1);
return OSHMEM_ERR_BAD_PARAM;
}

/* mxm request init */
sreq.base.state = MXM_REQ_NEW;
sreq.base.mq = mca_atomic_mxm_spml_self->mxm_mq;
sreq.base.conn = mca_atomic_mxm_spml_self->mxm_peers[pe]->mxm_hw_rdma_conn;
sreq.base.completed_cb = NULL;
sreq.base.data_type = MXM_REQ_DATA_BUFFER;

/* set data */
sreq.base.data.buffer.ptr = (void *) value;
sreq.base.data.buffer.length = nlong;
sreq.base.data.buffer.memh = MXM_INVALID_MEM_HANDLE;

sreq.op.atomic.remote_vaddr = (uintptr_t) remote_addr;
#if MXM_API < MXM_VERSION(2,0)
sreq.base.flags = 0;
sreq.op.atomic.remote_memh = MXM_INVALID_MEM_HANDLE;
#else
sreq.flags = 0;
sreq.op.atomic.remote_mkey = to_mxm_mkey(r_mkey);
#endif
sreq.op.atomic.order = nlong_order;

if (NULL == cond) {
sreq.opcode = MXM_REQ_OP_ATOMIC_SWAP;
} else {
#if MXM_API < MXM_VERSION(2,0)
memcpy(&sreq.op.atomic.value8, cond, nlong);
#else
memcpy(&sreq.op.atomic.value, cond, nlong);
#endif
sreq.opcode = MXM_REQ_OP_ATOMIC_CSWAP;
}

if (MXM_OK != (mxm_err = mxm_req_send(&sreq))) {
ATOMIC_ERROR("[#%d] mxm_req_send failed, mxm_error = %d",
my_pe, mxm_err);
oshmem_shmem_abort(-1);
return OSHMEM_ERROR;
}
mca_atomic_mxm_post(&sreq);

mxm_req_wait(&sreq.base);
if (MXM_OK != sreq.base.error) {
ATOMIC_ERROR("[#%d] mxm_req_wait got non MXM_OK error: %d",
my_pe, sreq.base.error);
oshmem_shmem_abort(-1);
return OSHMEM_ERROR;
}
memcpy(prev, value, nlong);

return OSHMEM_SUCCESS;
Expand Down
92 changes: 3 additions & 89 deletions oshmem/mca/atomic/mxm/atomic_mxm_fadd.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,106 +32,20 @@ int mca_atomic_mxm_fadd(void *target,
int pe,
struct oshmem_op_t *op)
{
unsigned my_pe;
uint8_t nlong_order;
void *remote_addr;
int ptl_id;
mxm_send_req_t sreq;
mxm_error_t mxm_err;
sshmem_mkey_t *r_mkey;
static char dummy_buf[8];

my_pe = oshmem_my_proc_id();
ptl_id = -1;
mxm_err = MXM_OK;
mca_atomic_mxm_req_init(&sreq, pe, target, nlong);

switch (nlong) {
case 1:
nlong_order = 0;
break;
case 2:
nlong_order = 1;
break;
case 4:
nlong_order = 2;
break;
case 8:
nlong_order = 3;
break;
default:
ATOMIC_ERROR("[#%d] Type size must be 1/2/4 or 8 bytes.", my_pe);
oshmem_shmem_abort(-1);
return OSHMEM_ERR_BAD_PARAM;
}

ptl_id = OSHMEM_PROC_DATA(oshmem_proc_group_all(pe))->transport_ids[0];
if (MXM_PTL_SHM == ptl_id) {
ptl_id = MXM_PTL_RDMA;
}
r_mkey = mca_memheap_base_get_cached_mkey(pe, target, ptl_id, &remote_addr);
if (!r_mkey) {
ATOMIC_ERROR("[#%d] %p is not address of symmetric variable",
my_pe, target);
oshmem_shmem_abort(-1);
return OSHMEM_ERR_BAD_PARAM;
}

/* mxm request init */
sreq.base.state = MXM_REQ_NEW;
sreq.base.mq = mca_atomic_mxm_spml_self->mxm_mq;
sreq.base.conn = mca_atomic_mxm_spml_self->mxm_peers[pe]->mxm_hw_rdma_conn;
sreq.base.completed_cb = NULL;
sreq.base.data_type = MXM_REQ_DATA_BUFFER;

sreq.op.atomic.remote_vaddr = (uintptr_t) remote_addr;
#if MXM_API < MXM_VERSION(2,0)
sreq.op.atomic.remote_memh = MXM_INVALID_MEM_HANDLE;
memcpy(&sreq.op.atomic.value8, value, nlong);
#else
sreq.op.atomic.remote_mkey = to_mxm_mkey(r_mkey);
memcpy(&sreq.op.atomic.value, value, nlong);
#endif
sreq.op.atomic.order = nlong_order;

/* Do we need atomic 'add' or atomic 'fetch and add'? */
sreq.opcode = MXM_REQ_OP_ATOMIC_FADD;
if (NULL == prev) {
sreq.base.data.buffer.ptr = dummy_buf;
sreq.base.data.buffer.length = nlong;
sreq.base.data.buffer.memh = MXM_INVALID_MEM_HANDLE;
#if MXM_API < MXM_VERSION(2,0)
sreq.base.flags = MXM_REQ_FLAG_SEND_SYNC;
sreq.opcode = MXM_REQ_OP_ATOMIC_ADD;
#else
sreq.flags = 0;
sreq.opcode = MXM_REQ_OP_ATOMIC_FADD;
#endif
} else {
sreq.base.data.buffer.ptr = prev;
sreq.base.data.buffer.length = nlong;
sreq.base.data.buffer.memh = MXM_INVALID_MEM_HANDLE;
#if MXM_API < MXM_VERSION(2,0)
sreq.base.flags = 0;
#else
sreq.flags = 0;
#endif

sreq.opcode = MXM_REQ_OP_ATOMIC_FADD;
}

if (MXM_OK != (mxm_err = mxm_req_send(&sreq))) {
ATOMIC_ERROR("[#%d] mxm_req_send failed, mxm_error = %d",
my_pe, mxm_err);
oshmem_shmem_abort(-1);
return OSHMEM_ERROR;
}

mxm_req_wait(&sreq.base);
if (MXM_OK != sreq.base.error) {
ATOMIC_ERROR("[#%d] mxm_req_wait got non MXM_OK error: %d",
my_pe, sreq.base.error);
oshmem_shmem_abort(-1);
return OSHMEM_ERROR;
}
mca_atomic_mxm_post(&sreq);

return OSHMEM_SUCCESS;
}
Loading