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

Refactor BUILD_THREADED to match documentation. #1335

Merged
merged 1 commit into from
Apr 11, 2017
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
1 change: 0 additions & 1 deletion scripts/lib/CIME/SystemTests/erp.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def build_phase(self, sharedlib_only=False, model_only=False):
nthreads = self._case.get_value("NTHRDS_%s"%comp)
rootpe = self._case.get_value("ROOTPE_%s"%comp)
if ( nthreads > 1 ):
self._case.set_value("BUILD_THREADED", True)
self._case.set_value("NTHRDS_%s"%comp, nthreads/2)
if ( ntasks > 1 ):
self._case.set_value("NTASKS_%s"%comp, ntasks/2)
Expand Down
4 changes: 2 additions & 2 deletions scripts/lib/CIME/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def _clean_impl(case, cleanlist, clean_all):
expect(cleanlist is not None and len(cleanlist) > 0,"Empty cleanlist not expected")
debug = case.get_value("DEBUG")
use_esmf_lib = case.get_value("USE_ESMF_LIB")
build_threaded = case.get_value("BUILD_THREADED")
build_threaded = case.get_build_threaded()
gmake = case.get_value("GMAKE")
caseroot = case.get_value("CASEROOT")
casetools = case.get_value("CASETOOLS")
Expand Down Expand Up @@ -394,7 +394,7 @@ def _case_build_impl(caseroot, case, sharedlib_only, model_only):
# needs to be unset before building again.
if "MODEL" in os.environ.keys():
del os.environ["MODEL"]
build_threaded = case.get_value("BUILD_THREADED")
build_threaded = case.get_build_threaded()
casetools = case.get_value("CASETOOLS")
exeroot = case.get_value("EXEROOT")
incroot = case.get_value("INCROOT")
Expand Down
13 changes: 10 additions & 3 deletions scripts/lib/CIME/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from CIME.utils import expect, get_cime_root, append_status
from CIME.utils import convert_to_type, get_model, get_project
from CIME.utils import get_build_threaded, get_current_commit
from CIME.utils import get_current_commit
from CIME.check_lockedfiles import LOCKED_DIR, lock_file
from CIME.XML.machines import Machines
from CIME.XML.pes import Pes
Expand Down Expand Up @@ -142,7 +142,7 @@ def _initialize_derived_attributes(self):
mpi_attribs = {
"compiler" : self.get_value("COMPILER"),
"mpilib" : self.get_value("MPILIB"),
"threaded" : get_build_threaded(self)
"threaded" : self.get_build_threaded()
}

executable = env_mach_spec.get_mpirun(self, mpi_attribs, job="case.run", exe_only=True)[0]
Expand Down Expand Up @@ -1072,7 +1072,7 @@ def get_mpirun_cmd(self, job="case.run"):
mpi_attribs = {
"compiler" : self.get_value("COMPILER"),
"mpilib" : self.get_value("MPILIB"),
"threaded" : get_build_threaded(self)
"threaded" : self.get_build_threaded()
}

executable, args = env_mach_specific.get_mpirun(self, mpi_attribs, job=job)
Expand Down Expand Up @@ -1119,6 +1119,13 @@ def load_env(self):
env_module.load_env(compiler=compiler,debug=debug, mpilib=mpilib)
self._is_env_loaded = True

def get_build_threaded(self):
"""
Returns True if current settings require a threaded build/run.
"""
force_threaded = self.get_value("BUILD_THREADED")
return bool(force_threaded) or self.thread_count > 1

def _check_testlists(self, compset_alias, grid_name, files):
"""
CESM only: check the testlist file for tests of this compset grid combination
Expand Down
6 changes: 2 additions & 4 deletions scripts/lib/CIME/case_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ def _case_setup_impl(case, caseroot, clean=False, test_mode=False, reset=False,
logger.debug("at update TOTALPES = %s"%pestot)
case.set_value("TOTALPES", pestot)
thread_count = env_mach_pes.get_max_thread_count(models)
if thread_count > 1:
case.set_value("BUILD_THREADED", True)

expect(not (case.get_value("BUILD_THREADED") and compiler == "nag"),
build_threaded = case.get_build_threaded()
expect(not (build_threaded and compiler == "nag"),
"it is not possible to run with OpenMP if using the NAG Fortran compiler")
cost_pes = env_mach_pes.get_cost_pes(pestot, thread_count, machine=case.get_value("MACH"))
case.set_value("COST_PES", cost_pes)
Expand Down
11 changes: 0 additions & 11 deletions scripts/lib/CIME/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,17 +973,6 @@ def wait_for_unlocked(filepath):
if file_object:
file_object.close()

def get_build_threaded(case):
"""Returns True if current settings require a threaded build/run."""
force_threaded = case.get_value("BUILD_THREADED")
if force_threaded:
return True
comp_classes = case.get_values("COMP_CLASSES")
for comp_class in comp_classes:
if case.get_value("NTHRDS_%s"%comp_class) > 1:
return True
return False

def gunzip_existing_file(filepath):
with gzip.open(filepath, "rb") as fd:
return fd.read()
Expand Down
41 changes: 40 additions & 1 deletion scripts/tests/scripts_regression_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ class K_TestCimeCase(TestCreateTestCommon):
###########################################################################
def test_cime_case(self):
###########################################################################
run_cmd_assert_result(self, "%s/create_test cime_test_only -t %s --no-build --test-root %s --output-root %s"
run_cmd_assert_result(self, "%s/create_test TESTRUNPASS_P1.f19_g16_rx1.A -t %s --no-build --test-root %s --output-root %s"
% (SCRIPT_DIR, self._baseline_name, TEST_ROOT, TEST_ROOT))

casedir = os.path.join(self._testroot,
Expand Down Expand Up @@ -1282,6 +1282,45 @@ def test_cime_case(self):
# Test some test properties
self.assertEqual(case.get_value("TESTCASE"), "TESTRUNPASS")

###########################################################################
def test_cime_case_build_threaded_1(self):
###########################################################################
run_cmd_assert_result(self, "%s/create_test TESTRUNPASS_P1x1.f19_g16_rx1.A -t %s --no-build --test-root %s --output-root %s"
% (SCRIPT_DIR, self._baseline_name, TEST_ROOT, TEST_ROOT))

casedir = os.path.join(self._testroot,
"%s.%s" % (CIME.utils.get_full_test_name("TESTRUNPASS_P1x1.f19_g16_rx1.A", machine=self._machine, compiler=self._compiler), self._baseline_name))
self.assertTrue(os.path.isdir(casedir), msg="Missing casedir '%s'" % casedir)

with Case(casedir, read_only=False) as case:
build_threaded = case.get_value("BUILD_THREADED")
self.assertFalse(build_threaded)

build_threaded = case.get_build_threaded()
self.assertFalse(build_threaded)

case.set_value("BUILD_THREADED", True)

build_threaded = case.get_build_threaded()
self.assertTrue(build_threaded)

###########################################################################
def test_cime_case_build_threaded_2(self):
###########################################################################
run_cmd_assert_result(self, "%s/create_test TESTRUNPASS_P1x2.f19_g16_rx1.A -t %s --no-build --test-root %s --output-root %s"
% (SCRIPT_DIR, self._baseline_name, TEST_ROOT, TEST_ROOT))

casedir = os.path.join(self._testroot,
"%s.%s" % (CIME.utils.get_full_test_name("TESTRUNPASS_P1x2.f19_g16_rx1.A", machine=self._machine, compiler=self._compiler), self._baseline_name))
self.assertTrue(os.path.isdir(casedir), msg="Missing casedir '%s'" % casedir)

with Case(casedir, read_only=False) as case:
build_threaded = case.get_value("BUILD_THREADED")
self.assertFalse(build_threaded)

build_threaded = case.get_build_threaded()
self.assertTrue(build_threaded)

###########################################################################
def test_cime_case_mpi_serial(self):
###########################################################################
Expand Down