2011-10-18 00:51:22 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
|
2011-12-02 18:10:08 +04:00
|
|
|
* Copyright (c) 2011 Los Alamos National Security, LLC.
|
|
|
|
* All rights reserved.
|
2011-10-18 00:51:22 +04:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include "ompi/constants.h"
|
|
|
|
|
|
|
|
#include <pmi.h>
|
2013-06-21 19:28:14 +04:00
|
|
|
#if WANT_PMI2_SUPPORT
|
2011-10-21 08:54:38 +04:00
|
|
|
#include <pmi2.h>
|
|
|
|
#endif
|
2011-10-18 00:51:22 +04:00
|
|
|
|
2013-07-24 08:05:41 +04:00
|
|
|
#include "opal/mca/common/pmi/common_pmi.h"
|
|
|
|
|
2011-10-18 00:51:22 +04:00
|
|
|
#include "ompi/info/info.h"
|
2013-01-28 03:25:10 +04:00
|
|
|
#include "ompi/mca/rte/rte.h"
|
2011-10-18 00:51:22 +04:00
|
|
|
#include "ompi/mca/pubsub/base/base.h"
|
|
|
|
#include "pubsub_pmi.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Init the module
|
|
|
|
*/
|
|
|
|
static int init(void)
|
|
|
|
{
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* publish the port_name for the specified service_name.
|
|
|
|
*/
|
2013-09-27 01:56:20 +04:00
|
|
|
static int publish ( const char *service_name, ompi_info_t *info, const char *port_name )
|
2011-10-18 00:51:22 +04:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2013-06-21 19:28:14 +04:00
|
|
|
#if WANT_PMI2_SUPPORT
|
2011-10-21 20:34:22 +04:00
|
|
|
if (PMI_SUCCESS != (rc = PMI2_Nameserv_publish(service_name, NULL, port_name))) {
|
2013-07-24 08:05:41 +04:00
|
|
|
OPAL_PMI_ERROR(rc, "PMI2_Nameserv_publish");
|
2011-10-21 08:54:38 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
#else
|
2011-10-18 00:51:22 +04:00
|
|
|
if (PMI_SUCCESS != (rc = PMI_Publish_name(service_name, port_name))) {
|
2013-07-24 08:05:41 +04:00
|
|
|
OPAL_PMI_ERROR(rc, "PMI_Publish_name");
|
2011-10-18 00:51:22 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2011-10-21 08:54:38 +04:00
|
|
|
#endif
|
2011-10-18 00:51:22 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-09-27 01:56:20 +04:00
|
|
|
static char* lookup ( const char *service_name, ompi_info_t *info )
|
2011-10-18 00:51:22 +04:00
|
|
|
{
|
|
|
|
char *port=NULL;
|
|
|
|
int rc;
|
|
|
|
|
2013-06-21 19:28:14 +04:00
|
|
|
#if WANT_PMI2_SUPPORT
|
2011-10-21 08:54:38 +04:00
|
|
|
port = (char*)malloc(1024*sizeof(char)); /* arbitrary size */
|
2011-10-21 20:34:22 +04:00
|
|
|
if (PMI_SUCCESS != (rc = PMI2_Nameserv_lookup(service_name, NULL, port, 1024))) {
|
2013-07-24 08:05:41 +04:00
|
|
|
OPAL_PMI_ERROR(rc, "PMI2_Nameserv_lookup");
|
2011-10-21 08:54:38 +04:00
|
|
|
free(port);
|
2011-12-02 14:36:57 +04:00
|
|
|
return NULL;
|
2011-10-21 08:54:38 +04:00
|
|
|
}
|
|
|
|
#else
|
2011-10-18 00:51:22 +04:00
|
|
|
if (PMI_SUCCESS != (rc = PMI_Lookup_name(service_name, port))) {
|
2013-07-24 08:05:41 +04:00
|
|
|
OPAL_PMI_ERROR(rc, "PMI_Lookup_name");
|
2011-10-18 00:51:22 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2011-10-21 08:54:38 +04:00
|
|
|
#endif
|
2011-10-18 00:51:22 +04:00
|
|
|
return port;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* delete the entry */
|
2013-09-27 01:56:20 +04:00
|
|
|
static int unpublish ( const char *service_name, ompi_info_t *info )
|
2011-10-18 00:51:22 +04:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2013-06-21 19:28:14 +04:00
|
|
|
#if WANT_PMI2_SUPPORT
|
2011-10-21 08:54:38 +04:00
|
|
|
if (PMI_SUCCESS != (rc = PMI2_Nameserv_unpublish(service_name, NULL))) {
|
2013-07-24 08:05:41 +04:00
|
|
|
OPAL_PMI_ERROR(rc, "PMI2_Nameserv_unpublish");
|
2011-10-21 08:54:38 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
#else
|
2011-10-18 00:51:22 +04:00
|
|
|
if (PMI_SUCCESS != (rc = PMI_Unpublish_name(service_name))) {
|
2013-07-24 08:05:41 +04:00
|
|
|
OPAL_PMI_ERROR(rc, "PMI2_Nameserv_unpublish");
|
2011-10-18 00:51:22 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2011-10-21 08:54:38 +04:00
|
|
|
#endif
|
2011-10-18 00:51:22 +04:00
|
|
|
return OMPI_SUCCESS;;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* finalize the module
|
|
|
|
*/
|
|
|
|
static int finalize(void)
|
|
|
|
{
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* instantiate the module
|
|
|
|
*/
|
|
|
|
ompi_pubsub_base_module_t ompi_pubsub_pmi_module = {
|
|
|
|
init,
|
|
|
|
publish,
|
|
|
|
unpublish,
|
|
|
|
lookup,
|
|
|
|
finalize
|
|
|
|
};
|