2012-06-27 05:28:28 +04:00
|
|
|
/* * Copyright (C) Mellanox Technologies Ltd. 2001-2011. ALL RIGHTS RESERVED.
|
2011-07-26 08:36:21 +04:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include "ompi/mca/pml/pml.h"
|
|
|
|
#include "opal/datatype/opal_convertor.h"
|
2013-12-19 23:37:21 +04:00
|
|
|
#include "opal/util/show_help.h"
|
2011-07-26 08:36:21 +04:00
|
|
|
|
|
|
|
#include "mtl_mxm.h"
|
|
|
|
#include "mtl_mxm_types.h"
|
|
|
|
#include "mtl_mxm_request.h"
|
|
|
|
#include "ompi/mca/mtl/base/mtl_base_datatype.h"
|
|
|
|
|
2013-02-27 17:21:30 +04:00
|
|
|
static inline __opal_attribute_always_inline__
|
|
|
|
size_t ompi_mtl_mxm_stream_pack(opal_convertor_t *convertor, void *buffer,
|
|
|
|
size_t length, size_t offset)
|
2012-07-19 17:28:06 +04:00
|
|
|
{
|
|
|
|
struct iovec iov;
|
|
|
|
uint32_t iov_count = 1;
|
|
|
|
|
|
|
|
iov.iov_len = length;
|
|
|
|
iov.iov_base = buffer;
|
|
|
|
|
|
|
|
opal_convertor_set_position(convertor, &offset);
|
|
|
|
opal_convertor_pack(convertor, &iov, &iov_count, &length);
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
2013-02-27 17:21:30 +04:00
|
|
|
static size_t ompi_mtl_mxm_stream_isend(void *buffer, size_t length, size_t offset, void *context)
|
|
|
|
{
|
|
|
|
mca_mtl_mxm_request_t *mtl_mxm_request = (mca_mtl_mxm_request_t *) context;
|
|
|
|
opal_convertor_t *convertor = mtl_mxm_request->convertor;
|
|
|
|
|
|
|
|
return ompi_mtl_mxm_stream_pack(convertor, buffer, length, offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t ompi_mtl_mxm_stream_send(void *buffer, size_t length, size_t offset, void *context)
|
|
|
|
{
|
|
|
|
opal_convertor_t *convertor = (opal_convertor_t *) context;
|
|
|
|
|
|
|
|
return ompi_mtl_mxm_stream_pack(convertor, buffer, length, offset);
|
|
|
|
}
|
|
|
|
|
2012-07-19 17:28:06 +04:00
|
|
|
static inline __opal_attribute_always_inline__ int
|
|
|
|
ompi_mtl_mxm_choose_send_datatype(mxm_send_req_t *mxm_send_req,
|
2013-02-27 17:21:30 +04:00
|
|
|
opal_convertor_t *convertor,
|
|
|
|
mxm_stream_cb_t stream_cb)
|
2012-07-19 17:28:06 +04:00
|
|
|
{
|
|
|
|
struct iovec iov;
|
|
|
|
uint32_t iov_count = 1;
|
|
|
|
|
|
|
|
size_t *buffer_len = &mxm_send_req->base.data.buffer.length;
|
|
|
|
|
|
|
|
opal_convertor_get_packed_size(convertor, buffer_len);
|
|
|
|
if (0 == *buffer_len) {
|
|
|
|
mxm_send_req->base.data.buffer.ptr = NULL;
|
|
|
|
mxm_send_req->base.data_type = MXM_REQ_DATA_BUFFER;
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opal_convertor_need_buffers(convertor)) {
|
|
|
|
mxm_send_req->base.data_type = MXM_REQ_DATA_STREAM;
|
|
|
|
mxm_send_req->base.data.stream.length = *buffer_len;
|
2013-02-27 17:21:30 +04:00
|
|
|
mxm_send_req->base.data.stream.cb = stream_cb;
|
2012-07-19 17:28:06 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
mxm_send_req->base.data_type = MXM_REQ_DATA_BUFFER;
|
|
|
|
|
|
|
|
iov.iov_base = NULL;
|
|
|
|
iov.iov_len = *buffer_len;
|
|
|
|
|
|
|
|
opal_convertor_pack(convertor, &iov, &iov_count, buffer_len);
|
|
|
|
mxm_send_req->base.data.buffer.ptr = iov.iov_base;
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2011-07-26 08:36:21 +04:00
|
|
|
|
2011-08-02 18:30:11 +04:00
|
|
|
static void ompi_mtl_mxm_send_completion_cb(void *context)
|
2011-07-26 08:36:21 +04:00
|
|
|
{
|
2012-04-09 20:02:05 +04:00
|
|
|
mca_mtl_mxm_request_t *mtl_mxm_request = context;
|
2011-07-26 08:36:21 +04:00
|
|
|
|
2012-04-09 20:02:05 +04:00
|
|
|
ompi_mtl_mxm_to_mpi_status(mtl_mxm_request->mxm.base.error,
|
|
|
|
&mtl_mxm_request->super.ompi_req->req_status);
|
2011-07-26 08:36:21 +04:00
|
|
|
mtl_mxm_request->super.completion_callback(&mtl_mxm_request->super);
|
|
|
|
}
|
|
|
|
|
2012-03-01 02:02:34 +04:00
|
|
|
static void ompi_mtl_mxm_send_progress_cb(void *user_data)
|
|
|
|
{
|
|
|
|
opal_progress();
|
|
|
|
}
|
|
|
|
|
2011-07-26 08:36:21 +04:00
|
|
|
int ompi_mtl_mxm_send(struct mca_mtl_base_module_t* mtl,
|
|
|
|
struct ompi_communicator_t* comm, int dest, int tag,
|
|
|
|
struct opal_convertor_t *convertor,
|
|
|
|
mca_pml_base_send_mode_t mode)
|
|
|
|
{
|
2011-08-02 18:30:11 +04:00
|
|
|
mxm_send_req_t mxm_send_req;
|
2012-03-01 02:02:34 +04:00
|
|
|
mxm_wait_t wait;
|
2011-07-26 08:36:21 +04:00
|
|
|
mxm_error_t err;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* prepare local send request */
|
2011-08-20 02:18:17 +04:00
|
|
|
mxm_send_req.base.state = MXM_REQ_NEW;
|
|
|
|
mxm_send_req.base.mq = ompi_mtl_mxm_mq_lookup(comm);
|
|
|
|
mxm_send_req.base.conn = ompi_mtl_mxm_conn_lookup(comm, dest);
|
2013-02-27 17:21:30 +04:00
|
|
|
mxm_send_req.base.context = convertor;
|
2013-02-17 14:04:19 +04:00
|
|
|
mxm_send_req.base.completed_cb = NULL;
|
|
|
|
|
2013-02-27 17:21:30 +04:00
|
|
|
ret = ompi_mtl_mxm_choose_send_datatype(&mxm_send_req, convertor,
|
|
|
|
ompi_mtl_mxm_stream_send);
|
2012-07-19 17:28:06 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
2011-07-26 08:36:21 +04:00
|
|
|
return ret;
|
|
|
|
}
|
2012-01-06 22:56:28 +04:00
|
|
|
|
2013-12-04 13:11:55 +04:00
|
|
|
mxm_send_req.base.data.buffer.memh = MXM_INVALID_MEM_HANDLE;
|
2011-08-20 02:18:17 +04:00
|
|
|
mxm_send_req.op.send.tag = tag;
|
|
|
|
mxm_send_req.op.send.imm_data = ompi_comm_rank(comm);
|
2013-12-04 13:11:55 +04:00
|
|
|
|
2013-02-17 14:04:19 +04:00
|
|
|
#if MXM_API < MXM_VERSION(2,0)
|
|
|
|
mxm_send_req.base.flags = MXM_REQ_FLAG_BLOCKING;
|
|
|
|
mxm_send_req.opcode = MXM_REQ_OP_SEND;
|
|
|
|
if (mode == MCA_PML_BASE_SEND_SYNCHRONOUS) {
|
|
|
|
mxm_send_req.base.flags |= MXM_REQ_FLAG_SEND_SYNC;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
mxm_send_req.flags = MXM_REQ_SEND_FLAG_BLOCKING;
|
|
|
|
if (mode == MCA_PML_BASE_SEND_SYNCHRONOUS) {
|
|
|
|
mxm_send_req.opcode = MXM_REQ_OP_SEND_SYNC;
|
|
|
|
} else {
|
|
|
|
mxm_send_req.opcode = MXM_REQ_OP_SEND;
|
|
|
|
}
|
|
|
|
#endif
|
2011-08-20 02:18:17 +04:00
|
|
|
|
2011-07-26 08:36:21 +04:00
|
|
|
/* post-send */
|
2011-08-02 18:30:11 +04:00
|
|
|
err = mxm_req_send(&mxm_send_req);
|
2011-07-26 08:36:21 +04:00
|
|
|
if (MXM_OK != err) {
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mtl-mxm.txt", "error posting send", true, 0, mxm_error_string(err));
|
2011-07-26 08:36:21 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wait for request completion */
|
2012-03-01 02:02:34 +04:00
|
|
|
wait.req = &mxm_send_req.base;
|
|
|
|
wait.state = MXM_REQ_COMPLETED;
|
|
|
|
wait.progress_cb = ompi_mtl_mxm_send_progress_cb;
|
|
|
|
wait.progress_arg = NULL;
|
|
|
|
mxm_wait(&wait);
|
2011-07-26 08:36:21 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ompi_mtl_mxm_isend(struct mca_mtl_base_module_t* mtl,
|
|
|
|
struct ompi_communicator_t* comm, int dest, int tag,
|
|
|
|
struct opal_convertor_t *convertor,
|
|
|
|
mca_pml_base_send_mode_t mode, bool blocking,
|
|
|
|
mca_mtl_request_t * mtl_request)
|
|
|
|
{
|
2013-02-27 17:21:30 +04:00
|
|
|
mca_mtl_mxm_request_t *mtl_mxm_request = (mca_mtl_mxm_request_t *) mtl_request;
|
2011-08-02 18:30:11 +04:00
|
|
|
mxm_send_req_t *mxm_send_req;
|
2011-07-26 08:36:21 +04:00
|
|
|
mxm_error_t err;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
assert(mtl == &ompi_mtl_mxm.super);
|
|
|
|
|
|
|
|
mtl_mxm_request->convertor = convertor;
|
|
|
|
|
2011-08-07 16:06:49 +04:00
|
|
|
mxm_send_req = &mtl_mxm_request->mxm.send;
|
2013-02-04 10:59:24 +04:00
|
|
|
#if MXM_API >= MXM_VERSION(2,0)
|
|
|
|
mtl_mxm_request->is_send = 1;
|
|
|
|
#endif
|
2011-08-02 18:30:11 +04:00
|
|
|
|
2011-07-26 08:36:21 +04:00
|
|
|
/* prepare a send request embedded in the MTL request */
|
2011-08-20 02:18:17 +04:00
|
|
|
mxm_send_req->base.state = MXM_REQ_NEW;
|
|
|
|
mxm_send_req->base.mq = ompi_mtl_mxm_mq_lookup(comm);
|
|
|
|
mxm_send_req->base.conn = ompi_mtl_mxm_conn_lookup(comm, dest);
|
2013-02-27 17:21:30 +04:00
|
|
|
|
|
|
|
ret = ompi_mtl_mxm_choose_send_datatype(mxm_send_req, convertor,
|
|
|
|
ompi_mtl_mxm_stream_isend);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
mtl_mxm_request->buf = mxm_send_req->base.data.buffer.ptr;
|
|
|
|
mtl_mxm_request->length = mxm_send_req->base.data.buffer.length;
|
|
|
|
|
2012-08-28 09:57:36 +04:00
|
|
|
mxm_send_req->base.data.buffer.memh = MXM_INVALID_MEM_HANDLE;
|
2011-08-20 02:18:17 +04:00
|
|
|
mxm_send_req->base.context = mtl_mxm_request;
|
|
|
|
mxm_send_req->base.completed_cb = ompi_mtl_mxm_send_completion_cb;
|
2013-02-17 14:04:19 +04:00
|
|
|
|
|
|
|
#if MXM_API < MXM_VERSION(2,0)
|
|
|
|
mxm_send_req->base.flags = 0;
|
|
|
|
mxm_send_req->opcode = MXM_REQ_OP_SEND;
|
2011-07-26 08:36:21 +04:00
|
|
|
if (mode == MCA_PML_BASE_SEND_SYNCHRONOUS) {
|
2012-01-06 22:56:28 +04:00
|
|
|
mxm_send_req->base.flags |= MXM_REQ_FLAG_SEND_SYNC;
|
2013-02-17 14:04:19 +04:00
|
|
|
}
|
2014-01-12 21:47:03 +04:00
|
|
|
#else
|
|
|
|
#if defined(MXM_REQ_SEND_FLAG_REENTRANT)
|
|
|
|
mxm_send_req->flags = MXM_REQ_SEND_FLAG_REENTRANT;
|
2013-02-17 14:04:19 +04:00
|
|
|
#else
|
|
|
|
mxm_send_req->flags = 0;
|
2014-01-12 21:47:03 +04:00
|
|
|
#endif
|
2013-02-17 14:04:19 +04:00
|
|
|
if (mode == MCA_PML_BASE_SEND_SYNCHRONOUS) {
|
|
|
|
mxm_send_req->opcode = MXM_REQ_OP_SEND_SYNC;
|
|
|
|
} else {
|
|
|
|
mxm_send_req->opcode = MXM_REQ_OP_SEND;
|
2011-07-26 08:36:21 +04:00
|
|
|
}
|
2013-02-17 14:04:19 +04:00
|
|
|
#endif
|
2011-11-01 02:36:15 +04:00
|
|
|
mxm_send_req->op.send.tag = tag;
|
|
|
|
mxm_send_req->op.send.imm_data = ompi_comm_rank(comm);
|
|
|
|
|
2011-07-26 08:36:21 +04:00
|
|
|
/* post-send */
|
2011-08-02 18:30:11 +04:00
|
|
|
err = mxm_req_send(mxm_send_req);
|
2011-07-26 08:36:21 +04:00
|
|
|
if (MXM_OK != err) {
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mtl-mxm.txt", "error posting send", true, 1, mxm_error_string(err));
|
2011-07-26 08:36:21 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|