2011-11-02 15:07:57 +00:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
2011-10-20 21:39:44 +00:00
|
|
|
/*
|
2013-03-27 22:10:02 +00:00
|
|
|
* Copyright (c) 2010-2013 Los Alamos National Security, LLC.
|
2011-10-20 21:39:44 +00: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_endpoint.h"
|
2013-07-11 20:54:12 +00:00
|
|
|
#include "btl_vader_xpmem.h"
|
2011-10-20 21:39:44 +00:00
|
|
|
|
2014-01-06 19:51:44 +00:00
|
|
|
#if OMPI_BTL_VADER_HAVE_CMA
|
|
|
|
#include <sys/uio.h>
|
|
|
|
|
|
|
|
#if OMPI_CMA_NEED_SYSCALL_DEFS
|
|
|
|
#include "opal/sys/cma.h"
|
|
|
|
#endif /* OMPI_CMA_NEED_SYSCALL_DEFS */
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2011-10-20 21:39:44 +00:00
|
|
|
/**
|
|
|
|
* Initiate an synchronous put.
|
|
|
|
*
|
|
|
|
* @param btl (IN) BTL module
|
|
|
|
* @param endpoint (IN) BTL addressing information
|
|
|
|
* @param descriptor (IN) Description of the data to be transferred
|
|
|
|
*/
|
2014-01-06 19:51:44 +00:00
|
|
|
#if OMPI_BTL_VADER_HAVE_XPMEM
|
2011-10-20 21:39:44 +00:00
|
|
|
int mca_btl_vader_put (struct mca_btl_base_module_t *btl,
|
2011-11-02 15:07:57 +00:00
|
|
|
struct mca_btl_base_endpoint_t *endpoint,
|
|
|
|
struct mca_btl_base_descriptor_t *des)
|
2011-10-20 21:39:44 +00:00
|
|
|
{
|
|
|
|
mca_btl_vader_frag_t *frag = (mca_btl_vader_frag_t *) des;
|
|
|
|
mca_btl_base_segment_t *src = des->des_src;
|
|
|
|
mca_btl_base_segment_t *dst = des->des_dst;
|
2013-07-11 20:54:12 +00:00
|
|
|
const size_t size = min(dst->seg_len, src->seg_len);
|
2011-10-20 21:39:44 +00:00
|
|
|
mca_mpool_base_registration_t *reg;
|
|
|
|
void *rem_ptr;
|
|
|
|
|
2013-07-11 20:54:12 +00:00
|
|
|
reg = vader_get_registation (endpoint, dst->seg_addr.pval, dst->seg_len, 0, &rem_ptr);
|
2011-10-20 21:39:44 +00:00
|
|
|
if (OPAL_UNLIKELY(NULL == reg)) {
|
2011-11-02 15:07:57 +00:00
|
|
|
return OMPI_ERROR;
|
2011-10-20 21:39:44 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 20:54:12 +00:00
|
|
|
vader_memmove (rem_ptr, src->seg_addr.pval, size);
|
2011-10-20 21:39:44 +00:00
|
|
|
|
2013-03-27 22:10:02 +00:00
|
|
|
vader_return_registration (reg, endpoint);
|
2011-10-20 21:39:44 +00:00
|
|
|
|
2012-03-15 20:12:46 +00:00
|
|
|
/* always call the callback function */
|
|
|
|
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
|
2011-10-20 21:39:44 +00:00
|
|
|
|
2012-03-15 20:12:46 +00:00
|
|
|
mca_btl_vader_frag_complete (frag);
|
2011-10-20 21:39:44 +00:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2014-01-06 19:51:44 +00:00
|
|
|
#elif OMPI_BTL_VADER_HAVE_CMA
|
|
|
|
int mca_btl_vader_put (struct mca_btl_base_module_t *btl,
|
|
|
|
struct mca_btl_base_endpoint_t *endpoint,
|
|
|
|
struct mca_btl_base_descriptor_t *des)
|
|
|
|
{
|
|
|
|
mca_btl_vader_frag_t *frag = (mca_btl_vader_frag_t *) des;
|
|
|
|
mca_btl_base_segment_t *src = des->des_src;
|
|
|
|
mca_btl_base_segment_t *dst = des->des_dst;
|
|
|
|
const size_t size = min(dst->seg_len, src->seg_len);
|
|
|
|
struct iovec src_iov = {.iov_base = src->seg_addr.pval, .iov_len = size};
|
|
|
|
struct iovec dst_iov = {.iov_base = dst->seg_addr.pval, .iov_len = size};
|
|
|
|
ssize_t ret;
|
|
|
|
|
|
|
|
ret = process_vm_writev (endpoint->seg_ds.seg_cpid, &src_iov, 1, &dst_iov, 1, 0);
|
|
|
|
if (ret != size) {
|
|
|
|
fprintf (stderr, "Wrote %d, expected %u\n", ret, size);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
mca_btl_vader_frag_complete (frag);
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
#endif
|