This source file includes following definitions.
- ompi_mpiinfo_init
- ompi_info_dup
- ompi_info_dup_mpistandard
- ompi_info_set
- ompi_info_set_value_enum
- ompi_info_get
- ompi_info_get_value_enum
- ompi_info_get_bool
- ompi_info_delete
- ompi_info_get_valuelen
- ompi_info_get_nthkey
- ompi_info_get_nkeys
- ompi_mpiinfo_finalize
- info_constructor
- info_destructor
- ompi_info_free
   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 
  26 
  27 #include "ompi_config.h"
  28 #include "ompi/constants.h"
  29 
  30 #include <string.h>
  31 #include <errno.h>
  32 #include <stdlib.h>
  33 #ifdef HAVE_UNISTD_H
  34 #include <unistd.h>
  35 #endif
  36 #include <limits.h>
  37 #include <ctype.h>
  38 #ifdef HAVE_SYS_UTSNAME_H
  39 #include <sys/utsname.h>
  40 #endif
  41 #include <assert.h>
  42 
  43 #include "opal/util/argv.h"
  44 #include "opal/util/opal_getcwd.h"
  45 #include "opal/util/output.h"
  46 #include "opal/util/info.h"
  47 
  48 #include "ompi/info/info.h"
  49 #include "ompi/runtime/mpiruntime.h"
  50 #include "ompi/runtime/params.h"
  51 
  52 
  53 
  54 
  55 ompi_predefined_info_t ompi_mpi_info_null = {{{{{0}}}}};
  56 ompi_predefined_info_t *ompi_mpi_info_null_addr = &ompi_mpi_info_null;
  57 ompi_predefined_info_t ompi_mpi_info_env = {{{{{0}}}}};
  58 
  59 
  60 
  61 
  62 static void info_constructor(ompi_info_t *info);
  63 static void info_destructor(ompi_info_t *info);
  64 
  65 
  66 
  67 
  68 OBJ_CLASS_INSTANCE(ompi_info_t,
  69                    opal_info_t,
  70                    info_constructor,
  71                    info_destructor);
  72 
  73 
  74 
  75 
  76 opal_pointer_array_t ompi_info_f_to_c_table = {{0}};
  77 
  78 
  79 
  80 
  81 
  82 
  83 int ompi_mpiinfo_init(void)
  84 {
  85     char val[OPAL_MAXHOSTNAMELEN];
  86     char *cptr;
  87 
  88     
  89 
  90     OBJ_CONSTRUCT(&ompi_info_f_to_c_table, opal_pointer_array_t);
  91     if( OPAL_SUCCESS != opal_pointer_array_init(&ompi_info_f_to_c_table, 0,
  92                                                 OMPI_FORTRAN_HANDLE_MAX, 16) ) {
  93         return OMPI_ERROR;
  94     }
  95 
  96     
  97     OBJ_CONSTRUCT(&ompi_mpi_info_null.info, ompi_info_t);
  98     assert(ompi_mpi_info_null.info.i_f_to_c_index == 0);
  99 
 100     
 101     OBJ_CONSTRUCT(&ompi_mpi_info_env.info, ompi_info_t);
 102     assert(ompi_mpi_info_env.info.i_f_to_c_index == 1);
 103 
 104     
 105 
 106     
 107     if (NULL != (cptr = getenv("OMPI_COMMAND"))) {
 108         opal_info_set(&ompi_mpi_info_env.info.super, "command", cptr);
 109     }
 110 
 111     
 112     if (NULL != (cptr = getenv("OMPI_ARGV"))) {
 113         opal_info_set(&ompi_mpi_info_env.info.super, "argv", cptr);
 114     }
 115 
 116     
 117     if (NULL != (cptr = getenv("OMPI_MCA_orte_ess_num_procs"))) {
 118         opal_info_set(&ompi_mpi_info_env.info.super, "maxprocs", cptr);
 119         
 120         opal_info_set(&ompi_mpi_info_env.info.super, "soft", cptr);
 121     }
 122 
 123     
 124     gethostname(val, sizeof(val));
 125     opal_info_set(&ompi_mpi_info_env.info.super, "host", val);
 126 
 127     
 128     if (NULL != (cptr = getenv("OMPI_MCA_orte_cpu_type"))) {
 129         opal_info_set(&ompi_mpi_info_env.info.super, "arch", cptr);
 130     }
 131 #ifdef HAVE_SYS_UTSNAME_H
 132     else {
 133         struct utsname sysname;
 134         uname(&sysname);
 135         cptr = sysname.machine;
 136         opal_info_set(&ompi_mpi_info_env.info.super, "arch", cptr);
 137     }
 138 #endif
 139 
 140     
 141 
 142 
 143 
 144     if (NULL != (cptr = getenv("OMPI_MCA_initial_wdir"))) {
 145         opal_info_set(&ompi_mpi_info_env.info.super, "wdir", cptr);
 146     }
 147 
 148     
 149 
 150 
 151     switch (ompi_mpi_thread_requested) {
 152     case MPI_THREAD_SINGLE:
 153         opal_info_set(&ompi_mpi_info_env.info.super, "thread_level", "MPI_THREAD_SINGLE");
 154         break;
 155     case MPI_THREAD_FUNNELED:
 156         opal_info_set(&ompi_mpi_info_env.info.super, "thread_level", "MPI_THREAD_FUNNELED");
 157         break;
 158     case MPI_THREAD_SERIALIZED:
 159         opal_info_set(&ompi_mpi_info_env.info.super, "thread_level", "MPI_THREAD_SERIALIZED");
 160         break;
 161     case MPI_THREAD_MULTIPLE:
 162         opal_info_set(&ompi_mpi_info_env.info.super, "thread_level", "MPI_THREAD_MULTIPLE");
 163         break;
 164     default:
 165         
 166         break;
 167     }
 168 
 169     
 170 
 171     
 172     if (NULL != (cptr = getenv("OMPI_NUM_APP_CTX"))) {
 173         opal_info_set(&ompi_mpi_info_env.info.super, "ompi_num_apps", cptr);
 174     }
 175 
 176     
 177     if (NULL != (cptr = getenv("OMPI_FIRST_RANKS"))) {
 178         opal_info_set(&ompi_mpi_info_env.info.super, "ompi_first_rank", cptr);
 179     }
 180 
 181     
 182     if (NULL != (cptr = getenv("OMPI_APP_CTX_NUM_PROCS"))) {
 183         opal_info_set(&ompi_mpi_info_env.info.super, "ompi_np", cptr);
 184     }
 185 
 186     
 187 
 188 
 189     if (NULL != (cptr = getenv("OMPI_FILE_LOCATION"))) {
 190         opal_info_set(&ompi_mpi_info_env.info.super, "ompi_positioned_file_dir", cptr);
 191     }
 192 
 193     
 194 
 195     return OMPI_SUCCESS;
 196 }
 197 
 198 
 199 
 200 
 201 
 202 
 203 
 204 int ompi_info_dup (ompi_info_t *info, ompi_info_t **newinfo) {
 205     return opal_info_dup (&(info->super), (opal_info_t **)newinfo);
 206 }
 207 int ompi_info_dup_mpistandard (ompi_info_t *info, ompi_info_t **newinfo) {
 208     return opal_info_dup_mpistandard (&(info->super), (opal_info_t **)newinfo);
 209 }
 210 int ompi_info_set (ompi_info_t *info, const char *key, const char *value) {
 211     return opal_info_set (&(info->super), key, value);
 212 }
 213 int ompi_info_set_value_enum (ompi_info_t *info, const char *key, int value,
 214                               mca_base_var_enum_t *var_enum)
 215 {
 216     return opal_info_set_value_enum (&(info->super), key, value, var_enum);
 217 }
 218 int ompi_info_get (ompi_info_t *info, const char *key, int valuelen,
 219                    char *value, int *flag)
 220 {
 221     return opal_info_get (&(info->super), key, valuelen, value, flag);
 222 }
 223 int ompi_info_get_value_enum (ompi_info_t *info, const char *key, int *value,
 224                               int default_value, mca_base_var_enum_t *var_enum,
 225                               int *flag)
 226 {
 227     return opal_info_get_value_enum (&(info->super), key, value,
 228                               default_value, var_enum, flag);
 229 }
 230 int ompi_info_get_bool(ompi_info_t *info, char *key, bool *value, int *flag) {
 231     return opal_info_get_bool(&(info->super), key, value, flag);
 232 }
 233 int ompi_info_delete (ompi_info_t *info, const char *key) {
 234     return opal_info_delete (&(info->super), key);
 235 }
 236 int ompi_info_get_valuelen (ompi_info_t *info, const char *key, int *valuelen,
 237                             int *flag)
 238 {
 239     return opal_info_get_valuelen (&(info->super), key, valuelen, flag);
 240 }
 241 int ompi_info_get_nthkey (ompi_info_t *info, int n, char *key) {
 242     return opal_info_get_nthkey (&(info->super), n, key);
 243 }
 244 int ompi_info_get_nkeys(ompi_info_t *info, int *nkeys)
 245 {
 246     return opal_info_get_nkeys (&(info->super), nkeys);
 247 }
 248 
 249 
 250 
 251 
 252 
 253 int ompi_mpiinfo_finalize(void)
 254 {
 255     size_t i, max;
 256     ompi_info_t *info;
 257     opal_list_item_t *item;
 258     opal_info_entry_t *entry;
 259     bool found = false;
 260 
 261     OBJ_DESTRUCT(&ompi_mpi_info_null);
 262     OBJ_DESTRUCT(&ompi_mpi_info_env);
 263 
 264     
 265 
 266 
 267     max = opal_pointer_array_get_size(&ompi_info_f_to_c_table);
 268     for (i = 2; i < max; ++i) {
 269         info = (ompi_info_t *)opal_pointer_array_get_item(&ompi_info_f_to_c_table, i);
 270 
 271         
 272 
 273 
 274 
 275 
 276         if (NULL != info && ompi_debug_no_free_handles && info->i_freed) {
 277             OBJ_RELEASE(info);
 278             info = (ompi_info_t *)opal_pointer_array_get_item(&ompi_info_f_to_c_table, i);
 279         }
 280 
 281         
 282 
 283 
 284         if (NULL != info) {
 285 
 286             
 287 
 288 
 289             if (!info->i_freed && ompi_debug_show_handle_leaks) {
 290                 if (ompi_debug_show_handle_leaks) {
 291                     opal_output(0, "WARNING: MPI_Info still allocated at MPI_FINALIZE");
 292 
 293                     for (item = opal_list_get_first(&info->super.super);
 294                          opal_list_get_end(&(info->super.super)) != item;
 295                          item = opal_list_get_next(item)) {
 296                         entry = (opal_info_entry_t *) item;
 297                         opal_output(0, "WARNING:   key=\"%s\", value=\"%s\"",
 298                                     entry->ie_key,
 299                                     NULL != entry->ie_value ? entry->ie_value : "(null)");
 300                         found = true;
 301                     }
 302                 }
 303                 OBJ_RELEASE(info);
 304             }
 305 
 306             
 307 
 308 
 309 
 310             if (!found && ompi_debug_show_handle_leaks) {
 311                 opal_output(0, "WARNING:   (no keys)");
 312             }
 313         }
 314     }
 315 
 316     
 317 
 318     OBJ_DESTRUCT(&ompi_info_f_to_c_table);
 319     return OPAL_SUCCESS;
 320 }
 321 
 322 
 323 
 324 
 325 
 326 
 327 
 328 static void info_constructor(ompi_info_t *info)
 329 {
 330     info->i_f_to_c_index = opal_pointer_array_add(&ompi_info_f_to_c_table,
 331                                                   info);
 332     info->i_freed = false;
 333 
 334 
 335 
 336 
 337 
 338     if (ompi_debug_no_free_handles) {
 339         OBJ_RETAIN(&(info->super));
 340     }
 341 }
 342 
 343 
 344 
 345 
 346 
 347 
 348 static void info_destructor(ompi_info_t *info)
 349 {
 350    
 351 
 352 
 353     if (MPI_UNDEFINED != info->i_f_to_c_index &&
 354         NULL != opal_pointer_array_get_item(&ompi_info_f_to_c_table,
 355                                             info->i_f_to_c_index)){
 356         opal_pointer_array_set_item(&ompi_info_f_to_c_table,
 357                                     info->i_f_to_c_index, NULL);
 358     }
 359 
 360 }
 361 
 362 
 363 
 364 
 365 
 366 int ompi_info_free (ompi_info_t **info)
 367 {
 368     (*info)->i_freed = true;
 369     OBJ_RELEASE(*info);
 370     *info = MPI_INFO_NULL;
 371     return MPI_SUCCESS;
 372 }