From 2ba63d0217b21665165c11264a9e3827b2c35748 Mon Sep 17 00:00:00 2001 From: abishekg7 <56273301+abishekg7@users.noreply.github.com> Date: Wed, 26 Apr 2023 09:30:52 -0500 Subject: [PATCH] ICON with DSL variants (#716) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * 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 Co-authored-by: github-actions Co-authored-by: juckerj <39263956+jonasjucker@users.noreply.github.com> Co-authored-by: Samuel Kellerhals Co-authored-by: Christoph Müller --- repos/c2sm/packages/icon/package.py | 74 +++++++++++++++++-- .../c2sm/packages/py-gridtools-cpp/package.py | 6 ++ repos/c2sm/packages/py-gt4py/package.py | 4 +- 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/repos/c2sm/packages/icon/package.py b/repos/c2sm/packages/icon/package.py index 7c847722e0..7ded165df7 100755 --- a/repos/c2sm/packages/icon/package.py +++ b/repos/c2sm/packages/icon/package.py @@ -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): @@ -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', @@ -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') @@ -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 @@ -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 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) diff --git a/repos/c2sm/packages/py-gridtools-cpp/package.py b/repos/c2sm/packages/py-gridtools-cpp/package.py index c62eee80b6..22963b8a5e 100644 --- a/repos/c2sm/packages/py-gridtools-cpp/package.py +++ b/repos/c2sm/packages/py-gridtools-cpp/package.py @@ -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") diff --git a/repos/c2sm/packages/py-gt4py/package.py b/repos/c2sm/packages/py-gt4py/package.py index afd50cfe25..6098426af3 100644 --- a/repos/c2sm/packages/py-gt4py/package.py +++ b/repos/c2sm/packages/py-gt4py/package.py @@ -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'))