root/ompi/mpi/c/unpublish_name.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_Unpublish_name

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2012-2013 Los Alamos National Security, LLC.  All rights
  14  *                         reserved.
  15  * Copyright (c) 2015-2016 Intel, Inc. All rights reserved.
  16  * Copyright (c) 2015      Research Organization for Information Science
  17  *                         and Technology (RIST). All rights reserved.
  18  * Copyright (c) 2015      Cisco Systems, Inc.  All rights reserved.
  19  * $COPYRIGHT$
  20  *
  21  * Additional copyrights may follow
  22  *
  23  * $HEADER$
  24  */
  25 #include "ompi_config.h"
  26 #include <stdio.h>
  27 
  28 #include "opal/class/opal_list.h"
  29 #include "opal/mca/pmix/pmix.h"
  30 #include "opal/util/argv.h"
  31 #include "opal/util/show_help.h"
  32 
  33 #include "ompi/mpi/c/bindings.h"
  34 #include "ompi/runtime/params.h"
  35 #include "ompi/communicator/communicator.h"
  36 #include "ompi/errhandler/errhandler.h"
  37 #include "ompi/info/info.h"
  38 
  39 #if OMPI_BUILD_MPI_PROFILING
  40 #if OPAL_HAVE_WEAK_SYMBOLS
  41 #pragma weak MPI_Unpublish_name = PMPI_Unpublish_name
  42 #endif
  43 #define MPI_Unpublish_name PMPI_Unpublish_name
  44 #endif
  45 
  46 static const char FUNC_NAME[] = "MPI_Unpublish_name";
  47 
  48 
  49 int MPI_Unpublish_name(const char *service_name, MPI_Info info,
  50                        const char *port_name)
  51 {
  52     int rc;
  53     char range[OPAL_MAX_INFO_VAL];
  54     int flag=0;
  55     opal_list_t pinfo;
  56     opal_value_t *rng;
  57     char **keys = NULL;
  58 
  59     if ( MPI_PARAM_CHECK ) {
  60         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  61 
  62         if ( NULL == port_name ) {
  63             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  64                                           FUNC_NAME);
  65         }
  66         if ( NULL == service_name ) {
  67             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  68                                           FUNC_NAME);
  69         }
  70         if (NULL == info || ompi_info_is_freed(info)) {
  71             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO,
  72                                           FUNC_NAME);
  73         }
  74     }
  75 
  76     if (NULL == opal_pmix.publish) {
  77         opal_show_help("help-mpi-api.txt",
  78                        "MPI function not supported",
  79                        true,
  80                        FUNC_NAME,
  81                        "Underlying runtime environment does not support name publishing functionality");
  82         return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
  83                                       OMPI_ERR_NOT_SUPPORTED,
  84                                       FUNC_NAME);
  85     }
  86 
  87     OPAL_CR_ENTER_LIBRARY();
  88     OBJ_CONSTRUCT(&pinfo, opal_list_t);
  89 
  90     /* OMPI supports info keys to pass the range to
  91      * be searched for the given key */
  92     if (MPI_INFO_NULL != info) {
  93         ompi_info_get (info, "range", sizeof(range) - 1, range, &flag);
  94         if (flag) {
  95             if (0 == strcmp(range, "nspace")) {
  96                 rng = OBJ_NEW(opal_value_t);
  97                 rng->key = strdup(OPAL_PMIX_RANGE);
  98                 rng->type = OPAL_INT;
  99                 rng->data.integer = OPAL_PMIX_RANGE_NAMESPACE;  // share only with procs in same nspace
 100                 opal_list_append(&pinfo, &rng->super);
 101             } else if (0 == strcmp(range, "session")) {
 102                 rng = OBJ_NEW(opal_value_t);
 103                 rng->key = strdup(OPAL_PMIX_RANGE);
 104                 rng->type = OPAL_INT;
 105                 rng->data.integer = OPAL_PMIX_RANGE_SESSION; // share only with procs in same session
 106                 opal_list_append(&pinfo, &rng->super);
 107             } else {
 108                 /* unrecognized scope */
 109                 OPAL_LIST_DESTRUCT(&pinfo);
 110                 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
 111                                             FUNC_NAME);
 112             }
 113         }
 114     }
 115 
 116     /* unpublish the service_name */
 117     opal_argv_append_nosize(&keys, service_name);
 118 
 119     rc = opal_pmix.unpublish(keys, &pinfo);
 120     opal_argv_free(keys);
 121     OPAL_LIST_DESTRUCT(&pinfo);
 122 
 123     if ( OPAL_SUCCESS != rc ) {
 124         if (OPAL_ERR_NOT_FOUND == rc) {
 125             /* service couldn't be found */
 126             rc = MPI_ERR_SERVICE;
 127         } else if (OPAL_ERR_PERM == rc) {
 128             /* this process didn't own the specified service */
 129             rc = MPI_ERR_ACCESS;
 130         } else if (OPAL_ERR_NOT_SUPPORTED == rc) {
 131             /* this PMIX environment doesn't support publishing */
 132             rc = OMPI_ERR_NOT_SUPPORTED;
 133             opal_show_help("help-mpi-api.txt",
 134                            "MPI function not supported",
 135                            true,
 136                            FUNC_NAME,
 137                            "Underlying runtime environment does not support name publishing functionality");
 138         } else {
 139             rc = MPI_ERR_INTERN;
 140         }
 141 
 142         OPAL_CR_EXIT_LIBRARY();
 143         return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, rc, FUNC_NAME);
 144     }
 145 
 146     OPAL_CR_EXIT_LIBRARY();
 147     return MPI_SUCCESS;
 148 }

/* [<][>][^][v][top][bottom][index][help] */