2011-11-02 19:07:57 +04:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
2011-10-21 01:39:44 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2011 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2009 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2006-2007 Voltaire. All rights reserved.
|
|
|
|
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
|
2013-03-28 02:10:02 +04:00
|
|
|
* Copyright (c) 2010-2013 Los Alamos National Security, LLC.
|
2011-10-21 01:39:44 +04:00
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include "btl_vader.h"
|
|
|
|
#include "btl_vader_frag.h"
|
|
|
|
#include "btl_vader_fifo.h"
|
|
|
|
|
2011-10-28 00:22:46 +04:00
|
|
|
#include "btl_vader_fbox.h"
|
|
|
|
|
2011-10-21 01:39:44 +04:00
|
|
|
/**
|
|
|
|
* Initiate an inline send to the peer.
|
|
|
|
*
|
|
|
|
* @param btl (IN) BTL module
|
|
|
|
* @param peer (IN) BTL peer addressing
|
|
|
|
*/
|
|
|
|
int mca_btl_vader_sendi (struct mca_btl_base_module_t *btl,
|
2011-11-02 19:07:57 +04:00
|
|
|
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)
|
2011-10-21 01:39:44 +04:00
|
|
|
{
|
|
|
|
size_t length = (header_size + payload_size);
|
|
|
|
mca_btl_vader_frag_t *frag;
|
|
|
|
uint32_t iov_count = 1;
|
|
|
|
struct iovec iov;
|
|
|
|
size_t max_data;
|
2011-10-28 00:22:46 +04:00
|
|
|
void *data_ptr = NULL;
|
2011-10-21 01:39:44 +04:00
|
|
|
|
2013-03-28 02:10:02 +04:00
|
|
|
assert (length < mca_btl_vader.super.btl_eager_limit);
|
2011-10-21 01:39:44 +04:00
|
|
|
assert (0 == (flags & MCA_BTL_DES_SEND_ALWAYS_CALLBACK));
|
|
|
|
|
2011-10-27 02:15:42 +04:00
|
|
|
/* we won't ever return a descriptor */
|
|
|
|
*descriptor = NULL;
|
|
|
|
|
2013-03-28 02:10:02 +04:00
|
|
|
if (OPAL_LIKELY((payload_size + header_size) < mca_btl_vader_component.max_inline_send &&
|
|
|
|
!opal_convertor_need_buffers (convertor))) {
|
2011-11-02 19:07:57 +04:00
|
|
|
if (payload_size) {
|
|
|
|
opal_convertor_get_current_pointer (convertor, &data_ptr);
|
|
|
|
}
|
2011-10-28 00:22:46 +04:00
|
|
|
|
2011-11-02 19:07:57 +04:00
|
|
|
if (mca_btl_vader_fbox_sendi (endpoint, tag, header, header_size, data_ptr, payload_size)) {
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2011-10-28 00:22:46 +04:00
|
|
|
}
|
|
|
|
|
2011-10-21 01:39:44 +04:00
|
|
|
/* allocate a fragment, giving up if we can't get one */
|
2011-10-28 00:22:46 +04:00
|
|
|
frag = (mca_btl_vader_frag_t *) mca_btl_vader_alloc (btl, endpoint, order, length,
|
2011-11-02 19:07:57 +04:00
|
|
|
flags | MCA_BTL_DES_FLAGS_BTL_OWNERSHIP);
|
2011-10-21 01:39:44 +04:00
|
|
|
if (OPAL_UNLIKELY(NULL == frag)) {
|
2011-11-02 19:07:57 +04:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2011-10-21 01:39:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* fill in fragment fields */
|
2011-10-27 02:15:42 +04:00
|
|
|
frag->hdr->len = length;
|
2011-10-21 01:39:44 +04:00
|
|
|
frag->hdr->tag = tag;
|
|
|
|
|
|
|
|
/* write the match header (with MPI comm/tag/etc. info) */
|
2012-12-14 03:18:53 +04:00
|
|
|
memcpy (frag->segments[0].seg_addr.pval, header, header_size);
|
2011-10-21 01:39:44 +04:00
|
|
|
|
|
|
|
/* write the message data if there is any */
|
|
|
|
/*
|
|
|
|
We can add MEMCHECKER calls before and after the packing.
|
|
|
|
*/
|
2011-10-27 02:15:42 +04:00
|
|
|
/* we can't use single-copy semantics here since as caller will consider the send
|
|
|
|
complete if we return success */
|
|
|
|
if (OPAL_UNLIKELY(payload_size && opal_convertor_need_buffers (convertor))) {
|
2011-11-02 19:07:57 +04:00
|
|
|
/* pack the data into the supplied buffer */
|
2012-12-14 03:18:53 +04:00
|
|
|
iov.iov_base = (IOVBASE_TYPE *)((uintptr_t)frag->segments[0].seg_addr.pval + header_size);
|
2011-11-02 19:07:57 +04:00
|
|
|
iov.iov_len = max_data = payload_size;
|
2011-10-21 01:39:44 +04:00
|
|
|
|
2011-11-02 19:07:57 +04:00
|
|
|
(void) opal_convertor_pack (convertor, &iov, &iov_count, &max_data);
|
2011-10-21 01:39:44 +04:00
|
|
|
|
2011-11-02 19:07:57 +04:00
|
|
|
assert (max_data == payload_size);
|
2011-10-27 02:15:42 +04:00
|
|
|
} else if (payload_size) {
|
2011-11-02 19:07:57 +04:00
|
|
|
/* bypassing the convertor may speed things up a little */
|
|
|
|
opal_convertor_get_current_pointer (convertor, &data_ptr);
|
2012-12-14 03:18:53 +04:00
|
|
|
memcpy ((void *)((uintptr_t)frag->segments[0].seg_addr.pval + header_size), data_ptr, payload_size);
|
2011-10-21 01:39:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
opal_list_append (&mca_btl_vader_component.active_sends, (opal_list_item_t *) frag);
|
|
|
|
|
|
|
|
/* write the fragment pointer to peer's the FIFO */
|
2013-03-28 02:10:02 +04:00
|
|
|
vader_fifo_write (frag->hdr, endpoint);
|
2011-10-21 01:39:44 +04:00
|
|
|
|
2011-10-27 02:15:42 +04:00
|
|
|
/* the progress function will return the fragment */
|
|
|
|
|
2011-10-21 01:39:44 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|