2011-12-10 01:24:07 +04:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
|
|
|
/*
|
2012-02-10 04:47:29 +04:00
|
|
|
* Copyright (c) 2011-2012 Los Alamos National Security, LLC. All rights
|
2011-12-10 01:24:07 +04:00
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2011 UT-Battelle, LLC. All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "btl_ugni_rdma.h"
|
2012-02-10 04:47:29 +04:00
|
|
|
#include "btl_ugni_smsg.h"
|
|
|
|
|
2011-12-10 01:24:07 +04:00
|
|
|
/**
|
|
|
|
* Initiate a get operation.
|
|
|
|
*
|
|
|
|
* @param btl (IN) BTL module
|
|
|
|
* @param endpoint (IN) BTL addressing information
|
|
|
|
* @param descriptor (IN) Description of the data to be transferred
|
|
|
|
*/
|
|
|
|
int mca_btl_ugni_get (struct mca_btl_base_module_t *btl,
|
|
|
|
struct mca_btl_base_endpoint_t *endpoint,
|
|
|
|
struct mca_btl_base_descriptor_t *des) {
|
|
|
|
mca_btl_ugni_base_frag_t *frag = (mca_btl_ugni_base_frag_t *) des;
|
2012-06-21 21:09:12 +04:00
|
|
|
mca_btl_ugni_segment_t *src_seg = (mca_btl_ugni_segment_t *) des->des_src;
|
|
|
|
mca_btl_ugni_segment_t *dst_seg = (mca_btl_ugni_segment_t *) des->des_dst;
|
|
|
|
size_t size = src_seg->base.seg_len - src_seg->extra_byte_count;
|
2012-02-10 04:47:29 +04:00
|
|
|
bool check;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-02-10 04:47:29 +04:00
|
|
|
BTL_VERBOSE(("Using RDMA/FMA Get"));
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-06-01 00:02:41 +04:00
|
|
|
/* cause endpoint to bind if it isn't already (bind is sufficient for rdma) */
|
|
|
|
(void) mca_btl_ugni_check_endpoint_state(endpoint);
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-02-10 04:47:29 +04:00
|
|
|
/* Check if the get is aligned/sized on a multiple of 4 */
|
|
|
|
check = !!((des->des_src->seg_addr.lval | des->des_dst->seg_addr.lval | size) & 3);
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-02-10 04:47:29 +04:00
|
|
|
if (OPAL_UNLIKELY(check || size > mca_btl_ugni_component.ugni_get_limit)) {
|
2011-12-10 01:24:07 +04:00
|
|
|
/* switch to put */
|
2012-04-25 00:18:56 +04:00
|
|
|
return OMPI_ERR_NOT_AVAILABLE;
|
2012-04-20 01:51:55 +04:00
|
|
|
}
|
|
|
|
|
2012-06-21 21:09:12 +04:00
|
|
|
if (src_seg->extra_byte_count) {
|
2012-06-29 19:43:29 +04:00
|
|
|
memmove ((char *) dst_seg->base.seg_addr.pval + size, src_seg->extra_bytes, src_seg->extra_byte_count);
|
2012-06-21 21:09:12 +04:00
|
|
|
src_seg->base.seg_len = size;
|
|
|
|
dst_seg->base.seg_len = size;
|
|
|
|
}
|
|
|
|
|
2012-06-01 00:02:41 +04:00
|
|
|
des->des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-06-21 21:09:12 +04:00
|
|
|
return mca_btl_ugni_post (frag, true, dst_seg, src_seg);
|
2012-06-01 00:02:41 +04:00
|
|
|
}
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-04-25 00:18:56 +04:00
|
|
|
static void mca_btl_ugni_callback_rdma_complete (mca_btl_ugni_base_frag_t *frag, int rc)
|
2012-04-20 01:51:55 +04:00
|
|
|
{
|
|
|
|
BTL_VERBOSE(("rdma operation for rem_ctx %p complete", frag->hdr.rdma.ctx));
|
|
|
|
|
2012-06-29 19:43:29 +04:00
|
|
|
/* tell peer the get is complete */
|
2012-06-01 00:02:41 +04:00
|
|
|
rc = ompi_mca_btl_ugni_smsg_send (frag, &frag->hdr.rdma, sizeof (frag->hdr.rdma),
|
2012-04-20 01:51:55 +04:00
|
|
|
NULL, 0, MCA_BTL_UGNI_TAG_RDMA_COMPLETE);
|
|
|
|
if (OPAL_UNLIKELY(0 > rc)) {
|
|
|
|
/* call this callback again later */
|
|
|
|
frag->cbfunc = mca_btl_ugni_callback_rdma_complete;
|
|
|
|
opal_list_append (&frag->endpoint->btl->failed_frags, (opal_list_item_t *) frag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* eager get */
|
|
|
|
static void mca_btl_ugni_callback_eager_get_retry (mca_btl_ugni_base_frag_t *frag, int rc)
|
|
|
|
{
|
|
|
|
(void) mca_btl_ugni_start_eager_get(frag->endpoint, frag->hdr.eager_ex, frag);
|
|
|
|
}
|
|
|
|
|
2012-06-29 19:43:29 +04:00
|
|
|
static void mca_btl_ugni_callback_eager_get (mca_btl_ugni_base_frag_t *frag, int rc)
|
2012-04-20 01:51:55 +04:00
|
|
|
{
|
|
|
|
uint32_t len = frag->hdr.eager.send.lag & 0x00ffffff;
|
|
|
|
uint8_t tag = frag->hdr.eager.send.lag >> 24;
|
2012-06-29 19:43:29 +04:00
|
|
|
size_t payload_len = frag->hdr.eager.src_seg.base.seg_len;
|
2012-04-20 01:51:55 +04:00
|
|
|
size_t hdr_len = len - payload_len;
|
|
|
|
mca_btl_active_message_callback_t *reg;
|
2012-06-21 21:09:12 +04:00
|
|
|
mca_btl_base_segment_t segs[2];
|
2012-04-20 01:51:55 +04:00
|
|
|
mca_btl_ugni_base_frag_t tmp;
|
|
|
|
|
|
|
|
BTL_VERBOSE(("eager get for rem_ctx %p complete", frag->hdr.eager.ctx));
|
|
|
|
|
2012-06-21 21:09:12 +04:00
|
|
|
tmp.base.des_dst = segs;
|
2012-05-07 21:23:06 +04:00
|
|
|
if (hdr_len) {
|
|
|
|
tmp.base.des_dst_cnt = 2;
|
|
|
|
|
2012-06-21 21:09:12 +04:00
|
|
|
segs[0].seg_addr.pval = frag->hdr.eager_ex.pml_header;
|
|
|
|
segs[0].seg_len = hdr_len;
|
|
|
|
segs[1].seg_addr.pval = frag->segments[0].base.seg_addr.pval;
|
|
|
|
segs[1].seg_len = payload_len;
|
2012-05-07 21:23:06 +04:00
|
|
|
} else {
|
|
|
|
tmp.base.des_dst_cnt = 1;
|
|
|
|
|
2012-06-21 21:09:12 +04:00
|
|
|
segs[0].seg_addr.pval = frag->segments[0].base.seg_addr.pval;
|
|
|
|
segs[0].seg_len = payload_len;
|
2012-05-07 21:23:06 +04:00
|
|
|
}
|
2012-04-20 01:51:55 +04:00
|
|
|
|
|
|
|
reg = mca_btl_base_active_message_trigger + tag;
|
|
|
|
reg->cbfunc(&frag->endpoint->btl->super, tag, &(tmp.base), reg->cbdata);
|
|
|
|
|
|
|
|
frag->hdr.rdma.ctx = frag->hdr.eager.ctx;
|
|
|
|
|
|
|
|
/* tell the remote peer the operation is complete */
|
|
|
|
mca_btl_ugni_callback_rdma_complete (frag, rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
int mca_btl_ugni_start_eager_get (mca_btl_base_endpoint_t *ep,
|
|
|
|
mca_btl_ugni_eager_ex_frag_hdr_t hdr,
|
|
|
|
mca_btl_ugni_base_frag_t *frag)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (OPAL_UNLIKELY(frag && frag->my_list == &ep->btl->rdma_int_frags)) {
|
|
|
|
mca_btl_ugni_frag_return (frag);
|
|
|
|
frag = NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-25 18:24:48 +04:00
|
|
|
BTL_VERBOSE(("starting eager get for remote ctx: %p", hdr.eager.ctx));
|
2012-04-20 01:51:55 +04:00
|
|
|
|
|
|
|
do {
|
|
|
|
if (NULL == frag) {
|
|
|
|
rc = MCA_BTL_UGNI_FRAG_ALLOC_EAGER_RECV(ep, frag);
|
|
|
|
if (OPAL_UNLIKELY(NULL == frag)) {
|
|
|
|
(void) MCA_BTL_UGNI_FRAG_ALLOC_RDMA_INT(ep, frag);
|
|
|
|
assert (NULL != frag);
|
|
|
|
frag->hdr.eager_ex = hdr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
frag->hdr.eager_ex = hdr;
|
2012-06-29 19:43:29 +04:00
|
|
|
frag->flags = 0;
|
2012-04-20 01:51:55 +04:00
|
|
|
|
2012-06-29 19:43:29 +04:00
|
|
|
frag->base.des_flags = MCA_BTL_DES_FLAGS_BTL_OWNERSHIP;
|
2012-04-20 01:51:55 +04:00
|
|
|
|
2012-06-29 19:43:29 +04:00
|
|
|
frag->segments[1] = hdr.eager.src_seg;
|
2012-04-20 01:51:55 +04:00
|
|
|
|
|
|
|
/* increase size to a multiple of 4 bytes (required for get) */
|
2012-06-21 21:09:12 +04:00
|
|
|
frag->segments[0].base.seg_len = frag->segments[1].base.seg_len =
|
2012-06-29 19:43:29 +04:00
|
|
|
(hdr.eager.src_seg.base.seg_len + 3) & ~3;
|
2012-04-20 01:51:55 +04:00
|
|
|
|
2012-06-29 19:43:29 +04:00
|
|
|
frag->base.des_src = &frag->segments[1].base;
|
|
|
|
|
|
|
|
rc = mca_btl_ugni_post_wcb (frag, GNI_POST_RDMA_GET, frag->segments, frag->segments + 1,
|
|
|
|
mca_btl_ugni_callback_eager_get);
|
2012-06-01 00:02:41 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS == rc)) {
|
|
|
|
return OMPI_SUCCESS;
|
2012-04-20 01:51:55 +04:00
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
frag->cbfunc = mca_btl_ugni_callback_eager_get_retry;
|
|
|
|
opal_list_append (&ep->btl->failed_frags, (opal_list_item_t *) frag);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|