2011-12-10 01:24:07 +04:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
|
|
|
/*
|
2013-11-18 08:58:37 +04:00
|
|
|
* Copyright (c) 2011-2013 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 "common_ugni.h"
|
|
|
|
|
2013-11-18 08:58:37 +04:00
|
|
|
OBJ_CLASS_INSTANCE(ompi_common_ugni_endpoint_t, opal_object_t, NULL, NULL);
|
2011-12-10 01:24:07 +04:00
|
|
|
|
|
|
|
int ompi_common_ugni_endpoint_for_proc (ompi_common_ugni_device_t *dev, ompi_proc_t *peer_proc,
|
|
|
|
ompi_common_ugni_endpoint_t **ep)
|
|
|
|
{
|
|
|
|
ompi_common_ugni_endpoint_t *endpoint;
|
|
|
|
ompi_common_ugni_modex_t *modex;
|
|
|
|
size_t msg_size;
|
2013-11-18 08:58:37 +04:00
|
|
|
int rc;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
|
|
|
assert (NULL != dev && NULL != ep && peer_proc);
|
|
|
|
|
2013-11-18 08:58:37 +04:00
|
|
|
endpoint = OBJ_NEW(ompi_common_ugni_endpoint_t);
|
|
|
|
if (OPAL_UNLIKELY(NULL == endpoint)) {
|
|
|
|
assert (0);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2013-11-18 08:58:37 +04:00
|
|
|
/* Receive the modex */
|
|
|
|
rc = ompi_modex_recv(&ompi_common_ugni_component, peer_proc,
|
|
|
|
(void *) &modex, &msg_size);
|
|
|
|
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
|
|
|
|
OPAL_OUTPUT((-1, "btl/ugni error receiving modex"));
|
|
|
|
return rc;
|
|
|
|
}
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2013-11-18 08:58:37 +04:00
|
|
|
endpoint->ep_rem_addr = modex->addr;
|
|
|
|
endpoint->ep_rem_id = modex->id;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2013-11-18 08:58:37 +04:00
|
|
|
endpoint->dev = dev;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2013-11-18 08:58:37 +04:00
|
|
|
*ep = endpoint;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ompi_common_ugni_endpoint_return (ompi_common_ugni_endpoint_t *ep)
|
|
|
|
{
|
|
|
|
assert(NULL != ep);
|
|
|
|
|
|
|
|
OBJ_RELEASE(ep);
|
|
|
|
}
|
|
|
|
|
2013-11-18 08:58:37 +04:00
|
|
|
int ompi_common_ugni_ep_create (ompi_common_ugni_endpoint_t *cep, gni_cq_handle_t cq,
|
|
|
|
gni_ep_handle_t *ep_handle)
|
2011-12-10 01:24:07 +04:00
|
|
|
{
|
2012-04-20 01:51:55 +04:00
|
|
|
gni_return_t grc;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
if (OPAL_UNLIKELY(NULL == cep)) {
|
|
|
|
assert (0);
|
2011-12-10 01:24:07 +04:00
|
|
|
return OPAL_ERR_BAD_PARAM;
|
|
|
|
}
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
/* create a uGNI endpoint handle and bind it to the remote peer */
|
|
|
|
grc = GNI_EpCreate (cep->dev->dev_handle, cq, ep_handle);
|
|
|
|
if (OPAL_UNLIKELY(GNI_RC_SUCCESS != grc)) {
|
|
|
|
return ompi_common_rc_ugni_to_ompi (grc);
|
|
|
|
}
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
grc = GNI_EpBind (*ep_handle, cep->ep_rem_addr, cep->ep_rem_id);
|
|
|
|
if (GNI_RC_SUCCESS != grc) {
|
2013-11-18 08:58:37 +04:00
|
|
|
GNI_EpDestroy (*ep_handle);
|
2012-04-20 01:51:55 +04:00
|
|
|
return ompi_common_rc_ugni_to_ompi (grc);
|
|
|
|
}
|
2011-12-10 01:24:07 +04:00
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
return OMPI_SUCCESS;
|
2011-12-10 01:24:07 +04:00
|
|
|
}
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
int ompi_common_ugni_ep_destroy (gni_ep_handle_t *ep)
|
2011-12-10 01:24:07 +04:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
if (NULL == ep || 0 == *ep) {
|
2011-12-10 01:24:07 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
rc = GNI_EpUnbind (*ep);
|
2011-12-10 01:24:07 +04:00
|
|
|
if (OPAL_UNLIKELY(GNI_RC_SUCCESS != rc)) {
|
|
|
|
/* should warn */
|
|
|
|
}
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
GNI_EpDestroy (*ep);
|
2011-12-10 01:24:07 +04:00
|
|
|
if (OPAL_UNLIKELY(GNI_RC_SUCCESS != rc)) {
|
|
|
|
/* should warn */
|
|
|
|
}
|
|
|
|
|
2012-04-20 01:51:55 +04:00
|
|
|
*ep = 0;
|
2011-12-10 01:24:07 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|