Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically get cores_per_node on single node #357

Merged
merged 3 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions compass/machines/default.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# The parallel section describes options related to running tests in parallel
[parallel]

Expand All @@ -7,6 +6,3 @@ system = single_node

# whether to use mpirun or srun to run the model
parallel_executable = mpirun

# cores per node on the machine
cores_per_node = 4
10 changes: 8 additions & 2 deletions compass/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ def get_available_cores_and_nodes(config):
args = ['squeue', '--noheader', '-j', job_id, '-o', '%D']
nodes = _get_subprocess_int(args)
elif parallel_system == 'single_node':
cores_per_node = config.getint('parallel', 'cores_per_node')
cores = min(multiprocessing.cpu_count(), cores_per_node)
cores = multiprocessing.cpu_count()
if config.has_option('parallel', 'cores_per_node'):
cores_per_node = config.getint('parallel', 'cores_per_node')
cores = min(cores, cores_per_node)
nodes = 1
else:
raise ValueError('Unexpected parallel system: {}'.format(
Expand Down Expand Up @@ -90,6 +92,10 @@ def set_cores_per_node(config):
if old_cpus_per_node != cpus_per_node:
warnings.warn(f'Slurm found {cpus_per_node} cpus per node but '
f'config from mache was {old_cpus_per_node}')
elif parallel_system == 'single_node':
if not config.has_option('parallel', 'cores_per_node'):
cores = multiprocessing.cpu_count()
config.set('parallel', 'cores_per_node', f'{cores}')


def _get_subprocess_int(args):
Expand Down
9 changes: 3 additions & 6 deletions docs/users_guide/machines/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,10 @@ in your user config file:
system = single_node

# whether to use mpirun or srun to run the model
parallel_executable = mpirun
parallel_executable = mpirun -host localhost

# cores per node on the machine
cores_per_node = 4

# the number of multiprocessing or dask threads to use
threads = 4
# cores per node on the machine, detected automatically by default
# cores_per_node = 4

The paths for the MPAS core "databases" can be any emtpy path to begin with.
If the path doesn't exist, ``compass`` will create it.
Expand Down
13 changes: 5 additions & 8 deletions docs/users_guide/quick_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,17 @@ in the repository.
# whether to use mpirun or srun to run the model
parallel_executable = mpirun -host localhost

# cores per node on the machine
cores_per_node = 4

# the number of multiprocessing or dask threads to use
threads = 4
# cores per node on the machine, detected automatically by default
# cores_per_node = 4

The two ``*_database_root`` directories can point to locations where you would
like to download data for MALI and MPAS-Ocean. This data is downloaded only
once and cached for the next time you call ``compass setup`` or
``compass suite`` (see below).

The ``cores_per_node`` and ``threads`` config options should be the number of
CPUs on your computer. You can set this to a smaller number if you want
``compass``.
The ``cores_per_node`` config option will default to the number of CPUs on your
computer. You can set this to a smaller number if you want ``compass`` to
use fewer cores.

In order to run regression testing that compares the output of the current run
with that from a previous compass run, use ``-b <previous_workdir>`` to specify
Expand Down
7 changes: 2 additions & 5 deletions example_configs/landice.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ system = single_node
# whether to use mpirun or srun to run the model
parallel_executable = mpirun -host localhost

# cores per node on the machine
cores_per_node = 4

# the number of multiprocessing or dask threads to use
threads = 4
# cores per node on the machine, detected automatically by default
# cores_per_node = 4


# Options related to downloading files
Expand Down
7 changes: 2 additions & 5 deletions example_configs/ocean.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ system = single_node
# whether to use mpirun or srun to run the model
parallel_executable = mpirun -host localhost

# cores per node on the machine
cores_per_node = 4

# the number of multiprocessing or dask threads to use
threads = 4
# cores per node on the machine, detected automatically by default
# cores_per_node = 4


# Options related to downloading files
Expand Down