root/opal/runtime/opal_params.c

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

DEFINITIONS

This source file includes following definitions.
  1. opal_deregister_params
  2. opal_register_params

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2014 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) 2006      Los Alamos National Security, LLC.  All rights
  14  *                         reserved.
  15  * Copyright (c) 2008-2015 Cisco Systems, Inc.  All rights reserved.
  16  * Copyright (c) 2009      Oak Ridge National Labs.  All rights reserved.
  17  * Copyright (c) 2010-2014 Los Alamos National Security, LLC.
  18  *                         All rights reserved.
  19  * Copyright (c) 2014      Hochschule Esslingen.  All rights reserved.
  20  * Copyright (c) 2015      Research Organization for Information Science
  21  *                         and Technology (RIST). All rights reserved.
  22  * Copyright (c) 2015      Mellanox Technologies, Inc.
  23  *                         All rights reserved.
  24  * Copyright (c) 2017      IBM Corporation.  All rights reserved.
  25  * Copyright (c) 2018      Amazon.com, Inc. or its affiliates.  All Rights reserved.
  26  * $COPYRIGHT$
  27  *
  28  * Additional copyrights may follow
  29  *
  30  * $HEADER$
  31  */
  32 
  33 #include "opal_config.h"
  34 
  35 #include <time.h>
  36 #include <signal.h>
  37 
  38 #include "opal/constants.h"
  39 #include "opal/runtime/opal.h"
  40 #include "opal/datatype/opal_datatype.h"
  41 #include "opal/mca/base/mca_base_var.h"
  42 #include "opal/threads/mutex.h"
  43 #include "opal/threads/threads.h"
  44 #include "opal/mca/shmem/base/base.h"
  45 #include "opal/mca/base/mca_base_var.h"
  46 #include "opal/runtime/opal_params.h"
  47 #include "opal/dss/dss.h"
  48 #include "opal/util/opal_environ.h"
  49 #include "opal/util/show_help.h"
  50 #include "opal/util/timings.h"
  51 #include "opal/util/printf.h"
  52 
  53 char *opal_signal_string = NULL;
  54 char *opal_stacktrace_output_filename = NULL;
  55 char *opal_net_private_ipv4 = NULL;
  56 char *opal_set_max_sys_limits = NULL;
  57 
  58 #if OPAL_ENABLE_TIMING
  59 char *opal_timing_sync_file = NULL;
  60 char *opal_timing_output = NULL;
  61 bool opal_timing_overhead = true;
  62 #endif
  63 
  64 bool opal_built_with_cuda_support = OPAL_INT_TO_BOOL(OPAL_CUDA_SUPPORT);
  65 bool opal_cuda_support = false;
  66 bool opal_warn_on_missing_libcuda = true;
  67 #if OPAL_ENABLE_FT_CR == 1
  68 bool opal_base_distill_checkpoint_ready = false;
  69 #endif
  70 
  71 /**
  72  * Globals imported from the OMPI layer.
  73  */
  74 int opal_leave_pinned = -1;
  75 bool opal_leave_pinned_pipeline = false;
  76 bool opal_abort_print_stack = false;
  77 int opal_abort_delay = 0;
  78 
  79 int opal_max_thread_in_progress = 1;
  80 
  81 static bool opal_register_done = false;
  82 
  83 static void opal_deregister_params (void)
  84 {
  85     /* The MCA variable system will be torn down shortly so reset the registered
  86      * flag. */
  87     opal_register_done = false;
  88 }
  89 
  90 int opal_register_params(void)
  91 {
  92     int ret;
  93     char *string = NULL;
  94 
  95     if (opal_register_done) {
  96         return OPAL_SUCCESS;
  97     }
  98 
  99     opal_register_done = true;
 100 
 101     /*
 102      * This string is going to be used in opal/util/stacktrace.c
 103      */
 104     {
 105         int j;
 106         int signals[] = {
 107 #ifdef SIGABRT
 108             SIGABRT,
 109 #endif
 110 #ifdef SIGBUS
 111             SIGBUS,
 112 #endif
 113 #ifdef SIGFPE
 114             SIGFPE,
 115 #endif
 116 #ifdef SIGSEGV
 117             SIGSEGV,
 118 #endif
 119             -1
 120         };
 121         for (j = 0 ; signals[j] != -1 ; ++j) {
 122             if (j == 0) {
 123                 opal_asprintf(&string, "%d", signals[j]);
 124             } else {
 125                 char *tmp;
 126                 opal_asprintf(&tmp, "%s,%d", string, signals[j]);
 127                 free(string);
 128                 string = tmp;
 129             }
 130         }
 131 
 132         opal_signal_string = string;
 133         ret = mca_base_var_register ("opal", "opal", NULL, "signal",
 134                                      "Comma-delimited list of integer signal numbers to Open MPI to attempt to intercept.  Upon receipt of the intercepted signal, Open MPI will display a stack trace and abort.  Open MPI will *not* replace signals if handlers are already installed by the time MPI_INIT is invoked.  Optionally append \":complain\" to any signal number in the comma-delimited list to make Open MPI complain if it detects another signal handler (and therefore does not insert its own).",
 135                                      MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 136                                      OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_LOCAL,
 137                                      &opal_signal_string);
 138         free (string);
 139         if (0 > ret) {
 140             return ret;
 141         }
 142     }
 143 
 144     /*
 145      * Where should the stack trace output be directed
 146      * This string is going to be used in opal/util/stacktrace.c
 147      */
 148     string = strdup("stderr");
 149     opal_stacktrace_output_filename = string;
 150     ret = mca_base_var_register ("opal", "opal", NULL, "stacktrace_output",
 151                                  "Specifies where the stack trace output stream goes.  "
 152                                  "Accepts one of the following: none (disabled), stderr (default), stdout, file[:filename].   "
 153                                  "If 'filename' is not specified, a default filename of 'stacktrace' is used.  "
 154                                  "The 'filename' is appended with either '.PID' or '.RANK.PID', if RANK is available.  "
 155                                  "The 'filename' can be an absolute path or a relative path to the current working directory.",
 156                                  MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 157                                  OPAL_INFO_LVL_3,
 158                                  MCA_BASE_VAR_SCOPE_LOCAL,
 159                                  &opal_stacktrace_output_filename);
 160     free (string);
 161     if (0 > ret) {
 162         return ret;
 163     }
 164 
 165 
 166 #if defined(HAVE_SCHED_YIELD)
 167     opal_progress_yield_when_idle = false;
 168     ret = mca_base_var_register ("opal", "opal", "progress", "yield_when_idle",
 169                                  "Yield the processor when waiting on progress",
 170                                  MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 171                                  OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_LOCAL,
 172                                  &opal_progress_yield_when_idle);
 173 #endif
 174 
 175 #if OPAL_ENABLE_DEBUG
 176     opal_progress_debug = false;
 177     ret = mca_base_var_register ("opal", "opal", "progress", "debug",
 178                                  "Set to non-zero to debug progress engine features",
 179                                  MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 180                                  OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_LOCAL,
 181                                  &opal_progress_debug);
 182     if (0 > ret) {
 183         return ret;
 184     }
 185 
 186     opal_debug_threads = false;
 187     ret = mca_base_var_register ("opal", "opal", "debug", "threads",
 188                                  "Debug thread usage within OPAL. Reports out "
 189                                  "when threads are acquired and released.",
 190                                  MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 191                                  OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_LOCAL,
 192                                  &opal_debug_threads);
 193     if (0 > ret) {
 194         return ret;
 195     }
 196 #endif
 197 
 198 #if OPAL_ENABLE_FT_CR == 1
 199     opal_base_distill_checkpoint_ready = false;
 200     ret = mca_base_var_register("opal", "opal", "base", "distill_checkpoint_ready",
 201                                 "Distill only those components that are Checkpoint Ready",
 202                                 MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 203                                 OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_LOCAL,
 204                                 &opal_base_distill_checkpoint_ready);
 205 
 206     if (0 > ret) {
 207         return ret;
 208     }
 209 #endif
 210 
 211     /* RFC1918 defines
 212        - 10.0.0./8
 213        - 172.16.0.0/12
 214        - 192.168.0.0/16
 215 
 216        RFC3330 also mentions
 217        - 169.254.0.0/16 for DHCP onlink iff there's no DHCP server
 218     */
 219     opal_net_private_ipv4 = "10.0.0.0/8;172.16.0.0/12;192.168.0.0/16;169.254.0.0/16";
 220     ret = mca_base_var_register ("opal", "opal", "net", "private_ipv4",
 221                                  "Semicolon-delimited list of CIDR notation entries specifying what networks are considered \"private\" (default value based on RFC1918 and RFC3330)",
 222                                  MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 223                                  OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_ALL_EQ,
 224                                  &opal_net_private_ipv4);
 225     if (0 > ret) {
 226         return ret;
 227     }
 228 
 229     opal_set_max_sys_limits = NULL;
 230     ret = mca_base_var_register ("opal", "opal", NULL, "set_max_sys_limits",
 231                                  "Set the specified system-imposed limits to the specified value, including \"unlimited\"."
 232                                  "Supported params: core, filesize, maxmem, openfiles, stacksize, maxchildren",
 233                                  MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 234                                  OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_ALL_EQ,
 235                                  &opal_set_max_sys_limits);
 236     if (0 > ret) {
 237         return ret;
 238     }
 239 
 240     ret = mca_base_var_register("opal", "opal", NULL, "built_with_cuda_support",
 241                                 "Whether CUDA GPU buffer support is built into library or not",
 242                                 MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_DEFAULT_ONLY,
 243                                 OPAL_INFO_LVL_4, MCA_BASE_VAR_SCOPE_CONSTANT,
 244                                 &opal_built_with_cuda_support);
 245     if (0 > ret) {
 246         return ret;
 247     }
 248 
 249     /* Current default is to enable CUDA support if it is built into library */
 250     opal_cuda_support = opal_built_with_cuda_support;
 251     ret = mca_base_var_register ("opal", "opal", NULL, "cuda_support",
 252                                  "Whether CUDA GPU buffer support is enabled or not",
 253                                  MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 254                                  OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_ALL_EQ,
 255                                  &opal_cuda_support);
 256     if (0 > ret) {
 257         return ret;
 258     }
 259 
 260     opal_warn_on_missing_libcuda = true;
 261     ret = mca_base_var_register ("opal", "opal", NULL, "warn_on_missing_libcuda",
 262                                  "Whether to print a message when CUDA support is enabled but libcuda is not found",
 263                                  MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 264                                  OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_ALL_EQ,
 265                                  &opal_warn_on_missing_libcuda);
 266     if (0 > ret) {
 267         return ret;
 268     }
 269 
 270     /* Leave pinned parameter */
 271     opal_leave_pinned = -1;
 272     ret = mca_base_var_register("ompi", "mpi", NULL, "leave_pinned",
 273                                 "Whether to use the \"leave pinned\" protocol or not.  Enabling this setting can help bandwidth performance when repeatedly sending and receiving large messages with the same buffers over RDMA-based networks (false = do not use \"leave pinned\" protocol, true = use \"leave pinned\" protocol, auto = allow network to choose at runtime).",
 274                                 MCA_BASE_VAR_TYPE_INT, &mca_base_var_enum_auto_bool, 0, 0,
 275                                 OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
 276                                 &opal_leave_pinned);
 277     mca_base_var_register_synonym(ret, "opal", "opal", NULL, "leave_pinned",
 278                                   MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
 279 
 280     opal_leave_pinned_pipeline = false;
 281     ret = mca_base_var_register("ompi", "mpi", NULL, "leave_pinned_pipeline",
 282                                 "Whether to use the \"leave pinned pipeline\" protocol or not.",
 283                                  MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
 284                                  OPAL_INFO_LVL_9,
 285                                  MCA_BASE_VAR_SCOPE_READONLY,
 286                                  &opal_leave_pinned_pipeline);
 287     mca_base_var_register_synonym(ret, "opal", "opal", NULL, "leave_pinned_pipeline",
 288                                   MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
 289 
 290     if (opal_leave_pinned > 0 && opal_leave_pinned_pipeline) {
 291         opal_leave_pinned_pipeline = 0;
 292         opal_show_help("help-opal-runtime.txt",
 293                        "mpi-params:leave-pinned-and-pipeline-selected",
 294                        true);
 295     }
 296 
 297     opal_warn_on_fork = true;
 298     (void) mca_base_var_register("ompi", "mpi", NULL, "warn_on_fork",
 299                                  "If nonzero, issue a warning if program forks under conditions that could cause system errors",
 300                                  MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
 301                                  OPAL_INFO_LVL_9,
 302                                  MCA_BASE_VAR_SCOPE_READONLY,
 303                                  &opal_warn_on_fork);
 304 
 305     opal_abort_delay = 0;
 306     ret = mca_base_var_register("opal", "opal", NULL, "abort_delay",
 307                                 "If nonzero, print out an identifying message when abort operation is invoked (hostname, PID of the process that called abort) and delay for that many seconds before exiting (a negative delay value means to never abort).  This allows attaching of a debugger before quitting the job.",
 308                                  MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 309                                  OPAL_INFO_LVL_5,
 310                                  MCA_BASE_VAR_SCOPE_READONLY,
 311                                  &opal_abort_delay);
 312     if (0 > ret) {
 313         return ret;
 314     }
 315 
 316     opal_abort_print_stack = false;
 317     ret = mca_base_var_register("opal", "opal", NULL, "abort_print_stack",
 318                                  "If nonzero, print out a stack trace when abort is invoked",
 319                                  MCA_BASE_VAR_TYPE_BOOL, NULL, 0,
 320                                 /* If we do not have stack trace
 321                                    capability, make this a constant
 322                                    MCA variable */
 323 #if OPAL_WANT_PRETTY_PRINT_STACKTRACE
 324                                  0,
 325                                  OPAL_INFO_LVL_5,
 326                                  MCA_BASE_VAR_SCOPE_READONLY,
 327 #else
 328                                  MCA_BASE_VAR_FLAG_DEFAULT_ONLY,
 329                                  OPAL_INFO_LVL_5,
 330                                  MCA_BASE_VAR_SCOPE_CONSTANT,
 331 #endif
 332                                  &opal_abort_print_stack);
 333     if (0 > ret) {
 334         return ret;
 335     }
 336 
 337     /* register the envar-forwarding params */
 338     (void)mca_base_var_register ("opal", "mca", "base", "env_list",
 339                                  "Set SHELL env variables",
 340                                  MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
 341                                  MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list);
 342 
 343     mca_base_env_list_sep = MCA_BASE_ENV_LIST_SEP_DEFAULT;
 344     (void)mca_base_var_register ("opal", "mca", "base", "env_list_delimiter",
 345                                  "Set SHELL env variables delimiter. Default: semicolon ';'",
 346                                  MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
 347                                  MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_sep);
 348 
 349     /* Set OMPI_MCA_mca_base_env_list variable, it might not be set before
 350      * if mca variable was taken from amca conf file. Need to set it
 351      * here because mca_base_var_process_env_list is called from schizo_ompi.c
 352      * only when this env variable was set.
 353      */
 354     if (NULL != mca_base_env_list) {
 355         char *name = NULL;
 356         (void) mca_base_var_env_name ("mca_base_env_list", &name);
 357         if (NULL != name) {
 358             opal_setenv(name, mca_base_env_list, false, &environ);
 359             free(name);
 360         }
 361     }
 362 
 363     /* Register internal MCA variable mca_base_env_list_internal. It can be set only during
 364      * parsing of amca conf file and contains SHELL env variables specified via -x there.
 365      * Its format is the same as for mca_base_env_list.
 366      */
 367     (void)mca_base_var_register ("opal", "mca", "base", "env_list_internal",
 368             "Store SHELL env variables from amca conf file",
 369             MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_INTERNAL, OPAL_INFO_LVL_3,
 370             MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_internal);
 371 
 372     /* Number of threads allowed in opal_progress. This might increase multithreaded performance. */
 373     (void)mca_base_var_register ("opal", "opal", NULL, "max_thread_in_progress",
 374             "Number of thread allowed in opal_progress. Default: 1",
 375             MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, OPAL_INFO_LVL_8,
 376             MCA_BASE_VAR_SCOPE_READONLY, &opal_max_thread_in_progress);
 377 
 378     /* The ddt engine has a few parameters */
 379     ret = opal_datatype_register_params();
 380     if (OPAL_SUCCESS != ret) {
 381         return ret;
 382     }
 383 
 384     /* dss has parameters */
 385     ret = opal_dss_register_vars ();
 386     if (OPAL_SUCCESS != ret) {
 387         return ret;
 388     }
 389 
 390     opal_finalize_register_cleanup (opal_deregister_params);
 391 
 392     return OPAL_SUCCESS;
 393 }

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