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

Make LAPACK from E3SM optional in Spack builds #43

Merged
merged 1 commit into from
May 14, 2022
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
35 changes: 26 additions & 9 deletions mache/spack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@


def make_spack_env(spack_path, env_name, spack_specs, compiler, mpi,
machine=None, include_e3sm_hdf5_netcdf=False,
yaml_template=None, tmpdir=None):
machine=None, include_e3sm_lapack=False,
include_e3sm_hdf5_netcdf=False, yaml_template=None,
tmpdir=None):
"""
Clone the ``spack_for_mache_{{version}}`` branch from
`E3SM's spack clone <https://github.com/E3SM-Project/spack>`_ and build
Expand Down Expand Up @@ -38,6 +39,9 @@ def make_spack_env(spack_path, env_name, spack_specs, compiler, mpi,
The name of an E3SM supported machine. If none is given, the machine
will be detected automatically via the host name.

include_e3sm_lapack : bool, optional
Whether to include the same lapack (typically from MKL) as used in E3SM

include_e3sm_hdf5_netcdf : bool, optional
Whether to include the same hdf5, netcdf-c, netcdf-fortran and pnetcdf
as used in E3SM
Expand Down Expand Up @@ -67,7 +71,7 @@ def make_spack_env(spack_path, env_name, spack_specs, compiler, mpi,
# add the package specs to the appropriate template
specs = ''.join([f' - {spec}\n' for spec in spack_specs])

yaml_data = _get_yaml_data(machine, compiler, mpi,
yaml_data = _get_yaml_data(machine, compiler, mpi, include_e3sm_lapack,
include_e3sm_hdf5_netcdf, specs, yaml_template)

yaml_filename = os.path.abspath(f'{env_name}.yaml')
Expand All @@ -91,6 +95,7 @@ def make_spack_env(spack_path, env_name, spack_specs, compiler, mpi,
# there's nothing to add, which is fine
continue
bash_script = template.render(
e3sm_lapack=include_e3sm_lapack,
e3sm_hdf5_netcdf=include_e3sm_hdf5_netcdf)

modules = f'{modules}\n{bash_script}'
Expand All @@ -114,7 +119,8 @@ def make_spack_env(spack_path, env_name, spack_specs, compiler, mpi,


def get_spack_script(spack_path, env_name, compiler, mpi, shell, machine=None,
include_e3sm_hdf5_netcdf=False, yaml_template=None):
include_e3sm_lapack=False, include_e3sm_hdf5_netcdf=False,
yaml_template=None):
"""
Build a snippet of a load script for the given spack environment

Expand All @@ -140,6 +146,9 @@ def get_spack_script(spack_path, env_name, compiler, mpi, shell, machine=None,
The name of an E3SM supported machine. If none is given, the machine
will be detected automatically via the host name.

include_e3sm_lapack : bool, optional
Whether to include the same lapack (typically from MKL) as used in E3SM

include_e3sm_hdf5_netcdf : bool, optional
Whether to include the same hdf5, netcdf-c, netcdf-fortran and pnetcdf
as used in E3SM
Expand Down Expand Up @@ -172,8 +181,8 @@ def get_spack_script(spack_path, env_name, compiler, mpi, shell, machine=None,
modules_after = section.getboolean('modules_after')

yaml_data = _get_yaml_data(
machine, compiler, mpi, include_e3sm_hdf5_netcdf, specs='',
yaml_template=yaml_template)
machine, compiler, mpi, include_e3sm_lapack, include_e3sm_hdf5_netcdf,
specs='', yaml_template=yaml_template)

if modules_before or modules_after:
load_script = 'module purge\n'
Expand All @@ -197,6 +206,7 @@ def get_spack_script(spack_path, env_name, compiler, mpi, shell, machine=None,
# there's nothing to add, which is fine
continue
shell_script = template.render(
e3sm_lapack=include_e3sm_lapack,
e3sm_hdf5_netcdf=include_e3sm_hdf5_netcdf)
load_script = f'{load_script}\n{shell_script}'

Expand All @@ -208,6 +218,7 @@ def get_spack_script(spack_path, env_name, compiler, mpi, shell, machine=None,


def get_modules_env_vars_and_mpi_compilers(machine, compiler, mpi, shell,
include_e3sm_lapack=False,
include_e3sm_hdf5_netcdf=False,
yaml_template=None):
"""
Expand All @@ -230,6 +241,9 @@ def get_modules_env_vars_and_mpi_compilers(machine, compiler, mpi, shell,
shell : {'sh', 'csh'}
Which shell the script is for

include_e3sm_lapack : bool, optional
Whether to include the same lapack (typically from MKL) as used in E3SM

include_e3sm_hdf5_netcdf : bool, optional
Whether to include the same hdf5, netcdf-c, netcdf-fortran and pnetcdf
as used in E3SM
Expand Down Expand Up @@ -274,7 +288,8 @@ def get_modules_env_vars_and_mpi_compilers(machine, compiler, mpi, shell,
mod_env_commands = 'module purge\n'
if with_modules:
yaml_data = _get_yaml_data(
machine, compiler, mpi, include_e3sm_hdf5_netcdf, specs='',
machine, compiler, mpi, include_e3sm_lapack,
include_e3sm_hdf5_netcdf, specs='',
yaml_template=yaml_template)
mods = _get_modules(yaml_data)
mod_env_commands = f'{mod_env_commands}\n{mods}\n'
Expand All @@ -288,6 +303,7 @@ def get_modules_env_vars_and_mpi_compilers(machine, compiler, mpi, shell,
# there's nothing to add, which is fine
continue
shell_script = template.render(
e3sm_lapack=include_e3sm_lapack,
e3sm_hdf5_netcdf=include_e3sm_hdf5_netcdf)
mod_env_commands = f'{mod_env_commands}\n{shell_script}'

Expand All @@ -296,8 +312,8 @@ def get_modules_env_vars_and_mpi_compilers(machine, compiler, mpi, shell,
return mpicc, mpicxx, mpifc, mod_env_commands


def _get_yaml_data(machine, compiler, mpi, include_e3sm_hdf5_netcdf, specs,
yaml_template):
def _get_yaml_data(machine, compiler, mpi, include_e3sm_lapack,
include_e3sm_hdf5_netcdf, specs, yaml_template):
""" Get the data from the jinja-templated yaml file based on settings """
if yaml_template is None:
template_filename = f'{machine}_{compiler}_{mpi}.yaml'
Expand All @@ -312,6 +328,7 @@ def _get_yaml_data(machine, compiler, mpi, include_e3sm_hdf5_netcdf, specs,
template = Template(f.read())

yaml_data = template.render(specs=specs,
e3sm_lapack=include_e3sm_lapack,
e3sm_hdf5_netcdf=include_e3sm_hdf5_netcdf)
return yaml_data

Expand Down
6 changes: 5 additions & 1 deletion mache/spack/anvil_gnu_mvapich.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
spack:
specs:
specs:
- cmake
- gcc
- mvapich2
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- netcdf-c
- netcdf-fortran
Expand All @@ -16,7 +18,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bison:
externals:
- spec: [email protected]
Expand Down
6 changes: 5 additions & 1 deletion mache/spack/anvil_gnu_openmpi.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
spack:
specs:
specs:
- cmake
- gcc
- openmpi
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- hdf5
- netcdf-c
Expand All @@ -17,7 +19,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bison:
externals:
- spec: [email protected]
Expand Down
4 changes: 4 additions & 0 deletions mache/spack/anvil_intel_impi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ spack:
- cmake
- intel
- intel-mpi
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- hdf5
- netcdf-c
Expand All @@ -17,7 +19,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bison:
externals:
- spec: [email protected]
Expand Down
4 changes: 4 additions & 0 deletions mache/spack/anvil_intel_mvapich.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ spack:
- cmake
- intel
- mvapich2
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- hdf5
- netcdf-c
Expand All @@ -17,7 +19,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bison:
externals:
- spec: [email protected]
Expand Down
4 changes: 4 additions & 0 deletions mache/spack/anvil_intel_openmpi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ spack:
- cmake
- intel
- openmpi
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- hdf5
- netcdf-c
Expand All @@ -17,7 +19,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bison:
externals:
- spec: [email protected]
Expand Down
4 changes: 4 additions & 0 deletions mache/spack/badger_gnu_mvapich.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ spack:
- cmake
- gcc
- mvapich2
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- hdf5
- netcdf-c
Expand All @@ -17,7 +19,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bzip2:
externals:
- spec: [email protected]
Expand Down
4 changes: 4 additions & 0 deletions mache/spack/badger_intel_impi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ spack:
- cmake
- intel
- intel-mpi
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- hdf5
- netcdf-c
Expand All @@ -17,7 +19,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bzip2:
externals:
- spec: [email protected]
Expand Down
4 changes: 4 additions & 0 deletions mache/spack/chrysalis_gnu_openmpi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ spack:
- cmake
- gcc
- openmpi
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- hdf5
- netcdf-c
Expand All @@ -17,7 +19,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bzip2:
externals:
- spec: [email protected]
Expand Down
6 changes: 5 additions & 1 deletion mache/spack/chrysalis_intel_impi.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
spack:
specs:
specs:
- cmake
- intel
- intel-mpi
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- hdf5
- netcdf-c
Expand All @@ -17,7 +19,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bzip2:
externals:
- spec: [email protected]
Expand Down
4 changes: 4 additions & 0 deletions mache/spack/chrysalis_intel_openmpi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ spack:
- cmake
- intel
- openmpi
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- hdf5
- netcdf-c
Expand All @@ -17,7 +19,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bzip2:
externals:
- spec: [email protected]
Expand Down
4 changes: 4 additions & 0 deletions mache/spack/compy_intel_impi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ spack:
- cmake
- intel
- intel-mpi
{% if e3sm_lapack %}
- intel-mkl
{% endif %}
{% if e3sm_hdf5_netcdf %}
- hdf5
- netcdf-c
Expand All @@ -17,7 +19,9 @@ spack:
compiler: [[email protected]]
providers:
mpi: [[email protected]]
{% if e3sm_lapack %}
lapack: [[email protected]]
{% endif %}
bison:
externals:
- spec: [email protected]
Expand Down
2 changes: 2 additions & 0 deletions mache/spack/cori-haswell_gnu_mpt.csh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ module swap PrgEnv-intel PrgEnv-gnu/6.0.10
module rm gcc
module load gcc/10.3.0
module rm cray-libsci
{% if e3sm_lapack %}
module load cray-libsci/20.09.1
{% endif %}
module swap craype craype/2.6.2
module rm pmi
module load pmi/5.0.14
Expand Down
2 changes: 2 additions & 0 deletions mache/spack/cori-haswell_gnu_mpt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ module swap PrgEnv-intel PrgEnv-gnu/6.0.10
module rm gcc
module load gcc/10.3.0
module rm cray-libsci
{% if e3sm_lapack %}
module load cray-libsci/20.09.1
{% endif %}
module swap craype craype/2.6.2
module rm pmi
module load pmi/5.0.14
Expand Down
Loading