Skip to content

Commit

Permalink
Merge pull request #3085 from ESMCI/azamat/threading/dont-set-threads…
Browse files Browse the repository at this point in the history
…-for-mpi-only-runs

Omit OMP_NUM_THREADS in MPI-only runs

Test suite: SMS.f19_g16.X
Test baseline: mpi-only vs. threaded
Test namelist changes: none
Test status: [bit for bit]

Fixes #3082

User interface changes?: none

Update gh-pages html (Y/N)?: N
  • Loading branch information
jgfouca authored Jun 5, 2019
2 parents 5c43a15 + 26795a1 commit 89fad14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions scripts/lib/CIME/case/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ def initialize_derived_attributes(self):
threads_per_core = 1 if (threads_per_node <= max_mpitasks_per_node) else smt_factor
self.cores_per_task = self.thread_count / threads_per_core

os.environ["OMP_NUM_THREADS"] = str(self.thread_count)
if self.get_build_threaded():
os.environ["OMP_NUM_THREADS"] = str(self.thread_count)
elif "OMP_NUM_THREADS" in os.environ:
del os.environ["OMP_NUM_THREADS"]

self.srun_binding = smt_factor*max_mpitasks_per_node / self.tasks_per_node

Expand Down Expand Up @@ -1417,7 +1420,10 @@ def load_env(self, reset=False, job=None, verbose=False):
if not self._is_env_loaded or reset:
if job is None:
job = self.get_primary_job()
os.environ["OMP_NUM_THREADS"] = str(self.thread_count)
if self.get_build_threaded():
os.environ["OMP_NUM_THREADS"] = str(self.thread_count)
elif "OMP_NUM_THREADS" in os.environ:
del os.environ["OMP_NUM_THREADS"]
env_module = self.get_env("mach_specific")
env_module.load_env(self, job=job, verbose=verbose)
self._is_env_loaded = True
Expand Down
5 changes: 4 additions & 1 deletion scripts/lib/CIME/case/case_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def _run_model_impl(case, lid, skip_pnl=False, da_cycle=0):
model = case.get_value("MODEL")

# Set OMP_NUM_THREADS
os.environ["OMP_NUM_THREADS"] = str(case.thread_count)
if case.get_build_threaded():
os.environ["OMP_NUM_THREADS"] = str(case.thread_count)
elif "OMP_NUM_THREADS" in os.environ:
del os.environ["OMP_NUM_THREADS"]

# Run the model
cmd = case.get_mpirun_cmd(allow_unresolved_envvars=False)
Expand Down

0 comments on commit 89fad14

Please sign in to comment.