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

Omit OMP_NUM_THREADS in MPI-only runs #3085

Merged
merged 2 commits into from
Jun 5, 2019
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
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 @@ -1411,7 +1414,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