-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cice5: improve handling of targets and dependencies for ESM1.6 (#179)
- Loading branch information
Showing
1 changed file
with
74 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ class Cice5(MakefilePackage): | |
|
||
maintainers = ["harshula"] | ||
|
||
version("master", branch="master") | ||
version("master", branch="master", preferred=True) | ||
|
||
variant("deterministic", default=False, description="Deterministic build.") | ||
variant("optimisation_report", default=False, description="Generate optimisation reports.") | ||
|
@@ -25,45 +25,27 @@ class Cice5(MakefilePackage): | |
depends_on("mpi") | ||
depends_on("[email protected]:") | ||
depends_on("[email protected]:") | ||
# TODO: For initial verification we are going to use static pio. | ||
# Eventually we plan to move to shared pio | ||
# ~shared requires: https://github.com/spack/spack/pull/34837 | ||
depends_on("parallelio~pnetcdf~timing~shared") | ||
depends_on("datetime-fortran") | ||
depends_on("oasis3-mct+deterministic", when="+deterministic") | ||
depends_on("oasis3-mct~deterministic", when="~deterministic") | ||
depends_on("libaccessom2+deterministic", when="+deterministic") | ||
depends_on("libaccessom2~deterministic", when="~deterministic") | ||
|
||
phases = ["edit", "build", "install"] | ||
|
||
_buildscript = "spack-build.sh" | ||
_buildscript_path = join_path("bld", _buildscript) | ||
|
||
# The integer represents environment variable NTASK | ||
__targets = {24: {}, 480: {}, 722: {}, 1682: {}} | ||
__targets[24]["driver"] = "auscom" | ||
__targets[24]["grid"] = "360x300" | ||
__targets[24]["blocks"] = "24x1" | ||
|
||
__targets[480]["driver"] = "auscom" | ||
__targets[480]["grid"] = "1440x1080" | ||
__targets[480]["blocks"] = "48x40" | ||
|
||
# Comment from bld/config.nci.auscom.3600x2700: | ||
# Recommendations: | ||
# use processor_shape = slenderX1 or slenderX2 in ice_in | ||
# one per processor with distribution_type='cartesian' or | ||
# squarish blocks with distribution_type='rake' | ||
# If BLCKX (BLCKY) does not divide NXGLOB (NYGLOB) evenly, padding | ||
# will be used on the right (top) of the grid. | ||
__targets[722]["driver"] = "auscom" | ||
__targets[722]["grid"] = "3600x2700" | ||
__targets[722]["blocks"] = "90x90" | ||
|
||
__targets[1682]["driver"] = "auscom" | ||
__targets[1682]["grid"] = "3600x2700" | ||
__targets[1682]["blocks"] = "200x180" | ||
|
||
# These are the default dependencies when building version "master". | ||
# Copied with when() from MOM5 SPR | ||
with when("@:access-esm0,access-esm2:"): | ||
# TODO: For initial verification we are going to use static pio. | ||
# Eventually we plan to move to shared pio | ||
# ~shared requires: https://github.com/spack/spack/pull/34837 | ||
depends_on("parallelio~pnetcdf~timing~shared") | ||
depends_on("libaccessom2+deterministic", when="+deterministic") | ||
depends_on("libaccessom2~deterministic", when="~deterministic") | ||
|
||
phases = ["set_deps_targets", "edit", "build", "install"] | ||
|
||
__buildscript = "spack-build.sh" | ||
__buildscript_path = join_path("bld", __buildscript) | ||
|
||
__deps = {"includes": "", "ldflags": ""} | ||
__targets = {} | ||
|
||
def url_for_version(self, version): | ||
return "https://github.com/ACCESS-NRI/cice5/tarball/{0}".format(version) | ||
|
@@ -86,25 +68,67 @@ def make_linker_args(self, spec, name, namespecs): | |
"-Wl,-rpath=" + path] | ||
) | ||
|
||
def add_target(self, ntask, driver, grid, blocks): | ||
self.__targets[ntask]["driver"] = driver | ||
self.__targets[ntask]["grid"] = grid | ||
self.__targets[ntask]["blocks"] = blocks | ||
|
||
def set_deps_targets(self, spec, prefix): | ||
|
||
if self.spec.satisfies("@access-esm1.6"): | ||
# The integer represents environment variable NTASK | ||
self.__targets = {12: {}} | ||
self.add_target(12, "access-esm1.6", "360x300", "12x1") | ||
|
||
ideps = ["oasis3-mct", "netcdf-fortran"] | ||
|
||
# NOTE: The order of the libraries matter during the linking step! | ||
ldeps = ["oasis3-mct", "netcdf-c", "netcdf-fortran"] | ||
lstr = "" | ||
|
||
# These are the default settings when building version "master". | ||
else: | ||
# The integer represents environment variable NTASK | ||
self.__targets = {24: {}, 480: {}, 722: {}, 1682: {}} | ||
|
||
# TODO: Each of these targets could map to a variant: | ||
self.add_target(24, "auscom", "360x300", "24x1") | ||
self.add_target(480, "auscom", "1440x1080", "48x40") | ||
|
||
# Comment from bld/config.nci.auscom.3600x2700: | ||
# Recommendations: | ||
# use processor_shape = slenderX1 or slenderX2 in ice_in | ||
# one per processor with distribution_type='cartesian' or | ||
# squarish blocks with distribution_type='rake' | ||
# If BLCKX (BLCKY) does not divide NXGLOB (NYGLOB) evenly, padding | ||
# will be used on the right (top) of the grid. | ||
self.add_target(722, "auscom", "3600x2700", "90x90") | ||
self.add_target(1682, "auscom", "3600x2700", "200x180") | ||
|
||
ideps = ["parallelio", "oasis3-mct", "libaccessom2", "netcdf-fortran"] | ||
|
||
# NOTE: The order of the libraries matter during the linking step! | ||
# NOTE: datetime-fortran is a dependency of libaccessom2. | ||
ldeps = ["oasis3-mct", "libaccessom2", "netcdf-c", "netcdf-fortran", "datetime-fortran"] | ||
lstr = self.make_linker_args(spec, "parallelio", "-lpiof -lpioc") | ||
|
||
istr = join_path((spec["oasis3-mct"].headers).cpp_flags, "psmile.MPI1") | ||
self.__deps["includes"] = " ".join([istr] + [(spec[d].headers).cpp_flags for d in ideps]) | ||
|
||
self.__deps["ldflags"] = " ".join([lstr] + [self.get_linker_args(spec, d) for d in ldeps]) | ||
|
||
|
||
def edit(self, spec, prefix): | ||
|
||
srcdir = self.stage.source_path | ||
buildscript_dest = join_path(srcdir, self._buildscript_path) | ||
buildscript_dest = join_path(srcdir, self.__buildscript_path) | ||
makeinc_path = join_path(srcdir, "bld", "Macros.spack") | ||
|
||
copy(join_path(self.package_dir, self._buildscript), buildscript_dest) | ||
copy(join_path(self.package_dir, self.__buildscript), buildscript_dest) | ||
|
||
config = {} | ||
|
||
istr = join_path((spec["oasis3-mct"].headers).cpp_flags, "psmile.MPI1") | ||
ideps = ["parallelio", "oasis3-mct", "libaccessom2", "netcdf-fortran"] | ||
incs = " ".join([istr] + [(spec[d].headers).cpp_flags for d in ideps]) | ||
|
||
lstr = self.make_linker_args(spec, "parallelio", "-lpiof -lpioc") | ||
# NOTE: The order of the libraries matter during the linking step! | ||
# NOTE: datetime-fortran is a dependency of libaccessom2. | ||
ldeps = ["oasis3-mct", "libaccessom2", "netcdf-c", "netcdf-fortran", "datetime-fortran"] | ||
libs = " ".join([lstr] + [self.get_linker_args(spec, d) for d in ldeps]) | ||
incs = self.__deps["includes"] | ||
libs = self.__deps["ldflags"] | ||
|
||
# TODO: https://github.com/ACCESS-NRI/ACCESS-OM/issues/12 | ||
NCI_OPTIM_FLAGS = "-g3 -O2 -axCORE-AVX2 -debug all -check none -traceback -assume buffered_io" | ||
|
@@ -224,7 +248,7 @@ def edit(self, spec, prefix): | |
def build(self, spec, prefix): | ||
|
||
build = Executable( | ||
join_path(self.stage.source_path, self._buildscript_path) | ||
join_path(self.stage.source_path, self.__buildscript_path) | ||
) | ||
|
||
for k in self.__targets: | ||
|