2011-12-10 01:24:07 +04:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
|
|
|
/*
|
2012-01-27 04:32:43 +04:00
|
|
|
* Copyright (c) 2011-2012 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 "ompi_config.h"
|
|
|
|
|
|
|
|
#include "btl_ugni.h"
|
|
|
|
#include "btl_ugni_frag.h"
|
|
|
|
#include "btl_ugni_endpoint.h"
|
2012-04-24 01:11:57 +04:00
|
|
|
#include "btl_ugni_prepare.h"
|
2011-12-10 01:24:07 +04:00
|
|
|
|
|
|
|
static int
|
|
|
|
mca_btl_ugni_free (struct mca_btl_base_module_t *btl,
|
|
|
|
mca_btl_base_descriptor_t *des);
|
|
|
|
|
|
|
|
static int
|
|
|
|
mca_btl_ugni_module_finalize (struct mca_btl_base_module_t* btl);
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
static mca_btl_base_descriptor_t *
|
|
|
|
mca_btl_ugni_prepare_dst (mca_btl_base_module_t *btl,
|
|
|
|
mca_btl_base_endpoint_t *endpoint,
|
|
|
|
mca_mpool_base_registration_t *registration,
|
|
|
|
opal_convertor_t *convertor, uint8_t order,
|
|
|
|
size_t reserve, size_t *size, uint32_t flags);
|
|
|
|
|
2011-12-10 01:24:07 +04:00
|
|
|
static struct mca_btl_base_descriptor_t *
|
|
|
|
mca_btl_ugni_prepare_src (struct mca_btl_base_module_t *btl,
|
|
|
|
struct mca_btl_base_endpoint_t *endpoint,
|
|
|
|
mca_mpool_base_registration_t *registration,
|
|
|
|
struct opal_convertor_t *convertor,
|
|
|
|
uint8_t order, size_t reserve, size_t *size,
|
|
|
|
uint32_t flags);
|
|
|
|
|
|
|
|
mca_btl_ugni_module_t mca_btl_ugni_module = {
|
|
|
|
{
|
|
|
|
/* .btl_component = */ &mca_btl_ugni_component.super,
|
|
|
|
|
|
|
|
/* these are set in component_register */
|
|
|
|
/* .btl_eager_limit = */ 0,
|
|
|
|
/* .btl_rndv_eager_limit = */ 0,
|
|
|
|
/* .btl_max_send_size = */ 0,
|
|
|
|
/* .btl_rdma_pipeline_send_length = */ 0,
|
|
|
|
/* .btl_rdma_pipeline_frag_size = */ 0,
|
|
|
|
/* .btl_min_rdma_pipeline_size = */ 0,
|
|
|
|
/* .btl_exclusivity = */ 0,
|
|
|
|
/* .btl_latency = */ 0,
|
|
|
|
/* .btl_bandwidth = */ 0,
|
|
|
|
/* .btl_flags = */ 0,
|
2012-06-21 21:09:12 +04:00
|
|
|
/* .btl_seg_size = */ 0,
|
2011-12-10 01:24:07 +04:00
|
|
|
|
|
|
|
/* member functions */
|
|
|
|
mca_btl_ugni_add_procs,
|
|
|
|
mca_btl_ugni_del_procs,
|
|
|
|
NULL, /* register */
|
|
|
|
mca_btl_ugni_module_finalize,
|
|
|
|
mca_btl_ugni_alloc,
|
|
|
|
mca_btl_ugni_free,
|
|
|
|
mca_btl_ugni_prepare_src,
|
|
|
|
mca_btl_ugni_prepare_dst,
|
|
|
|
mca_btl_ugni_send,
|
2012-06-29 19:43:29 +04:00
|
|
|
NULL, /* sendi */
|
2011-12-10 01:24:07 +04:00
|
|
|
mca_btl_ugni_put,
|
|
|
|
mca_btl_ugni_get,
|
|
|
|
NULL, /* mca_btl_base_dump, */
|
|
|
|
NULL, /* mpool */
|
|
|
|
NULL, /* mca_btl_ugni_register_error_cb - error callback registration */
|
|
|
|
NULL, /* mca_btl_ugni_ft_event */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
mca_btl_ugni_module_init (mca_btl_ugni_module_t *ugni_module,
|
|
|
|
ompi_common_ugni_device_t *dev)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
BTL_VERBOSE(("binding module %p to device %p", (void *) ugni_module,
|
|
|
|
(void *) dev));
|
|
|
|
|
|
|
|
/* copy module defaults (and function pointers) */
|
|
|
|
memmove (ugni_module, &mca_btl_ugni_module, sizeof (mca_btl_ugni_module));
|
|
|
|
|
|
|
|
OBJ_CONSTRUCT(&ugni_module->failed_frags, opal_list_t);
|
2012-03-16 00:13:32 +04:00
|
|
|
OBJ_CONSTRUCT(&ugni_module->eager_frags_send, ompi_free_list_t);
|
|
|
|
OBJ_CONSTRUCT(&ugni_module->eager_frags_recv, ompi_free_list_t);
|
|
|
|
OBJ_CONSTRUCT(&ugni_module->smsg_frags, ompi_free_list_t);
|
|
|
|
OBJ_CONSTRUCT(&ugni_module->rdma_frags, ompi_free_list_t);
|
|
|
|
OBJ_CONSTRUCT(&ugni_module->rdma_int_frags, ompi_free_list_t);
|
2012-04-20 01:51:55 +04:00
|
|
|
OBJ_CONSTRUCT(&ugni_module->pending_smsg_frags_bb, opal_pointer_array_t);
|
2012-06-01 00:02:41 +04:00
|
|
|
OBJ_CONSTRUCT(&ugni_module->ep_wait_list, opal_list_t);
|
2011-12-10 01:24:07 +04:00
|
|
|
|
|
|
|
ugni_module->device = dev;
|
2012-02-10 04:47:29 +04:00
|
|
|
ugni_module->endpoints = NULL;
|
2012-03-16 00:13:32 +04:00
|
|
|
dev->btl_ctx = (void *) ugni_module;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
|
|
|
/* create wildcard endpoint to listen for connections.
|
|
|
|
* there is no need to bind this endpoint. */
|
|
|
|
rc = GNI_EpCreate (ugni_module->device->dev_handle, NULL,
|
|
|
|
&ugni_module->wildcard_ep);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
|
|
|
|
BTL_ERROR(("error creating wildcard ugni endpoint"));
|
|
|
|
return ompi_common_rc_ugni_to_ompi (rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* post wildcard datagram */
|
|
|
|
rc = mca_btl_ugni_wildcard_ep_post (ugni_module);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
|
|
|
|
BTL_ERROR(("error posting wildcard datagram"));
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mca_btl_ugni_module_finalize (struct mca_btl_base_module_t *btl)
|
|
|
|
{
|
|
|
|
mca_btl_ugni_module_t *ugni_module = (mca_btl_ugni_module_t *)btl;
|
2012-04-25 01:16:51 +04:00
|
|
|
unsigned int i;
|
|
|
|
int rc;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-02-10 04:47:29 +04:00
|
|
|
OBJ_DESTRUCT(&ugni_module->eager_frags_send);
|
|
|
|
OBJ_DESTRUCT(&ugni_module->eager_frags_recv);
|
2012-03-16 00:13:32 +04:00
|
|
|
OBJ_DESTRUCT(&ugni_module->smsg_frags);
|
|
|
|
OBJ_DESTRUCT(&ugni_module->rdma_frags);
|
|
|
|
OBJ_DESTRUCT(&ugni_module->rdma_int_frags);
|
2012-06-01 00:02:41 +04:00
|
|
|
OBJ_DESTRUCT(&ugni_module->ep_wait_list);
|
2012-02-10 04:47:29 +04:00
|
|
|
|
2011-12-10 01:24:07 +04:00
|
|
|
/* close all open connections and release endpoints */
|
|
|
|
if (NULL != ugni_module->endpoints) {
|
2012-04-20 01:51:55 +04:00
|
|
|
for (i = 0 ; i < ugni_module->endpoint_count ; ++i) {
|
2011-12-10 01:24:07 +04:00
|
|
|
if (ugni_module->endpoints[i]) {
|
|
|
|
mca_btl_ugni_release_ep (ugni_module->endpoints[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ugni_module->endpoints[i] = NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
free (ugni_module->endpoints);
|
|
|
|
|
2011-12-10 01:24:07 +04:00
|
|
|
ugni_module->endpoint_count = 0;
|
|
|
|
ugni_module->endpoints = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* destroy all cqs */
|
2012-04-20 01:51:55 +04:00
|
|
|
rc = GNI_CqDestroy (ugni_module->rdma_local_cq);
|
|
|
|
if (GNI_RC_SUCCESS != rc) {
|
|
|
|
BTL_ERROR(("error tearing down local BTE/FMA CQ"));
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = GNI_CqDestroy (ugni_module->smsg_local_cq);
|
2011-12-10 01:24:07 +04:00
|
|
|
if (GNI_RC_SUCCESS != rc) {
|
2012-04-20 01:51:55 +04:00
|
|
|
BTL_ERROR(("error tearing down local SMSG CQ"));
|
2011-12-10 01:24:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
rc = GNI_CqDestroy (ugni_module->smsg_remote_cq);
|
|
|
|
if (GNI_RC_SUCCESS != rc) {
|
|
|
|
BTL_ERROR(("error tearing down remote SMSG CQ"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cancel wildcard post */
|
|
|
|
rc = GNI_EpPostDataCancelById (ugni_module->wildcard_ep,
|
|
|
|
MCA_BTL_UGNI_CONNECT_WILDCARD_ID |
|
|
|
|
ORTE_PROC_MY_NAME->vpid);
|
|
|
|
if (GNI_RC_SUCCESS != rc) {
|
|
|
|
BTL_VERBOSE(("btl/ugni error cancelling wildcard post"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tear down wildcard endpoint */
|
|
|
|
rc = GNI_EpDestroy (ugni_module->wildcard_ep);
|
|
|
|
if (GNI_RC_SUCCESS != rc) {
|
|
|
|
BTL_VERBOSE(("btl/ugni error destroying endpoint"));
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) mca_mpool_base_module_destroy (ugni_module->smsg_mpool);
|
|
|
|
ugni_module->smsg_mpool = NULL;
|
|
|
|
|
|
|
|
(void) mca_mpool_base_module_destroy (ugni_module->super.btl_mpool);
|
|
|
|
ugni_module->super.btl_mpool = NULL;
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
OBJ_DESTRUCT(&ugni_module->pending_smsg_frags_bb);
|
|
|
|
|
2011-12-10 01:24:07 +04:00
|
|
|
OBJ_DESTRUCT(&ugni_module->failed_frags);
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mca_btl_base_descriptor_t *
|
|
|
|
mca_btl_ugni_alloc(struct mca_btl_base_module_t *btl,
|
|
|
|
struct mca_btl_base_endpoint_t *endpoint,
|
|
|
|
uint8_t order, size_t size, uint32_t flags)
|
|
|
|
{
|
|
|
|
mca_btl_ugni_base_frag_t *frag = NULL;
|
|
|
|
|
2012-02-10 04:47:29 +04:00
|
|
|
if (size <= mca_btl_ugni_component.smsg_max_data) {
|
|
|
|
(void) MCA_BTL_UGNI_FRAG_ALLOC_SMSG(endpoint, frag);
|
|
|
|
} else if (size <= btl->btl_eager_limit) {
|
|
|
|
(void) MCA_BTL_UGNI_FRAG_ALLOC_EAGER_SEND(endpoint, frag);
|
2011-12-10 01:24:07 +04:00
|
|
|
}
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
if (OPAL_UNLIKELY(NULL == frag)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-12-10 01:24:07 +04:00
|
|
|
BTL_VERBOSE(("btl/ugni_module allocated frag of size: %u, flags: %x. frag = %p",
|
|
|
|
(unsigned int)size, flags, (void *) frag));
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
frag->base.des_flags = flags;
|
|
|
|
frag->base.order = order;
|
2012-06-21 21:09:12 +04:00
|
|
|
frag->base.des_src = &frag->segments[1].base;
|
2012-04-20 01:51:55 +04:00
|
|
|
frag->base.des_src_cnt = 1;
|
2012-06-21 21:09:12 +04:00
|
|
|
frag->base.des_dst = &frag->segments[1].base;
|
2012-04-20 01:51:55 +04:00
|
|
|
frag->base.des_dst_cnt = 1;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-06-21 21:09:12 +04:00
|
|
|
frag->segments[0].base.seg_addr.pval = NULL;
|
|
|
|
frag->segments[0].base.seg_len = 0;
|
|
|
|
frag->segments[1].base.seg_addr.pval = frag->base.super.ptr;
|
|
|
|
frag->segments[1].base.seg_len = size;
|
2012-04-20 01:51:55 +04:00
|
|
|
|
2012-05-07 21:23:06 +04:00
|
|
|
frag->flags = MCA_BTL_UGNI_FRAG_BUFFERED;
|
|
|
|
if (size > mca_btl_ugni_component.smsg_max_data) {
|
|
|
|
mca_btl_ugni_reg_t *registration;
|
|
|
|
|
|
|
|
frag->hdr_size = sizeof (frag->hdr.eager);
|
2012-06-01 00:02:41 +04:00
|
|
|
frag->flags |= MCA_BTL_UGNI_FRAG_EAGER | MCA_BTL_UGNI_FRAG_IGNORE;
|
2012-05-07 21:23:06 +04:00
|
|
|
|
|
|
|
registration = (mca_btl_ugni_reg_t *) frag->base.super.registration;
|
|
|
|
|
2012-06-21 21:09:12 +04:00
|
|
|
frag->segments[1].memory_handle = registration->memory_hdl;
|
2012-05-07 21:23:06 +04:00
|
|
|
} else {
|
|
|
|
frag->hdr_size = sizeof (frag->hdr.send);
|
|
|
|
}
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
return &frag->base;
|
2011-12-10 01:24:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mca_btl_ugni_free (struct mca_btl_base_module_t *btl,
|
|
|
|
mca_btl_base_descriptor_t *des)
|
|
|
|
{
|
2012-04-20 01:51:55 +04:00
|
|
|
return mca_btl_ugni_frag_return ((mca_btl_ugni_base_frag_t *) des);
|
2011-12-10 01:24:07 +04:00
|
|
|
}
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
static struct mca_btl_base_descriptor_t *
|
|
|
|
mca_btl_ugni_prepare_src (struct mca_btl_base_module_t *btl,
|
|
|
|
mca_btl_base_endpoint_t *endpoint,
|
|
|
|
mca_mpool_base_registration_t *registration,
|
|
|
|
struct opal_convertor_t *convertor,
|
|
|
|
uint8_t order, size_t reserve, size_t *size,
|
|
|
|
uint32_t flags)
|
|
|
|
{
|
|
|
|
if (OPAL_LIKELY(reserve)) {
|
|
|
|
return mca_btl_ugni_prepare_src_send (btl, endpoint, convertor,
|
|
|
|
order, reserve, size, flags);
|
|
|
|
} else {
|
2012-04-24 01:11:57 +04:00
|
|
|
return mca_btl_ugni_prepare_src_rdma (btl, endpoint, registration,
|
|
|
|
convertor, order, size, flags);
|
2011-12-10 01:24:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static mca_btl_base_descriptor_t *
|
|
|
|
mca_btl_ugni_prepare_dst (mca_btl_base_module_t *btl,
|
|
|
|
mca_btl_base_endpoint_t *endpoint,
|
|
|
|
mca_mpool_base_registration_t *registration,
|
|
|
|
opal_convertor_t *convertor, uint8_t order,
|
|
|
|
size_t reserve, size_t *size, uint32_t flags)
|
|
|
|
{
|
|
|
|
mca_btl_ugni_base_frag_t *frag;
|
|
|
|
void *data_ptr;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
opal_convertor_get_current_pointer (convertor, &data_ptr);
|
|
|
|
|
2012-02-10 04:47:29 +04:00
|
|
|
(void) MCA_BTL_UGNI_FRAG_ALLOC_RDMA(endpoint, frag);
|
2011-12-10 01:24:07 +04:00
|
|
|
if (OPAL_UNLIKELY(NULL == frag)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* always need to register the buffer for put/get (even for fma) */
|
|
|
|
if (NULL == registration) {
|
2012-02-10 04:47:29 +04:00
|
|
|
rc = btl->btl_mpool->mpool_register(btl->btl_mpool,
|
|
|
|
data_ptr, *size, 0,
|
|
|
|
®istration);
|
2011-12-10 01:24:07 +04:00
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
|
2012-02-10 04:47:29 +04:00
|
|
|
mca_btl_ugni_frag_return (frag);
|
2011-12-10 01:24:07 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
frag->registration = (mca_btl_ugni_reg_t*) registration;
|
|
|
|
}
|
|
|
|
|
2012-06-21 21:09:12 +04:00
|
|
|
frag->segments[0].memory_handle = ((mca_btl_ugni_reg_t *)registration)->memory_hdl;
|
|
|
|
frag->segments[0].base.seg_len = *size;
|
2012-07-14 01:19:16 +04:00
|
|
|
frag->segments[0].base.seg_addr.lval = (uint64_t)(uintptr_t) data_ptr;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-06-21 21:09:12 +04:00
|
|
|
frag->base.des_dst = &frag->segments->base;
|
2011-12-10 01:24:07 +04:00
|
|
|
frag->base.des_dst_cnt = 1;
|
|
|
|
frag->base.order = order;
|
|
|
|
frag->base.des_flags = flags;
|
|
|
|
|
|
|
|
return (struct mca_btl_base_descriptor_t *) frag;
|
|
|
|
}
|