This source file includes following definitions.
- MPI_Publish_name
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  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/show_help.h"
  31 
  32 #include "ompi/mpi/c/bindings.h"
  33 #include "ompi/runtime/params.h"
  34 #include "ompi/errhandler/errhandler.h"
  35 #include "ompi/info/info.h"
  36 #include "ompi/communicator/communicator.h"
  37 
  38 #if OMPI_BUILD_MPI_PROFILING
  39 #if OPAL_HAVE_WEAK_SYMBOLS
  40 #pragma weak MPI_Publish_name = PMPI_Publish_name
  41 #endif
  42 #define MPI_Publish_name PMPI_Publish_name
  43 #endif
  44 
  45 static const char FUNC_NAME[] = "MPI_Publish_name";
  46 
  47 
  48 int MPI_Publish_name(const char *service_name, MPI_Info info,
  49                      const char *port_name)
  50 {
  51     int rc;
  52     char range[OPAL_MAX_INFO_VAL];
  53     int flag=0;
  54     opal_value_t *rng;
  55     opal_list_t values;
  56 
  57     if ( MPI_PARAM_CHECK ) {
  58         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  59 
  60         if ( NULL == port_name || 0 == strlen(port_name) ) {
  61             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  62                                           FUNC_NAME);
  63         }
  64         if ( NULL == service_name || 0 == strlen(service_name) ) {
  65             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  66                                           FUNC_NAME);
  67         }
  68         if (NULL == info || ompi_info_is_freed(info)) {
  69             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO,
  70                                           FUNC_NAME);
  71         }
  72     }
  73 
  74     if (NULL == opal_pmix.publish) {
  75         opal_show_help("help-mpi-api.txt",
  76                        "MPI function not supported",
  77                        true,
  78                        FUNC_NAME,
  79                        "Underlying runtime environment does not support name publishing functionality");
  80         return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
  81                                       OMPI_ERR_NOT_SUPPORTED,
  82                                         FUNC_NAME);
  83     }
  84 
  85     OPAL_CR_ENTER_LIBRARY();
  86     OBJ_CONSTRUCT(&values, opal_list_t);
  87 
  88     
  89 
  90     if (MPI_INFO_NULL != info) {
  91         ompi_info_get (info, "range", sizeof(range) - 1, range, &flag);
  92         if (flag) {
  93             if (0 == strcmp(range, "nspace")) {
  94                 rng = OBJ_NEW(opal_value_t);
  95                 rng->key = strdup(OPAL_PMIX_RANGE);
  96                 rng->type = OPAL_INT;
  97                 rng->data.integer = OPAL_PMIX_RANGE_NAMESPACE;  
  98                 opal_list_append(&values, &rng->super);
  99             } else if (0 == strcmp(range, "session")) {
 100                 rng = OBJ_NEW(opal_value_t);
 101                 rng->key = strdup(OPAL_PMIX_RANGE);
 102                 rng->type = OPAL_INT;
 103                 rng->data.integer = OPAL_PMIX_RANGE_SESSION; 
 104                 opal_list_append(&values, &rng->super);
 105             } else {
 106                 
 107                 OPAL_LIST_DESTRUCT(&values);
 108                 OPAL_CR_EXIT_LIBRARY();
 109                 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
 110                                             FUNC_NAME);
 111             }
 112         }
 113         ompi_info_get (info, "persistence", sizeof(range) - 1, range, &flag);
 114         if (flag) {
 115             if (0 == strcmp(range, "indef")) {
 116                 rng = OBJ_NEW(opal_value_t);
 117                 rng->key = strdup(OPAL_PMIX_PERSISTENCE);
 118                 rng->type = OPAL_INT;
 119                 rng->data.integer = OPAL_PMIX_PERSIST_INDEF;   
 120                 opal_list_append(&values, &rng->super);
 121             } else if (0 == strcmp(range, "proc")) {
 122                 rng = OBJ_NEW(opal_value_t);
 123                 rng->key = strdup(OPAL_PMIX_PERSISTENCE);
 124                 rng->type = OPAL_INT;
 125                 rng->data.integer = OPAL_PMIX_PERSIST_PROC;    
 126                 opal_list_append(&values, &rng->super);
 127             } else if (0 == strcmp(range, "app")) {
 128                 rng = OBJ_NEW(opal_value_t);
 129                 rng->key = strdup(OPAL_PMIX_PERSISTENCE);
 130                 rng->type = OPAL_INT;
 131                 rng->data.integer = OPAL_PMIX_PERSIST_APP;     
 132                 opal_list_append(&values, &rng->super);
 133             } else if (0 == strcmp(range, "session")) {
 134                 rng = OBJ_NEW(opal_value_t);
 135                 rng->key = strdup(OPAL_PMIX_PERSISTENCE);
 136                 rng->type = OPAL_INT;
 137                 rng->data.integer = OPAL_PMIX_PERSIST_SESSION; 
 138                 opal_list_append(&values, &rng->super);
 139             } else {
 140                 
 141                 OPAL_LIST_DESTRUCT(&values);
 142                 OPAL_CR_EXIT_LIBRARY();
 143                 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
 144                                             FUNC_NAME);
 145             }
 146         }
 147     }
 148 
 149     
 150     rng = OBJ_NEW(opal_value_t);
 151     rng->key = strdup(service_name);
 152     rng->type = OPAL_STRING;
 153     rng->data.string = strdup(port_name);
 154     opal_list_append(&values, &rng->super);
 155 
 156     rc = opal_pmix.publish(&values);
 157     OPAL_LIST_DESTRUCT(&values);
 158 
 159     OPAL_CR_EXIT_LIBRARY();
 160     if ( OPAL_SUCCESS != rc ) {
 161         if (OPAL_EXISTS == rc) {
 162             
 163             rc = MPI_ERR_FILE_EXISTS;
 164         } else if (OPAL_ERR_NOT_SUPPORTED == rc) {
 165             
 166             rc = OMPI_ERR_NOT_SUPPORTED;
 167             opal_show_help("help-mpi-api.txt",
 168                            "MPI function not supported",
 169                            true,
 170                            FUNC_NAME,
 171                            "Underlying runtime environment does not support name publishing functionality");
 172         } else {
 173             rc = MPI_ERR_INTERN;
 174         }
 175 
 176         return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, rc, FUNC_NAME);
 177     }
 178 
 179     return MPI_SUCCESS;
 180 }