1
1
openmpi/opal/util/sys_limits.c
Nathan Hjelm cf377db823 MCA/base: Add new MCA variable system
Features:
 - Support for an override parameter file (openmpi-mca-param-override.conf).
   Variable values in this file can not be overridden by any file or environment
   value.
 - Support for boolean, unsigned, and unsigned long long variables.
 - Support for true/false values.
 - Support for enumerations on integer variables.
 - Support for MPIT scope, verbosity, and binding.
 - Support for command line source.
 - Support for setting variable source via the environment using
   OMPI_MCA_SOURCE_<var name>=source (either command or file:filename)
 - Cleaner API.
 - Support for variable groups (equivalent to MPIT categories).

Notes:
 - Variables must be created with a backing store (char **, int *, or bool *)
   that must live at least as long as the variable.
 - Creating a variable with the MCA_BASE_VAR_FLAG_SETTABLE enables the use of
   mca_base_var_set_value() to change the value.
 - String values are duplicated when the variable is registered. It is up to
   the caller to free the original value if necessary. The new value will be
   freed by the mca_base_var system and must not be freed by the user.
 - Variables with constant scope may not be settable.
 - Variable groups (and all associated variables) are deregistered when the
   component is closed or the component repository item is freed. This
   prevents a segmentation fault from accessing a variable after its component
   is unloaded.
 - After some discussion we decided we should remove the automatic registration
   of component priority variables. Few component actually made use of this
   feature.
 - The enumerator interface was updated to be general enough to handle
   future uses of the interface.
 - The code to generate ompi_info output has been moved into the MCA variable
   system. See mca_base_var_dump().

opal: update core and components to mca_base_var system
orte: update core and components to mca_base_var system
ompi: update core and components to mca_base_var system

This commit also modifies the rmaps framework. The following variables were
moved from ppr and lama: rmaps_base_pernode, rmaps_base_n_pernode,
rmaps_base_n_persocket. Both lama and ppr create synonyms for these variables.

This commit was SVN r28236.
2013-03-27 21:09:41 +00:00

104 строки
3.1 KiB
C

/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
* This file is only here because some platforms have a broken strncpy
* (e.g., Itanium with RedHat Advanced Server glibc).
*/
#include "opal_config.h"
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <errno.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#include "opal/constants.h"
#include "opal/runtime/opal_params.h"
#include "opal/util/sys_limits.h"
#include "opal/util/output.h"
/*
* Create and initialize storage for the system limits
*/
OPAL_DECLSPEC opal_sys_limits_t opal_sys_limits = {
/* initialized = */ false,
/* num_files = */ -1,
/* num_procs = */ -1,
/* file_size = */ 0
};
int opal_util_init_sys_limits(void)
{
struct rlimit rlim, rlim_set;
/* get/set the system limits on number of files we can have open */
if (0 <= getrlimit (RLIMIT_NOFILE, &rlim)) {
if (opal_set_max_sys_limits) {
rlim_set.rlim_cur = rlim.rlim_max;
rlim_set.rlim_max = rlim.rlim_max;
if (0 <= setrlimit (RLIMIT_NOFILE, &rlim_set)) {
rlim.rlim_cur = rlim.rlim_max;
}
}
opal_sys_limits.num_files = rlim.rlim_cur;
}
#if HAVE_DECL_RLIMIT_NPROC
/* get/set the system limits on number of child procs we can have open */
if (0 <= getrlimit (RLIMIT_NPROC, &rlim)) {
if (opal_set_max_sys_limits) {
rlim_set.rlim_cur = rlim.rlim_max;
rlim_set.rlim_max = rlim.rlim_max;
if (0 <= setrlimit (RLIMIT_NPROC, &rlim_set)) {
rlim.rlim_cur = rlim.rlim_max;
}
}
opal_sys_limits.num_procs = rlim.rlim_cur;
}
#endif
/* get/set the system limits on max file size we can create */
if (0 <= getrlimit (RLIMIT_FSIZE, &rlim)) {
if (opal_set_max_sys_limits) {
rlim_set.rlim_cur = rlim.rlim_max;
rlim_set.rlim_max = rlim.rlim_max;
if (0 <= setrlimit (RLIMIT_FSIZE, &rlim_set)) {
rlim.rlim_cur = rlim.rlim_max;
}
}
opal_sys_limits.file_size = rlim.rlim_cur;
}
/* indicate we initialized the limits structure */
opal_sys_limits.initialized = true;
return OPAL_SUCCESS;
}