2013-09-27 01:56:20 +04:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
2004-01-26 02:03:40 +03:00
|
|
|
/*
|
2007-03-17 02:11:45 +03:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2005-11-05 22:57:48 +03:00
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2015-06-24 06:59:57 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2013-09-27 01:56:20 +04:00
|
|
|
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
|
|
|
|
* reserved.
|
2016-06-02 02:34:03 +03:00
|
|
|
* Copyright (c) 2015-2016 Intel, Inc. All rights reserved.
|
2015-09-09 10:30:26 +03:00
|
|
|
* Copyright (c) 2015 Research Organization for Information Science
|
|
|
|
* and Technology (RIST). All rights reserved.
|
2016-06-02 02:34:03 +03:00
|
|
|
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2004-01-26 02:03:40 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-26 02:03:40 +03:00
|
|
|
|
2015-06-18 19:53:20 +03:00
|
|
|
#include "opal/class/opal_list.h"
|
|
|
|
#include "opal/mca/pmix/pmix.h"
|
2015-10-07 01:07:07 +03:00
|
|
|
#include "opal/util/show_help.h"
|
2015-06-18 19:53:20 +03:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mpi/c/bindings.h"
|
2009-04-29 05:32:14 +04:00
|
|
|
#include "ompi/runtime/params.h"
|
|
|
|
#include "ompi/errhandler/errhandler.h"
|
2005-09-12 13:17:44 +04:00
|
|
|
#include "ompi/info/info.h"
|
|
|
|
#include "ompi/communicator/communicator.h"
|
2004-01-26 02:03:40 +03:00
|
|
|
|
2015-08-31 03:36:02 +03:00
|
|
|
#if OMPI_BUILD_MPI_PROFILING
|
|
|
|
#if OPAL_HAVE_WEAK_SYMBOLS
|
2004-01-26 02:03:40 +03:00
|
|
|
#pragma weak MPI_Lookup_name = PMPI_Lookup_name
|
|
|
|
#endif
|
2015-09-09 10:30:26 +03:00
|
|
|
#define MPI_Lookup_name PMPI_Lookup_name
|
2004-04-20 22:50:43 +04:00
|
|
|
#endif
|
|
|
|
|
2004-07-30 06:58:53 +04:00
|
|
|
static const char FUNC_NAME[] = "MPI_Lookup_name";
|
2004-06-23 00:21:35 +04:00
|
|
|
|
|
|
|
|
2013-09-27 01:56:20 +04:00
|
|
|
int MPI_Lookup_name(const char *service_name, MPI_Info info, char *port_name)
|
2004-06-16 05:41:01 +04:00
|
|
|
{
|
2015-06-18 19:53:20 +03:00
|
|
|
char range[OPAL_MAX_INFO_VAL];
|
|
|
|
int flag=0, ret;
|
2015-09-04 18:29:09 +03:00
|
|
|
opal_value_t *rng;
|
|
|
|
opal_list_t results, pinfo;
|
2015-06-18 19:53:20 +03:00
|
|
|
opal_pmix_pdata_t *pdat;
|
2004-06-17 01:35:31 +04:00
|
|
|
|
2004-06-16 05:41:01 +04:00
|
|
|
if ( MPI_PARAM_CHECK ) {
|
2015-06-24 06:59:57 +03:00
|
|
|
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
2004-06-18 23:02:52 +04:00
|
|
|
|
2004-07-30 06:58:53 +04:00
|
|
|
if ( NULL == port_name ) {
|
2015-06-24 06:59:57 +03:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
|
2004-06-23 00:21:35 +04:00
|
|
|
FUNC_NAME);
|
2004-07-30 06:58:53 +04:00
|
|
|
}
|
|
|
|
if ( NULL == service_name ) {
|
2015-06-24 06:59:57 +03:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
|
2004-06-23 00:21:35 +04:00
|
|
|
FUNC_NAME);
|
2004-07-30 06:58:53 +04:00
|
|
|
}
|
2004-08-12 20:56:24 +04:00
|
|
|
if (NULL == info || ompi_info_is_freed(info)) {
|
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO,
|
|
|
|
FUNC_NAME);
|
|
|
|
}
|
2004-06-16 05:41:01 +04:00
|
|
|
}
|
|
|
|
|
2015-10-07 01:07:07 +03:00
|
|
|
if (NULL == opal_pmix.lookup) {
|
|
|
|
opal_show_help("help-mpi-api.txt",
|
|
|
|
"MPI function not supported",
|
|
|
|
true,
|
|
|
|
FUNC_NAME,
|
|
|
|
"Underlying runtime environment does not support name lookup functionality");
|
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
|
|
|
|
OMPI_ERR_NOT_SUPPORTED,
|
|
|
|
FUNC_NAME);
|
|
|
|
}
|
|
|
|
|
2008-02-20 01:15:52 +03:00
|
|
|
OPAL_CR_ENTER_LIBRARY();
|
|
|
|
|
2015-09-04 18:29:09 +03:00
|
|
|
OBJ_CONSTRUCT(&pinfo, opal_list_t);
|
|
|
|
|
2015-06-18 19:53:20 +03:00
|
|
|
/* OMPI supports info keys to pass the range to
|
|
|
|
* be searched for the given key */
|
|
|
|
if (MPI_INFO_NULL != info) {
|
|
|
|
ompi_info_get (info, "range", sizeof(range) - 1, range, &flag);
|
|
|
|
if (flag) {
|
|
|
|
if (0 == strcmp(range, "nspace")) {
|
2015-09-04 18:29:09 +03:00
|
|
|
rng = OBJ_NEW(opal_value_t);
|
|
|
|
rng->key = strdup(OPAL_PMIX_RANGE);
|
|
|
|
rng->type = OPAL_INT;
|
2016-06-02 02:34:03 +03:00
|
|
|
rng->data.integer = OPAL_PMIX_RANGE_NAMESPACE; // share only with procs in same nspace
|
2015-09-04 18:29:09 +03:00
|
|
|
opal_list_append(&pinfo, &rng->super);
|
2015-06-18 19:53:20 +03:00
|
|
|
} else if (0 == strcmp(range, "session")) {
|
2015-09-04 18:29:09 +03:00
|
|
|
rng = OBJ_NEW(opal_value_t);
|
|
|
|
rng->key = strdup(OPAL_PMIX_RANGE);
|
|
|
|
rng->type = OPAL_INT;
|
2016-06-02 02:34:03 +03:00
|
|
|
rng->data.integer = OPAL_PMIX_RANGE_SESSION; // share only with procs in same session
|
2015-09-04 18:29:09 +03:00
|
|
|
opal_list_append(&pinfo, &rng->super);
|
2015-06-18 19:53:20 +03:00
|
|
|
} else {
|
|
|
|
/* unrecognized scope */
|
2015-09-04 18:29:09 +03:00
|
|
|
OPAL_LIST_DESTRUCT(&pinfo);
|
2015-10-13 20:57:33 +03:00
|
|
|
OPAL_CR_EXIT_LIBRARY();
|
2015-06-18 19:53:20 +03:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
|
|
|
|
FUNC_NAME);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* collect the findings */
|
|
|
|
OBJ_CONSTRUCT(&results, opal_list_t);
|
|
|
|
pdat = OBJ_NEW(opal_pmix_pdata_t);
|
2015-08-31 06:54:45 +03:00
|
|
|
pdat->value.key = strdup(service_name);
|
2015-06-18 19:53:20 +03:00
|
|
|
opal_list_append(&results, &pdat->super);
|
|
|
|
|
2015-09-04 18:29:09 +03:00
|
|
|
ret = opal_pmix.lookup(&results, &pinfo);
|
|
|
|
OPAL_LIST_DESTRUCT(&pinfo);
|
2015-06-18 19:53:20 +03:00
|
|
|
if (OPAL_SUCCESS != ret ||
|
|
|
|
OPAL_STRING != pdat->value.type ||
|
|
|
|
NULL == pdat->value.data.string) {
|
2015-10-07 01:07:07 +03:00
|
|
|
if (OPAL_ERR_NOT_SUPPORTED == ret) {
|
|
|
|
ret = OMPI_ERR_NOT_SUPPORTED;
|
|
|
|
opal_show_help("help-mpi-api.txt",
|
|
|
|
"MPI function not supported",
|
|
|
|
true,
|
|
|
|
FUNC_NAME,
|
|
|
|
"Underlying runtime environment does not support name lookup functionality");
|
|
|
|
} else {
|
|
|
|
ret = MPI_ERR_NAME;
|
|
|
|
}
|
|
|
|
|
2015-10-13 20:57:33 +03:00
|
|
|
OPAL_CR_EXIT_LIBRARY();
|
2015-10-07 01:07:07 +03:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, ret, FUNC_NAME);
|
2004-06-17 01:35:31 +04:00
|
|
|
}
|
|
|
|
|
2015-06-18 19:53:20 +03:00
|
|
|
strncpy ( port_name, pdat->value.data.string, MPI_MAX_PORT_NAME );
|
|
|
|
OPAL_LIST_DESTRUCT(&results);
|
2008-02-20 01:15:52 +03:00
|
|
|
|
|
|
|
OPAL_CR_EXIT_LIBRARY();
|
2004-01-26 02:03:40 +03:00
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|