Resources Module

This module detects and returns system resources

class resources.resources.Resources(libE_specs, top_level_dir=None)

Provides system resources to libEnsemble and executor.

A resources instance is always initialized unless libE_specs['disable_resource_manager'] is True.

Class Attributes:

Variables

Resources – resources: The resources object is stored here and can be retrieved in user functions.

Object Attributes:

These are set on initialization.

Variables
  • top_level_dir (string) – Directory where searches for node_list file.

  • glob_resources (GlobalResources) – Maintains resources available to libEnsemble.

The following are set up after manager/worker fork.

The resource manager is set up only on the manaager, while the worker resources object is set up on workers.

Variables
  • resource_manager (ResourceManager) – An object that manages resource set assignment to workers.

  • worker_resources (WorkerResources) – An object that contains worker specific resources.

__init__(libE_specs, top_level_dir=None)

Initiate a new resources object

classmethod init_resources(libE_specs)

Initiate resource management

set_worker_resources(num_workers, workerid)

Initiate the worker resources component of resources

set_resource_manager(num_workers)

Initiate the resource manager component of resources

add_comm_info(libE_nodes)

Adds comms-specific information to resources

Removes libEnsemble nodes from nodelist if in dedicated_mode.

class resources.resources.GlobalResources(libE_specs, top_level_dir=None)

Object Attributes:

These are set on initialization. :ivar string top_level_dir: Directory where searches for node_list file :ivar EnvResources env_resources: Object storing environment variables used by resources :ivar list global_nodelist: list of all nodes available for running user applications :ivar int logical_cores_avail_per_node: Logical cores (including SMT threads) available on a node :ivar int physical_cores_avail_per_node: Physical cores available on a node :ivar list zero_resource_workers: List of workerIDs to have no resources. :ivar boolean dedicated_mode: Whether to remove libE nodes from global nodelist. :ivar int num_resource_sets: Number of resource sets, if supplied by the user.

__init__(libE_specs, top_level_dir=None)

Initializes a new Resources instance

Determines the compute resources available for current allocation, including node list and cores/hardware threads available within nodes.

The following parameters may be extracted from libE_specs

Parameters
  • top_level_dir (string, optional) – Directory libEnsemble runs in (default is current working directory)

  • dedicated_mode (boolean, optional) – If true, then dedicate nodes to running libEnsemble. Dedicated mode means that any nodes running libE processes (manager and workers), will not be available to worker launched tasks (user applications). They will be removed from the nodelist (if present), before dividing into resource sets.

  • zero_resource_workers (list of ints, optional) – List of workers that require no resources.

  • num_resource_sets (int, optional) – The total number of resource sets. Resources will be divided into this number. Default: None. If None, resources will be divided by workers (excluding zero_resource_workers).

  • cores_on_node (tuple (int,int), optional) – If supplied gives (physical cores, logical cores) for the nodes. If not supplied, this will be auto-detected.

  • enforce_worker_core_bounds (boolean, optional) – If True, then libEnsemble’s executor will raise an exception if it detects that a worker has been instructed to launch tasks with the number of requested processes being excessive to the number of cores allocated to that worker, or not enough processes were requested to satisfy allocated cores.

  • node_file (String, optional) – If supplied, give the name of a file in the run directory to use as a node-list for use by libEnsemble. Defaults to a file named ‘node_list’. If the file does not exist, then the node-list will be auto-detected.

  • nodelist_env_slurm (String, optional) – The environment variable giving a node list in Slurm format (Default: uses SLURM_NODELIST). Note: This is queried only if a node_list file is not provided.

  • nodelist_env_cobalt (String, optional) – The environment variable giving a node list in Cobalt format (Default: uses COBALT_PARTNAME). Note: This is queried only if a node_list file is not provided.

  • nodelist_env_lsf (String, optional) – The environment variable giving a node list in LSF format (Default: uses LSB_HOSTS). Note: This is queried only if a node_list file is not provided.

  • nodelist_env_lsf_shortform (String, optional) – The environment variable giving a node list in LSF short-form format (Default: uses LSB_MCPU_HOSTS) Note: This is only queried if a node_list file is not provided.

add_comm_info(libE_nodes)

Adds comms-specific information to resources

Removes libEnsemble nodes from nodelist if in dedicated_mode.

static is_nodelist_shortnames(nodelist)

Returns True if any entry contains a ‘.’, else False

static remove_nodes(global_nodelist_in, remove_list)

Removes any nodes in remove_list from the global nodelist

static get_global_nodelist(node_file='node_list', rundir=None, env_resources=None)

Returns the list of nodes available to all libEnsemble workers.

If a node_file exists this is used, otherwise the environment is interrogated for a node list. If a dedicated manager node is used, then a node_file is recommended.

In central mode, any node with a libE worker is removed from the list.