Skip to content

Commit

Permalink
ICON with DSL variants (#716)
Browse files Browse the repository at this point in the history
* add versions for icon4py and gt4py

* GitHub Action: Apply Pep8-formatting

* add fix for py-poetry-core

* GitHub Action: Apply Pep8-formatting

* updates to get icon4py building after the major gt4py overhaul

* Update system_test.py

* GitHub Action: Apply Pep8-formatting

* add missing test deps, only test next and eve

* remove obsolete patch

* addressing some review comments

* Add Boost to CMake Include Path

* Change icon, gridtools and balfrin site packages for successful build

* GitHub Action: Apply Pep8-formatting

* set boost-path for unittests of icon4py, make tests on Balfrin work

* lock python and gt4py versions

* GitHub Action: Apply Pep8-formatting

* fix typo

* GitHub Action: Apply Pep8-formatting

* Edits to support icon-dsl on Daint (#693)

* working on daint

* GitHub Action: Apply Pep8-formatting

* tested for icon4py v0.0.2

* GitHub Action: Apply Pep8-formatting

* cleanup

---------

Co-authored-by: github-actions <github-actions@github.com>

* Reverting to clean versions of icon, nvidia blas and lapack

* pulling changes from icon-gt4py-daint2 to support latest gt4py

* addressing review comments

* GitHub Action: Apply Pep8-formatting

* icon with dsl variants

* GitHub Action: Apply Pep8-formatting

* bumpin icon4py to 0.0.3, gt4py tag uknown yet. Gt4py requirements now match the correct min requirements

* numpy seems to depend on blas/lapack without this

* remove artefact

* addressing some review comments

* GitHub Action: Apply Pep8-formatting

* Update exclaim branch

* trying new paths for icon4py

* switching all gridtools references to py-gridtools-cpp and bumping to v2.3.0

* GitHub Action: Apply Pep8-formatting

* Changing to min requirements for py-gridtools-cpp

* fix for cases when dsl=none

* GitHub Action: Apply Pep8-formatting

* Update repos/c2sm/packages/icon/package.py

Co-authored-by: juckerj <39263956+jonasjucker@users.noreply.github.com>

---------

Co-authored-by: Jonas Jucker <joni.jucker@yahoo.de>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: juckerj <39263956+jonasjucker@users.noreply.github.com>
Co-authored-by: Samuel Kellerhals <kellerhalssamuel@gmail.com>
Co-authored-by: Christoph Müller <Christoph.Mueller@meteoswiss.ch>
  • Loading branch information
6 people authored Apr 26, 2023
1 parent d2c682f commit 2ba63d0
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 8 deletions.
74 changes: 68 additions & 6 deletions repos/c2sm/packages/icon/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
from llnl.util import lang, filesystem, tty
from spack.util.environment import is_system_path, dump_environment
from spack.util.executable import which_string, which
import spack.error as error


def validate_variant_dsl(pkg, name, value):
set_mutual_excl = set(['substitute', 'verify', 'serialize'])
set_input_var = set(value)
if len(set_mutual_excl.intersection(set_input_var)) > 1:
raise error.SpecError(
'Cannot have more than one of (substitute, verify, serialize) in the same build'
)


def check_variant_fcgroup(fcgroup):
Expand All @@ -29,8 +39,8 @@ class Icon(AutotoolsPackage):
branch='master',
git='ssh://git@github.com/C2SM/icon-exclaim.git',
submodules=True)
version('exclaim-test',
branch='test_spec',
version('exclaim',
branch='icon-dsl-spack',
git='ssh://git@github.com/C2SM/icon-exclaim.git',
submodules=True)
version('nwp-master',
Expand Down Expand Up @@ -169,6 +179,20 @@ class Icon(AutotoolsPackage):
description=
'Enable extension of eccodes with center specific definition files')

# EXCLAIM-GT4Py specific features:
dsl_values = ('substitute', 'verify', 'serialize', 'fused', 'nvtx', 'lam')
variant('dsl',
default='none',
validator=validate_variant_dsl,
values=('none', ) + dsl_values,
description='Build with GT4Py dynamical core',
multi=True)

for x in dsl_values:
depends_on('py-icon4py', when='dsl={0}'.format(x))
depends_on('py-gridtools-cpp', when='dsl={0}'.format(x))
conflicts('^python@:3.9,3.11:', when='dsl={0}'.format(x))

depends_on('infero +quiet', when='+infero')

depends_on('libfyaml', when='+coupling')
Expand Down Expand Up @@ -292,6 +316,11 @@ def setup_build_environment(self, env):
for d in link_dirs:
env.append_path('SPACK_COMPILER_IMPLICIT_RPATHS', d)

if 'none' not in self.spec.variants['dsl'].value:
env.set("CUDAARCHS", self.spec.variants['gpu'].value)
env.unset("CUDAHOSTCXX")
env.set("Boost_INCLUDE_DIR", self.spec['boost'].prefix.include)

@run_before('configure')
def downgrade_opt_level(self):
# We try to prevent compiler crashes by reducing the optimization level
Expand Down Expand Up @@ -618,15 +647,48 @@ def configure_args(self):
cuda_host_compiler = self.compiler.cxx
cuda_host_compiler_stdcxx_libs = self.compiler.stdcxx_libs

config_vars['NVCFLAGS'].extend([
'-ccbin {0}'.format(cuda_host_compiler), '-g', '-O3',
'-arch=sm_{0}'.format(gpu)
])
if 'none' in self.spec.variants['dsl'].value:
config_vars['NVCFLAGS'].extend(
['-ccbin {0}'.format(cuda_host_compiler)])

config_vars['NVCFLAGS'].extend(
['-g', '-O3', '-arch=sm_{0}'.format(gpu)])
# cuda_host_compiler_stdcxx_libs might contain compiler-specific
# flags (i.e. not the linker -l<library> flags), therefore we put
# the value to the config_flags directly.
config_vars['LIBS'].extend(cuda_host_compiler_stdcxx_libs)

# Check for DSL variants and set corresponding Liskov options
dsl = self.spec.variants['dsl'].value
if dsl != ('none', ):
if 'substitute' in dsl:
config_args.append('--enable-liskov=substitute')
elif 'verify' in dsl:
config_args.append('--enable-liskov=verify')
elif 'serialize' in dsl:
raise error.UnsupportedPlatformError(
'serialize mode is not supported yet by icon-liskov')

if 'lam' in dsl:
config_args.append('--enable-dsl-local')
if 'nvtx' in dsl:
config_args.append('--enable-nvtx')
if 'fused' in dsl:
raise error.UnsupportedPlatformError(
'liskov does not support fusing just yet')

config_vars['LOC_GT4PY'].append(self.spec['py-gt4py'].prefix)
config_vars['LOC_ICON4PY'].append(
os.path.join(self.spec['py-icon4py'].prefix))
config_vars['LOC_ICON4PY_LIB'].append(
os.path.join(self.spec['py-icon4py'].prefix,
'lib/python3.10/site-packages/icon4py'))
config_vars['LOC_GRIDTOOLS'].append(
os.path.join(
self.spec['py-gridtools-cpp'].prefix,
'lib/python3.10/site-packages/gridtools_cpp/data'))
config_vars['GT4PYNVCFLAGS'] = config_vars['NVCFLAGS']

# Finalize the LIBS variable (we always put the real collected
# libraries to the front):
config_vars['LIBS'].insert(0, libs.link_flags)
Expand Down
6 changes: 6 additions & 0 deletions repos/c2sm/packages/py-gridtools-cpp/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ class PyGridtoolsCpp(PythonPackage):
homepage = "https://gridtools.github.io/gridtools/latest/index.html"

pypi = "gridtools-cpp/gridtools-cpp-2.2.3.tar.gz"
whl_url = "https://pypi.io/packages/py3/g/gridtools-cpp/gridtools_cpp-2.3.0-py3-none-any.whl"

maintainers = ['samkellerhals']

version("2.3.0",
url=whl_url,
sha256=
"0af02845a538a7c20791ecaeeb3b68c8b976b653ef8593a00beea60445ec38b6",
expand=False)
version("2.2.2",
sha256=
"d45316379440b6d96d04b3fb47f6a432946e9f9d906bcb10af51d9a92e95353e")
Expand Down
4 changes: 2 additions & 2 deletions repos/c2sm/packages/py-gt4py/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class PyGt4py(PythonPackage):
depends_on('py-deepdiff@5.6:', type=('build', 'run'))
depends_on('py-devtools@0.6:', type=('build', 'run'))
depends_on('py-frozendict@2.3:', type=('build', 'run'))
depends_on('py-gridtools-cpp@2.2.3:', type=('build', 'run'))
depends_on('py-gridtools-cpp@2.3.0:', type=('build', 'run'))
depends_on('py-jinja2@3.0.0:', type=('build', 'run'))
depends_on('py-lark@1.1.2:', type=('build', 'run'))
depends_on('py-mako@1.1:', type=('build', 'run'))
depends_on('py-ninja@1.10:', type=('build', 'run'))
depends_on('py-numpy@1.24.2:', type=('build', 'run'))
depends_on('py-numpy@1.24.2: ~blas ~lapack', type=('build', 'run'))
depends_on('py-packaging@20.0:', type=('build', 'run'))
depends_on('py-pybind11@2.5:', type=('build', 'run'))
depends_on('py-tabulate@0.8:', type=('build', 'run'))
Expand Down

0 comments on commit 2ba63d0

Please sign in to comment.