2011-12-10 01:24:07 +04:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
|
|
|
/*
|
2014-01-22 00:53:35 +04:00
|
|
|
* Copyright (c) 2011-2014 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.h"
|
|
|
|
#include "btl_ugni_frag.h"
|
2012-02-10 04:47:29 +04:00
|
|
|
#include "btl_ugni_smsg.h"
|
2014-01-22 00:53:35 +04:00
|
|
|
#include "btl_ugni_prepare.h"
|
2011-12-10 01:24:07 +04:00
|
|
|
|
|
|
|
int mca_btl_ugni_send (struct mca_btl_base_module_t *btl,
|
2012-06-01 00:02:41 +04:00
|
|
|
struct mca_btl_base_endpoint_t *endpoint,
|
2011-12-10 01:24:07 +04:00
|
|
|
struct mca_btl_base_descriptor_t *descriptor,
|
|
|
|
mca_btl_base_tag_t tag)
|
|
|
|
{
|
|
|
|
mca_btl_ugni_base_frag_t *frag = (mca_btl_ugni_base_frag_t *) descriptor;
|
2012-06-21 21:09:12 +04:00
|
|
|
size_t size = frag->segments[0].base.seg_len + frag->segments[1].base.seg_len;
|
2012-06-01 00:02:41 +04:00
|
|
|
mca_btl_ugni_module_t *ugni_module = (mca_btl_ugni_module_t *) btl;
|
2012-04-25 00:18:35 +04:00
|
|
|
int flags_save = frag->base.des_flags;
|
2011-12-10 01:24:07 +04:00
|
|
|
int rc;
|
|
|
|
|
2012-02-10 04:47:29 +04:00
|
|
|
/* tag and len are at the same location in eager and smsg frag hdrs */
|
2012-04-20 01:51:55 +04:00
|
|
|
frag->hdr.send.lag = (tag << 24) | size;
|
2012-02-10 04:47:29 +04:00
|
|
|
|
2012-06-01 00:02:41 +04:00
|
|
|
rc = mca_btl_ugni_check_endpoint_state (endpoint);
|
2011-12-10 01:24:07 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
|
2012-04-25 00:18:35 +04:00
|
|
|
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
|
2012-06-01 00:02:41 +04:00
|
|
|
opal_list_append (&endpoint->frag_wait_list, (opal_list_item_t *) frag);
|
2011-12-10 01:24:07 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-11-18 08:58:37 +04:00
|
|
|
BTL_VERBOSE(("btl/ugni sending descriptor %p from %d -> %d. length = %" PRIu64, (void *)descriptor,
|
|
|
|
OMPI_PROC_MY_NAME->vpid, endpoint->common->ep_rem_id, frag->segments[0].base.seg_len));
|
|
|
|
|
2012-04-25 00:18:35 +04:00
|
|
|
/* temporarily disable ownership and callback flags so we can reliably check the complete flag */
|
|
|
|
frag->base.des_flags &= ~(MCA_BTL_DES_FLAGS_BTL_OWNERSHIP | MCA_BTL_DES_SEND_ALWAYS_CALLBACK);
|
2012-05-07 21:23:06 +04:00
|
|
|
frag->flags &= ~MCA_BTL_UGNI_FRAG_COMPLETE;
|
2012-04-25 00:18:35 +04:00
|
|
|
|
2012-06-01 00:02:41 +04:00
|
|
|
rc = mca_btl_ugni_send_frag (endpoint, frag);
|
|
|
|
|
|
|
|
if (OPAL_LIKELY(frag->flags & MCA_BTL_UGNI_FRAG_COMPLETE)) {
|
|
|
|
/* fast path: remote side has received the frag */
|
|
|
|
frag->base.des_flags = flags_save;
|
|
|
|
mca_btl_ugni_frag_complete (frag, OMPI_SUCCESS);
|
2012-06-29 19:43:29 +04:00
|
|
|
|
2012-06-01 00:02:41 +04:00
|
|
|
return 1;
|
2011-12-10 01:24:07 +04:00
|
|
|
}
|
2012-04-20 01:51:55 +04:00
|
|
|
|
2012-06-01 00:02:41 +04:00
|
|
|
if ((OMPI_SUCCESS == rc) && (frag->flags & MCA_BTL_UGNI_FRAG_BUFFERED) && (flags_save & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP)) {
|
|
|
|
/* fast(ish) path: btl owned buffered frag. report send as complete */
|
|
|
|
frag->base.des_flags = flags_save & ~MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
|
2012-04-25 00:18:35 +04:00
|
|
|
|
2012-06-01 00:02:41 +04:00
|
|
|
if (OPAL_LIKELY(flags_save & MCA_BTL_DES_SEND_ALWAYS_CALLBACK)) {
|
|
|
|
frag->base.des_cbfunc(&frag->endpoint->btl->super, frag->endpoint, &frag->base, rc);
|
2012-05-07 21:23:06 +04:00
|
|
|
}
|
2012-04-25 00:18:35 +04:00
|
|
|
|
2012-06-01 00:02:41 +04:00
|
|
|
return 1;
|
2012-04-24 01:11:57 +04:00
|
|
|
}
|
2012-04-20 01:51:55 +04:00
|
|
|
|
2012-04-25 00:18:35 +04:00
|
|
|
/* slow(ish) path: remote side hasn't received the frag. call the frag's callback when
|
2012-05-07 21:23:06 +04:00
|
|
|
we get the local smsg/msgq or remote rdma completion */
|
2012-04-25 00:18:35 +04:00
|
|
|
frag->base.des_flags = flags_save | MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
|
|
|
|
|
2012-06-01 00:02:41 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_ERR_OUT_OF_RESOURCE == rc)) {
|
|
|
|
/* queue up request */
|
2012-06-21 21:09:12 +04:00
|
|
|
if (false == endpoint->wait_listed) {
|
2012-06-01 00:02:41 +04:00
|
|
|
opal_list_append (&ugni_module->ep_wait_list, &endpoint->super);
|
2012-06-21 21:09:12 +04:00
|
|
|
endpoint->wait_listed = true;
|
2012-06-01 00:02:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
opal_list_append (&endpoint->frag_wait_list, (opal_list_item_t *) frag);
|
|
|
|
rc = OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-01-22 00:53:35 +04:00
|
|
|
int
|
|
|
|
mca_btl_ugni_sendi (struct mca_btl_base_module_t *btl,
|
|
|
|
struct mca_btl_base_endpoint_t *endpoint,
|
|
|
|
struct opal_convertor_t *convertor,
|
|
|
|
void *header, size_t header_size,
|
|
|
|
size_t payload_size, uint8_t order,
|
|
|
|
uint32_t flags, mca_btl_base_tag_t tag,
|
|
|
|
mca_btl_base_descriptor_t **descriptor)
|
|
|
|
{
|
|
|
|
size_t total_size = header_size + payload_size;
|
|
|
|
mca_btl_ugni_base_frag_t *frag = NULL;
|
|
|
|
size_t packed_size = payload_size;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != mca_btl_ugni_check_endpoint_state (endpoint))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-04-24 22:50:29 +04:00
|
|
|
flags |= MCA_BTL_DES_FLAGS_BTL_OWNERSHIP;
|
|
|
|
|
|
|
|
if (0 == payload_size) {
|
|
|
|
frag = (mca_btl_ugni_base_frag_t *) mca_btl_ugni_prepare_src_send_nodata (btl, endpoint, order, header_size,
|
|
|
|
flags);
|
|
|
|
} else {
|
|
|
|
frag = (mca_btl_ugni_base_frag_t *) mca_btl_ugni_prepare_src_send_buffered (btl, endpoint, convertor, order,
|
|
|
|
header_size, &packed_size, flags);
|
|
|
|
}
|
2014-01-22 20:32:07 +04:00
|
|
|
assert (packed_size == payload_size);
|
|
|
|
if (OPAL_UNLIKELY(NULL == frag)) {
|
2014-01-22 00:53:35 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
frag->hdr.send.lag = (tag << 24) | total_size;
|
|
|
|
memcpy (frag->segments[0].base.seg_addr.pval, header, header_size);
|
|
|
|
|
|
|
|
rc = mca_btl_ugni_send_frag (endpoint, frag);
|
2014-02-21 21:46:22 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
|
2014-01-22 20:32:07 +04:00
|
|
|
mca_btl_ugni_frag_return (frag);
|
2014-01-22 00:53:35 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
*descriptor = NULL;
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
2012-06-01 00:02:41 +04:00
|
|
|
int mca_btl_progress_send_wait_list (mca_btl_base_endpoint_t *endpoint)
|
|
|
|
{
|
|
|
|
mca_btl_ugni_base_frag_t *frag;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
while (NULL !=
|
|
|
|
(frag = (mca_btl_ugni_base_frag_t *) opal_list_remove_first (&endpoint->frag_wait_list))) {
|
|
|
|
rc = mca_btl_ugni_send_frag (endpoint, frag);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS > rc)) {
|
|
|
|
if (OPAL_LIKELY(OMPI_ERR_OUT_OF_RESOURCE == rc)) {
|
|
|
|
opal_list_prepend (&endpoint->frag_wait_list, (opal_list_item_t *) frag);
|
|
|
|
} else {
|
|
|
|
mca_btl_ugni_frag_complete (frag, rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
return OMPI_SUCCESS;
|
2011-12-10 01:24:07 +04:00
|
|
|
}
|