2011-12-09 21:24:07 +00:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
|
|
|
/*
|
2012-01-27 00:32:43 +00:00
|
|
|
* Copyright (c) 2011-2012 Los Alamos National Security, LLC. All rights
|
2011-12-09 21:24:07 +00: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 00:47:29 +00:00
|
|
|
#include "btl_ugni_smsg.h"
|
2011-12-09 21:24:07 +00:00
|
|
|
|
|
|
|
int mca_btl_ugni_send (struct mca_btl_base_module_t *btl,
|
2012-05-31 20:02:41 +00:00
|
|
|
struct mca_btl_base_endpoint_t *endpoint,
|
2011-12-09 21:24:07 +00: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 17:09:12 +00:00
|
|
|
size_t size = frag->segments[0].base.seg_len + frag->segments[1].base.seg_len;
|
2012-05-31 20:02:41 +00:00
|
|
|
mca_btl_ugni_module_t *ugni_module = (mca_btl_ugni_module_t *) btl;
|
2012-04-24 20:18:35 +00:00
|
|
|
int flags_save = frag->base.des_flags;
|
2011-12-09 21:24:07 +00:00
|
|
|
int rc;
|
|
|
|
|
2012-06-21 17:09:12 +00:00
|
|
|
BTL_VERBOSE(("btl/ugni sending descriptor %p from %d -> %d. length = %" PRIu64, (void *)descriptor,
|
|
|
|
ORTE_PROC_MY_NAME->vpid, endpoint->common->ep_rem_id, frag->segments[0].base.seg_len));
|
2011-12-09 21:24:07 +00:00
|
|
|
|
2012-02-10 00:47:29 +00:00
|
|
|
/* tag and len are at the same location in eager and smsg frag hdrs */
|
2012-04-19 21:51:55 +00:00
|
|
|
frag->hdr.send.lag = (tag << 24) | size;
|
2012-05-31 20:02:41 +00:00
|
|
|
frag->endpoint = endpoint;
|
2012-02-10 00:47:29 +00:00
|
|
|
|
2012-05-31 20:02:41 +00:00
|
|
|
rc = mca_btl_ugni_check_endpoint_state (endpoint);
|
2011-12-09 21:24:07 +00:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
|
2012-04-24 20:18:35 +00:00
|
|
|
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
|
2012-05-31 20:02:41 +00:00
|
|
|
opal_list_append (&endpoint->frag_wait_list, (opal_list_item_t *) frag);
|
2011-12-09 21:24:07 +00:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-04-24 20:18:35 +00: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 17:23:06 +00:00
|
|
|
frag->flags &= ~MCA_BTL_UGNI_FRAG_COMPLETE;
|
2012-04-24 20:18:35 +00:00
|
|
|
|
2012-05-31 20:02:41 +00: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);
|
|
|
|
|
|
|
|
return 1;
|
2011-12-09 21:24:07 +00:00
|
|
|
}
|
2012-04-19 21:51:55 +00:00
|
|
|
|
2012-05-31 20:02:41 +00: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-24 20:18:35 +00:00
|
|
|
|
2012-05-31 20:02:41 +00: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 17:23:06 +00:00
|
|
|
}
|
2012-04-24 20:18:35 +00:00
|
|
|
|
2012-05-31 20:02:41 +00:00
|
|
|
return 1;
|
2012-04-23 21:11:57 +00:00
|
|
|
}
|
2012-04-19 21:51:55 +00:00
|
|
|
|
2012-04-24 20:18:35 +00:00
|
|
|
/* slow(ish) path: remote side hasn't received the frag. call the frag's callback when
|
2012-05-07 17:23:06 +00:00
|
|
|
we get the local smsg/msgq or remote rdma completion */
|
2012-04-24 20:18:35 +00:00
|
|
|
frag->base.des_flags = flags_save | MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
|
|
|
|
|
2012-05-31 20:02:41 +00:00
|
|
|
if (OPAL_UNLIKELY(OMPI_ERR_OUT_OF_RESOURCE == rc)) {
|
|
|
|
/* queue up request */
|
2012-06-21 17:09:12 +00:00
|
|
|
if (false == endpoint->wait_listed) {
|
2012-05-31 20:02:41 +00:00
|
|
|
opal_list_append (&ugni_module->ep_wait_list, &endpoint->super);
|
2012-06-21 17:09:12 +00:00
|
|
|
endpoint->wait_listed = true;
|
2012-05-31 20:02:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
opal_list_append (&endpoint->frag_wait_list, (opal_list_item_t *) frag);
|
|
|
|
rc = OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-19 21:51:55 +00:00
|
|
|
return OMPI_SUCCESS;
|
2011-12-09 21:24:07 +00:00
|
|
|
}
|