Skip to content

Commit

Permalink
Unset OMP_NUM_THREADS in MPI-only runs
Browse files Browse the repository at this point in the history
  • Loading branch information
amametjanov committed Apr 25, 2019
1 parent f184078 commit 26795a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/lib/CIME/case/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def initialize_derived_attributes(self):

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 @@ -1414,6 +1416,8 @@ def load_env(self, reset=False, job=None, verbose=False):
job = self.get_primary_job()
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
2 changes: 2 additions & 0 deletions scripts/lib/CIME/case/case_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def _run_model_impl(case, lid, skip_pnl=False, da_cycle=0):
# Set OMP_NUM_THREADS
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 26795a1

Please sign in to comment.