From 248c0c9c755c552631a975b9dab9641c6604830a Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Wed, 8 Mar 2023 12:59:30 +0000 Subject: [PATCH 01/15] compiler: Add oneapi compiler support --- devito/arch/compiler.py | 56 ++++++++++++++++++++++++++++++++++++++++- tests/conftest.py | 11 ++++++-- tests/test_dimension.py | 2 ++ tests/test_dle.py | 1 + tests/test_dse.py | 1 + 5 files changed, 68 insertions(+), 3 deletions(-) diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 36c15388e8..eba990fce8 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -13,7 +13,7 @@ from codepy.toolchain import GCCToolchain from devito.arch import (AMDGPUX, Cpu64, M1, NVIDIAX, SKX, POWER8, POWER9, GRAVITON, - get_nvidia_cc, check_cuda_runtime, get_m1_llvm_path) + INTELGPUX, get_nvidia_cc, check_cuda_runtime, get_m1_llvm_path) from devito.exceptions import CompilationError from devito.logger import debug, warning, error from devito.parameters import configuration @@ -528,6 +528,58 @@ def __lookup_cmds__(self): self.MPICXX = 'mpicxx' +class OneapiCompiler(Compiler): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + language = kwargs.pop('language', configuration['language']) + platform = kwargs.pop('platform', configuration['platform']) + + self.cflags.append("-xHost") + self.cflags.append("-qopt-zmm-usage=high") + + if configuration['safe-math']: + self.cflags.append("-fp-model=strict") + else: + self.cflags.append('-fast') + + if language == 'sycl': + self.cflags.append('-fsycl') + if platform is NVIDIAX: + self.cflags.append('-fsycl-targets=nvptx64-cuda') + else: + self.cflags.append('-fsycl-targets=spir64') + + if language == 'openmp': + self.cflags.append('-qopenmp') + if platform is NVIDIAX: + self.cflags.append('-fopenmp-targets=nvptx64-cuda') + if platform is INTELGPUX: + self.cflags.append('-fopenmp-targets=spir64') + self.cflags.append('-fopenmp-target-simd') + + if platform is INTELGPUX: + self.cflags.remove('-g') # -g disables some optimizations in IGC + self.cflags.append('-gline-tables-only') + self.cflags.append('-fdebug-info-for-profiling') + + # Make sure the MPI compiler uses `icx` underneath -- whatever the MPI distro is + if kwargs.get('mpi'): + ver = check_output([self.MPICC, "--version"]).decode("utf-8") + if not ver.startswith("Intel(R) oneAPI"): + warning("The MPI compiler `%s` doesn't use the Intel(R) oneAPI " + "DPC++/C++ compiler underneath" % self.MPICC) + + def __lookup_cmds__(self): + # OneAPI HPC ToolKit comes with icpx, which is clang++, + # and icx, which is clang + self.CC = 'icx' + self.CXX = 'icpx' + self.MPICC = 'mpicc' + self.MPICXX = 'mpicxx' + + class PGICompiler(Compiler): def __init__(self, *args, **kwargs): @@ -803,6 +855,8 @@ def __lookup_cmds__(self): 'intel': IntelCompiler, 'icpc': IntelCompiler, 'icc': IntelCompiler, + 'icx': OneapiCompiler, + 'icpx': OneapiCompiler, 'intel-knl': IntelKNLCompiler, 'knl': IntelKNLCompiler, 'dpcpp': DPCPPCompiler, diff --git a/tests/conftest.py b/tests/conftest.py index 9f1246a294..ac38a6f38a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,7 +9,8 @@ from devito.checkpointing import NoopRevolver from devito.finite_differences.differentiable import EvalDerivative from devito.arch import Cpu64, Device, sniff_mpi_distro, Arm -from devito.arch.compiler import compiler_registry, IntelCompiler, NvidiaCompiler +from devito.arch.compiler import (compiler_registry, IntelCompiler, OneapiCompiler, + NvidiaCompiler) from devito.ir.iet import (FindNodes, FindSymbols, Iteration, ParallelBlock, retrieve_iteration_tree) from devito.tools import as_tuple @@ -26,7 +27,7 @@ def skipif(items, whole_module=False): # Sanity check accepted = set() accepted.update({'device', 'device-C', 'device-openmp', 'device-openacc', - 'device-aomp', 'cpu64-icc', 'cpu64-nvc', 'cpu64-arm', 'chkpnt'}) + 'device-aomp', 'cpu64-icc', 'cpu64-nvc', 'cpu64-arm' 'cpu64-icpx', 'chkpnt'}) accepted.update({'nompi', 'nodevice'}) unknown = sorted(set(items) - accepted) if unknown: @@ -70,6 +71,12 @@ def skipif(items, whole_module=False): isinstance(configuration['platform'], Cpu64): skipit = "`icc+cpu64` won't work with this test" break + # Skip if it won't run with OneAPICompiler + if i == 'cpu64-icpx' and \ + isinstance(configuration['compiler'], OneapiCompiler) and \ + isinstance(configuration['platform'], Cpu64): + skipit = "`icpx+cpu64` won't work with this test" + break # Skip if it won't run on Arm if i == 'cpu64-arm' and isinstance(configuration['platform'], Arm): skipit = "Arm doesn't support x86-specific instructions" diff --git a/tests/test_dimension.py b/tests/test_dimension.py index 8b06e39d33..65604c6413 100644 --- a/tests/test_dimension.py +++ b/tests/test_dimension.py @@ -1382,6 +1382,8 @@ def test_affiness(self): iterations = [i for i in FindNodes(Iteration).visit(op) if i.dim is not time] assert all(i.is_Affine for i in iterations) + # Skipping this test with icpx, as it requires safe-math + @skipif('cpu64-icpx') def test_sparse_time_function(self): nt = 20 diff --git a/tests/test_dle.py b/tests/test_dle.py index 9292b52664..009b5139e2 100644 --- a/tests/test_dle.py +++ b/tests/test_dle.py @@ -820,6 +820,7 @@ def test_incs_no_atomic(self): assert 'collapse' not in str(op1) assert 'atomic' not in str(op1) + @skipif('cpu64-icpx') @pytest.mark.parametrize('exprs,simd_level,expected', [ (['Eq(y.symbolic_max, g[0, x], implicit_dims=(t, x))', 'Inc(h1[0, 0], 1, implicit_dims=(t, x, y))'], diff --git a/tests/test_dse.py b/tests/test_dse.py index d11f25f16e..3ab3fa1514 100644 --- a/tests/test_dse.py +++ b/tests/test_dse.py @@ -317,6 +317,7 @@ def test_time_dependent_split(opt): class TestLifting(object): + @skipif('cpu64-icpx') @pytest.mark.parametrize('exprs,expected', [ # none (different distance) (['Eq(y.symbolic_max, g[0, x], implicit_dims=(t, x))', From e61fb8686f68499ad37dbcc21040af1d5c29e01d Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Fri, 17 Mar 2023 18:47:46 +0000 Subject: [PATCH 02/15] compiler: Switch oneapi to fopenmp --- devito/arch/compiler.py | 2 +- tests/test_dimension.py | 2 +- tests/test_dle.py | 1 - tests/test_dse.py | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index eba990fce8..949e8deaae 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -552,7 +552,7 @@ def __init__(self, *args, **kwargs): self.cflags.append('-fsycl-targets=spir64') if language == 'openmp': - self.cflags.append('-qopenmp') + self.cflags.append('-fopenmp') if platform is NVIDIAX: self.cflags.append('-fopenmp-targets=nvptx64-cuda') if platform is INTELGPUX: diff --git a/tests/test_dimension.py b/tests/test_dimension.py index 65604c6413..f38a8e18b8 100644 --- a/tests/test_dimension.py +++ b/tests/test_dimension.py @@ -1382,7 +1382,7 @@ def test_affiness(self): iterations = [i for i in FindNodes(Iteration).visit(op) if i.dim is not time] assert all(i.is_Affine for i in iterations) - # Skipping this test with icpx, as it requires safe-math + # Skipping this test with icx, as it requires safe-math @skipif('cpu64-icpx') def test_sparse_time_function(self): nt = 20 diff --git a/tests/test_dle.py b/tests/test_dle.py index 009b5139e2..9292b52664 100644 --- a/tests/test_dle.py +++ b/tests/test_dle.py @@ -820,7 +820,6 @@ def test_incs_no_atomic(self): assert 'collapse' not in str(op1) assert 'atomic' not in str(op1) - @skipif('cpu64-icpx') @pytest.mark.parametrize('exprs,simd_level,expected', [ (['Eq(y.symbolic_max, g[0, x], implicit_dims=(t, x))', 'Inc(h1[0, 0], 1, implicit_dims=(t, x, y))'], diff --git a/tests/test_dse.py b/tests/test_dse.py index 3ab3fa1514..d11f25f16e 100644 --- a/tests/test_dse.py +++ b/tests/test_dse.py @@ -317,7 +317,6 @@ def test_time_dependent_split(opt): class TestLifting(object): - @skipif('cpu64-icpx') @pytest.mark.parametrize('exprs,expected', [ # none (different distance) (['Eq(y.symbolic_max, g[0, x], implicit_dims=(t, x))', From 7645fc719c189edbf02ba92be130a050993cce58 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Fri, 24 Mar 2023 17:23:13 +0000 Subject: [PATCH 03/15] ci: Add icx workflow --- .github/workflows/docker-bases.yml | 6 ++++++ .github/workflows/pytest-core-nompi.yml | 12 ++++++++++-- devito/arch/compiler.py | 6 ++++-- docker/Dockerfile.cpu | 8 ++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-bases.yml b/.github/workflows/docker-bases.yml index 2d10b3e7e8..f0574af99b 100644 --- a/.github/workflows/docker-bases.yml +++ b/.github/workflows/docker-bases.yml @@ -72,6 +72,12 @@ jobs: dockerfile: './docker/Dockerfile.cpu' runner: ubuntu-latest + - tag: 'devitocodes/bases:cpu-icx' + arch: 'arch=icx' + version: '' + dockerfile: './docker/Dockerfile.cpu' + runner: ubuntu-latest + - tag: 'devitocodes/bases:cpu-nvc' arch: 'arch=nvc-host' version: '' diff --git a/.github/workflows/pytest-core-nompi.yml b/.github/workflows/pytest-core-nompi.yml index 7a8958210e..11063b6b36 100644 --- a/.github/workflows/pytest-core-nompi.yml +++ b/.github/workflows/pytest-core-nompi.yml @@ -38,7 +38,8 @@ jobs: pytest-ubuntu-py39-gcc9-omp, pytest-osx-py37-clang-omp, pytest-docker-py37-gcc-omp, - pytest-docker-py37-icc-omp + pytest-docker-py37-icc-omp, + pytest-docker-py38-icx-omp ] set: [base, adjoint] include: @@ -105,6 +106,13 @@ jobs: language: "openmp" sympy: "1.11" + - name: pytest-docker-py38-icx-omp + python-version: '3.8' + os: ubuntu-22.04 + arch: "icx" + language: "openmp" + sympy: "1.11" + - set: base test-set: 'not adjoint' @@ -139,7 +147,7 @@ jobs: fi id: set-run - - name: Install GCC ${{ matrix.arch }} + - name: Install ${{ matrix.arch }} compiler if: "runner.os == 'linux' && !contains(matrix.name, 'docker')" run : | sudo apt-get install -y ${{ matrix.arch }} diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 949e8deaae..bdeb5ba771 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -552,6 +552,8 @@ def __init__(self, *args, **kwargs): self.cflags.append('-fsycl-targets=spir64') if language == 'openmp': + # To be switched to `-fiopenmp` or `-qopenmp` as soon as + # it is fixed in the new Intel OneAPI release self.cflags.append('-fopenmp') if platform is NVIDIAX: self.cflags.append('-fopenmp-targets=nvptx64-cuda') @@ -566,8 +568,8 @@ def __init__(self, *args, **kwargs): # Make sure the MPI compiler uses `icx` underneath -- whatever the MPI distro is if kwargs.get('mpi'): - ver = check_output([self.MPICC, "--version"]).decode("utf-8") - if not ver.startswith("Intel(R) oneAPI"): + mpi_distro = sniff_mpi_distro('mpiexec') + if not mpi_distro.startswith("Intel(R) oneAPI"): warning("The MPI compiler `%s` doesn't use the Intel(R) oneAPI " "DPC++/C++ compiler underneath" % self.MPICC) diff --git a/docker/Dockerfile.cpu b/docker/Dockerfile.cpu index 15090ba290..c2607ca5be 100644 --- a/docker/Dockerfile.cpu +++ b/docker/Dockerfile.cpu @@ -68,6 +68,14 @@ ENV DEVITO_LANGUAGE="openmp" # MPICC compiler for mpi4py ENV MPICC=$I_MPI_ROOT/bin/mpiicc +############################################################## +# ICX image +############################################################## +FROM icc as icx + +# Devito config +ENV DEVITO_ARCH="icx" + ############################################################## # Published image ############################################################## From 41389057fa954e73d4dbfc1073533a5fb7ede0ed Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Fri, 7 Apr 2023 23:45:22 +0100 Subject: [PATCH 04/15] tests: Add condition to switchconfig --- .github/workflows/docker-bases.yml | 6 ------ .github/workflows/pytest-core-nompi.yml | 19 ++++++++++++------- devito/arch/compiler.py | 10 +++++----- devito/parameters.py | 7 +++++++ docker/Dockerfile.cpu | 8 -------- tests/conftest.py | 6 ------ tests/test_dimension.py | 7 ++++--- 7 files changed, 28 insertions(+), 35 deletions(-) diff --git a/.github/workflows/docker-bases.yml b/.github/workflows/docker-bases.yml index f0574af99b..2d10b3e7e8 100644 --- a/.github/workflows/docker-bases.yml +++ b/.github/workflows/docker-bases.yml @@ -72,12 +72,6 @@ jobs: dockerfile: './docker/Dockerfile.cpu' runner: ubuntu-latest - - tag: 'devitocodes/bases:cpu-icx' - arch: 'arch=icx' - version: '' - dockerfile: './docker/Dockerfile.cpu' - runner: ubuntu-latest - - tag: 'devitocodes/bases:cpu-nvc' arch: 'arch=nvc-host' version: '' diff --git a/.github/workflows/pytest-core-nompi.yml b/.github/workflows/pytest-core-nompi.yml index 11063b6b36..15288fc8e3 100644 --- a/.github/workflows/pytest-core-nompi.yml +++ b/.github/workflows/pytest-core-nompi.yml @@ -38,8 +38,8 @@ jobs: pytest-ubuntu-py39-gcc9-omp, pytest-osx-py37-clang-omp, pytest-docker-py37-gcc-omp, - pytest-docker-py37-icc-omp, - pytest-docker-py38-icx-omp + pytest-docker-py37-intel-omp, + pytest-docker-py38-intel-omp ] set: [base, adjoint] include: @@ -99,14 +99,14 @@ jobs: language: "openmp" sympy: "1.10" - - name: pytest-docker-py37-icc-omp + - name: pytest-docker-py37-intel-omp python-version: '3.7' os: ubuntu-22.04 arch: "icc" language: "openmp" sympy: "1.11" - - name: pytest-docker-py38-icx-omp + - name: pytest-docker-py38-intel-omp python-version: '3.8' os: ubuntu-22.04 arch: "icx" @@ -133,15 +133,20 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Build docker image - if: contains(matrix.name, 'docker') + - name: Build docker image for GCC variants + if: "contains(matrix.name, 'docker') && contains(matrix.name, 'gcc')" run: | docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-${{ matrix.arch }} + - name: Build docker image for INTEL variants + if: "contains(matrix.name, 'docker') && contains(matrix.name, 'intel')" + run: | + docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-icc + - name: Set run prefix run: | if [[ "${{ matrix.name }}" =~ "docker" ]]; then - echo "RUN_CMD=docker run --rm -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} --name testrun devito_img" >> $GITHUB_ENV + echo "RUN_CMD=docker run --rm -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e DEVITO_ARCH=${{ matrix.arch }} --name testrun devito_img" >> $GITHUB_ENV else echo "RUN_CMD=" >> $GITHUB_ENV fi diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index bdeb5ba771..5fad4e7e05 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -552,8 +552,8 @@ def __init__(self, *args, **kwargs): self.cflags.append('-fsycl-targets=spir64') if language == 'openmp': - # To be switched to `-fiopenmp` or `-qopenmp` as soon as - # it is fixed in the new Intel OneAPI release + # TODO: To be switched to `-fiopenmp` or `-qopenmp` as soon as + # it is fixed in the new Intel OneAPI release (current: 2023.0) self.cflags.append('-fopenmp') if platform is NVIDIAX: self.cflags.append('-fopenmp-targets=nvptx64-cuda') @@ -854,11 +854,11 @@ def __lookup_cmds__(self): 'nvidia': NvidiaCompiler, 'cuda': CudaCompiler, 'osx': ClangCompiler, - 'intel': IntelCompiler, - 'icpc': IntelCompiler, - 'icc': IntelCompiler, + 'intel': OneapiCompiler, 'icx': OneapiCompiler, 'icpx': OneapiCompiler, + 'icc': IntelCompiler, + 'icpc': IntelCompiler, 'intel-knl': IntelKNLCompiler, 'knl': IntelKNLCompiler, 'dpcpp': DPCPPCompiler, diff --git a/devito/parameters.py b/devito/parameters.py index 0c56f10b44..fab6940760 100644 --- a/devito/parameters.py +++ b/devito/parameters.py @@ -241,6 +241,13 @@ def __init__(self, **params): def __call__(self, func, *args, **kwargs): @wraps(func) def wrapper(*args, **kwargs): + # Do not switch if condition is False + try: + if not self.params.pop('condition'): + return + except KeyError: + pass + previous = {} for k, v in self.params.items(): previous[k] = configuration[k] diff --git a/docker/Dockerfile.cpu b/docker/Dockerfile.cpu index c2607ca5be..15090ba290 100644 --- a/docker/Dockerfile.cpu +++ b/docker/Dockerfile.cpu @@ -68,14 +68,6 @@ ENV DEVITO_LANGUAGE="openmp" # MPICC compiler for mpi4py ENV MPICC=$I_MPI_ROOT/bin/mpiicc -############################################################## -# ICX image -############################################################## -FROM icc as icx - -# Devito config -ENV DEVITO_ARCH="icx" - ############################################################## # Published image ############################################################## diff --git a/tests/conftest.py b/tests/conftest.py index ac38a6f38a..e2fecaca92 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -71,12 +71,6 @@ def skipif(items, whole_module=False): isinstance(configuration['platform'], Cpu64): skipit = "`icc+cpu64` won't work with this test" break - # Skip if it won't run with OneAPICompiler - if i == 'cpu64-icpx' and \ - isinstance(configuration['compiler'], OneapiCompiler) and \ - isinstance(configuration['platform'], Cpu64): - skipit = "`icpx+cpu64` won't work with this test" - break # Skip if it won't run on Arm if i == 'cpu64-arm' and isinstance(configuration['platform'], Arm): skipit = "Arm doesn't support x86-specific instructions" diff --git a/tests/test_dimension.py b/tests/test_dimension.py index f38a8e18b8..af2a8bb753 100644 --- a/tests/test_dimension.py +++ b/tests/test_dimension.py @@ -9,7 +9,8 @@ SparseFunction, SparseTimeFunction, Eq, Operator, Constant, Dimension, DefaultDimension, SubDimension, switchconfig, SubDomain, Lt, Le, Gt, Ge, Ne, Buffer, sin, SpaceDimension, - CustomDimension, dimensions) + CustomDimension, dimensions, configuration) +from devito.arch.compiler import OneapiCompiler from devito.ir.iet import (Conditional, Expression, Iteration, FindNodes, FindSymbols, retrieve_iteration_tree) from devito.symbolics import indexify, retrieve_functions, IntDiv @@ -1382,8 +1383,8 @@ def test_affiness(self): iterations = [i for i in FindNodes(Iteration).visit(op) if i.dim is not time] assert all(i.is_Affine for i in iterations) - # Skipping this test with icx, as it requires safe-math - @skipif('cpu64-icpx') + @switchconfig(condition=isinstance(configuration['compiler'], + OneapiCompiler), safe_math=True) def test_sparse_time_function(self): nt = 20 From 9f0652c10721a506692a740787b95a57745ffb0e Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Mon, 10 Apr 2023 14:40:29 +0100 Subject: [PATCH 05/15] ci: Add tag for dockers --- .github/workflows/pytest-core-nompi.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pytest-core-nompi.yml b/.github/workflows/pytest-core-nompi.yml index 15288fc8e3..cc19833c80 100644 --- a/.github/workflows/pytest-core-nompi.yml +++ b/.github/workflows/pytest-core-nompi.yml @@ -96,20 +96,23 @@ jobs: python-version: '3.7' os: ubuntu-latest arch: "gcc" + tag: "gcc" language: "openmp" sympy: "1.10" - - name: pytest-docker-py37-intel-omp + - name: pytest-docker-py37-icc-omp python-version: '3.7' os: ubuntu-22.04 arch: "icc" + tag: "icc" language: "openmp" sympy: "1.11" - - name: pytest-docker-py38-intel-omp + - name: pytest-docker-py38-icx-omp python-version: '3.8' os: ubuntu-22.04 arch: "icx" + tag: "icc" language: "openmp" sympy: "1.11" @@ -128,20 +131,15 @@ jobs: uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - if: "!contains(matrix.name, 'docker')" + if: !contains(matrix.name, 'docker') uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Build docker image for GCC variants - if: "contains(matrix.name, 'docker') && contains(matrix.name, 'gcc')" - run: | - docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-${{ matrix.arch }} - - - name: Build docker image for INTEL variants - if: "contains(matrix.name, 'docker') && contains(matrix.name, 'intel')" + - name: Build docker image + if: contains(matrix.name, 'docker') run: | - docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-icc + docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-${{ matrix.tag }} - name: Set run prefix run: | From 22861f7604389d62530c3e3c9485d452433f9166 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Wed, 19 Apr 2023 16:37:59 +0300 Subject: [PATCH 06/15] tests: Do not test gradients with OneApiCompiler --- .github/workflows/pytest-core-nompi.yml | 6 +++--- tests/conftest.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pytest-core-nompi.yml b/.github/workflows/pytest-core-nompi.yml index cc19833c80..944bf6ae76 100644 --- a/.github/workflows/pytest-core-nompi.yml +++ b/.github/workflows/pytest-core-nompi.yml @@ -38,8 +38,8 @@ jobs: pytest-ubuntu-py39-gcc9-omp, pytest-osx-py37-clang-omp, pytest-docker-py37-gcc-omp, - pytest-docker-py37-intel-omp, - pytest-docker-py38-intel-omp + pytest-docker-py37-icc-omp, + pytest-docker-py38-icx-omp ] set: [base, adjoint] include: @@ -131,7 +131,7 @@ jobs: uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - if: !contains(matrix.name, 'docker') + if: "!contains(matrix.name, 'docker')" uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} diff --git a/tests/conftest.py b/tests/conftest.py index e2fecaca92..59d13ed968 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -67,7 +67,7 @@ def skipif(items, whole_module=False): break # Skip if it won't run with IntelCompiler if i == 'cpu64-icc' and \ - isinstance(configuration['compiler'], IntelCompiler) and \ + isinstance(configuration['compiler'], (IntelCompiler, OneapiCompiler)) and \ isinstance(configuration['platform'], Cpu64): skipit = "`icc+cpu64` won't work with this test" break From bd9cb84d7ed8d7306f6569c22f428e30bc1df821 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Wed, 19 Apr 2023 16:59:48 +0300 Subject: [PATCH 07/15] compiler: drop support for icc < 15 --- devito/arch/compiler.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 5fad4e7e05..125fde19d4 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -729,13 +729,12 @@ def __init__(self, *args, **kwargs): self.cflags.append("-xhost") - language = kwargs.pop('language', configuration['language']) platform = kwargs.pop('platform', configuration['platform']) if configuration['safe-math']: self.cflags.append("-fp-model=strict") else: - self.cflags.append('-fast') + self.cflags.append('-fp-model=fast') if platform is SKX: # Systematically use 512-bit vectors on skylake @@ -746,11 +745,12 @@ def __init__(self, *args, **kwargs): # Append the OpenMP flag regardless of configuration['language'], # since icc15 and later versions implement OpenMP 4.0, hence # they support `#pragma omp simd` + # This class of IntelCompiler, will be dropped in future releases + # in favour of the OneApi IntelCompiler self.ldflags.append('-qopenmp') except (TypeError, ValueError): - if language == 'openmp': - # Note: fopenmp, not qopenmp, is what is needed by icc versions < 15.0 - self.ldflags.append('-fopenmp') + error("Support for IntelCompiler %s has been dropped." % self.version + + "Consider using a version >= 15.0.0") # Make sure the MPI compiler uses `icc` underneath -- whatever the MPI distro is if kwargs.get('mpi'): From b95bbd5b492d2dee9d107dcedeb566485c1fc9d1 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Tue, 16 May 2023 19:34:10 +0100 Subject: [PATCH 08/15] compiler: Subclass IntelCompiler --- devito/arch/compiler.py | 123 +++++++++++++++++----------------------- devito/parameters.py | 11 ++-- tests/conftest.py | 11 +++- tests/test_benchmark.py | 2 + tests/test_buffering.py | 1 - 5 files changed, 68 insertions(+), 80 deletions(-) diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 125fde19d4..64001e2170 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -528,60 +528,6 @@ def __lookup_cmds__(self): self.MPICXX = 'mpicxx' -class OneapiCompiler(Compiler): - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - language = kwargs.pop('language', configuration['language']) - platform = kwargs.pop('platform', configuration['platform']) - - self.cflags.append("-xHost") - self.cflags.append("-qopt-zmm-usage=high") - - if configuration['safe-math']: - self.cflags.append("-fp-model=strict") - else: - self.cflags.append('-fast') - - if language == 'sycl': - self.cflags.append('-fsycl') - if platform is NVIDIAX: - self.cflags.append('-fsycl-targets=nvptx64-cuda') - else: - self.cflags.append('-fsycl-targets=spir64') - - if language == 'openmp': - # TODO: To be switched to `-fiopenmp` or `-qopenmp` as soon as - # it is fixed in the new Intel OneAPI release (current: 2023.0) - self.cflags.append('-fopenmp') - if platform is NVIDIAX: - self.cflags.append('-fopenmp-targets=nvptx64-cuda') - if platform is INTELGPUX: - self.cflags.append('-fopenmp-targets=spir64') - self.cflags.append('-fopenmp-target-simd') - - if platform is INTELGPUX: - self.cflags.remove('-g') # -g disables some optimizations in IGC - self.cflags.append('-gline-tables-only') - self.cflags.append('-fdebug-info-for-profiling') - - # Make sure the MPI compiler uses `icx` underneath -- whatever the MPI distro is - if kwargs.get('mpi'): - mpi_distro = sniff_mpi_distro('mpiexec') - if not mpi_distro.startswith("Intel(R) oneAPI"): - warning("The MPI compiler `%s` doesn't use the Intel(R) oneAPI " - "DPC++/C++ compiler underneath" % self.MPICC) - - def __lookup_cmds__(self): - # OneAPI HPC ToolKit comes with icpx, which is clang++, - # and icx, which is clang - self.CC = 'icx' - self.CXX = 'icpx' - self.MPICC = 'mpicc' - self.MPICXX = 'mpicxx' - - class PGICompiler(Compiler): def __init__(self, *args, **kwargs): @@ -727,9 +673,9 @@ class IntelCompiler(Compiler): def __init__(self, *args, **kwargs): super(IntelCompiler, self).__init__(*args, **kwargs) - self.cflags.append("-xhost") - + self.cflags.append("-xHost") platform = kwargs.pop('platform', configuration['platform']) + language = kwargs.pop('language', configuration['language']) if configuration['safe-math']: self.cflags.append("-fp-model=strict") @@ -740,22 +686,13 @@ def __init__(self, *args, **kwargs): # Systematically use 512-bit vectors on skylake self.cflags.append("-qopt-zmm-usage=high") - try: - if self.version >= Version("15.0.0"): - # Append the OpenMP flag regardless of configuration['language'], - # since icc15 and later versions implement OpenMP 4.0, hence - # they support `#pragma omp simd` - # This class of IntelCompiler, will be dropped in future releases - # in favour of the OneApi IntelCompiler - self.ldflags.append('-qopenmp') - except (TypeError, ValueError): - error("Support for IntelCompiler %s has been dropped." % self.version + - "Consider using a version >= 15.0.0") + if language == 'openmp': + self.ldflags.append('-qopenmp') # Make sure the MPI compiler uses `icc` underneath -- whatever the MPI distro is if kwargs.get('mpi'): - ver = check_output([self.MPICC, "--version"]).decode("utf-8") - if not ver.startswith("icc"): + mpi_distro = sniff_mpi_distro('mpiexec') + if mpi_distro != 'IntelMPI': warning("The MPI compiler `%s` doesn't use the Intel " "C/C++ compiler underneath" % self.MPICC) @@ -783,7 +720,7 @@ class IntelKNLCompiler(IntelCompiler): def __init__(self, *args, **kwargs): super(IntelKNLCompiler, self).__init__(*args, **kwargs) - self.cflags += ["-xMIC-AVX512"] + self.cflags.append('-xMIC-AVX512') language = kwargs.pop('language', configuration['language']) @@ -791,6 +728,52 @@ def __init__(self, *args, **kwargs): warning("Running on Intel KNL without OpenMP is highly discouraged") +class OneapiCompiler(IntelCompiler): + + def __init__(self, *args, **kwargs): + super(OneapiCompiler, self).__init__(*args, **kwargs) + + platform = kwargs.pop('platform', configuration['platform']) + language = kwargs.pop('language', configuration['language']) + + if language == 'openmp': + self.ldflags.remove('-qopenmp') + self.ldflags.append('-fopenmp') + + if language == 'sycl': + self.cflags.append('-fsycl') + if platform is NVIDIAX: + self.cflags.append('-fsycl-targets=nvptx64-cuda') + else: + self.cflags.append('-fsycl-targets=spir64') + + if platform is NVIDIAX: + self.cflags.append('-fopenmp-targets=nvptx64-cuda') + if platform is INTELGPUX: + self.cflags.append('-fopenmp-targets=spir64') + self.cflags.append('-fopenmp-target-simd') + + if platform is INTELGPUX: + self.cflags.remove('-g') # -g disables some optimizations in IGC + self.cflags.append('-gline-tables-only') + self.cflags.append('-fdebug-info-for-profiling') + + # Make sure the MPI compiler uses `icx` underneath -- whatever the MPI distro is + if kwargs.get('mpi'): + mpi_distro = sniff_mpi_distro('mpiexec') + if mpi_distro != 'IntelMPI': + warning("The MPI compiler `%s` doesn't use the Intel(R) oneAPI " + "DPC++/C++ compiler underneath" % self.MPICC) + + def __lookup_cmds__(self): + # OneAPI HPC ToolKit comes with icpx, which is clang++, + # and icx, which is clang + self.CC = 'icx' + self.CXX = 'icpx' + self.MPICC = 'mpicc' + self.MPICX = 'mpicx' + + class CustomCompiler(Compiler): """ diff --git a/devito/parameters.py b/devito/parameters.py index fab6940760..adfbf29d10 100644 --- a/devito/parameters.py +++ b/devito/parameters.py @@ -236,17 +236,14 @@ class switchconfig(object): """ def __init__(self, **params): + params.pop('condition', None) self.params = {k.replace('_', '-'): v for k, v in params.items()} def __call__(self, func, *args, **kwargs): @wraps(func) - def wrapper(*args, **kwargs): - # Do not switch if condition is False - try: - if not self.params.pop('condition'): - return - except KeyError: - pass + def wrapper(*args, condition=None, **kwargs): + if condition is False: + return previous = {} for k, v in self.params.items(): diff --git a/tests/conftest.py b/tests/conftest.py index 59d13ed968..7db4cb2fbd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -27,7 +27,8 @@ def skipif(items, whole_module=False): # Sanity check accepted = set() accepted.update({'device', 'device-C', 'device-openmp', 'device-openacc', - 'device-aomp', 'cpu64-icc', 'cpu64-nvc', 'cpu64-arm' 'cpu64-icpx', 'chkpnt'}) + 'device-aomp', 'cpu64-icc', 'cpu64-icx', 'cpu64-nvc', 'cpu64-arm', + 'cpu64-icpx', 'chkpnt'}) accepted.update({'nompi', 'nodevice'}) unknown = sorted(set(items) - accepted) if unknown: @@ -67,10 +68,16 @@ def skipif(items, whole_module=False): break # Skip if it won't run with IntelCompiler if i == 'cpu64-icc' and \ - isinstance(configuration['compiler'], (IntelCompiler, OneapiCompiler)) and \ + isinstance(configuration['compiler'], IntelCompiler) and \ isinstance(configuration['platform'], Cpu64): skipit = "`icc+cpu64` won't work with this test" break + # Skip if it won't run with OneAPICompiler + if i == 'cpu64-icx' and \ + isinstance(configuration['compiler'], OneapiCompiler) and \ + isinstance(configuration['platform'], Cpu64): + skipit = "`icx+cpu64` won't work with this test" + break # Skip if it won't run on Arm if i == 'cpu64-arm' and isinstance(configuration['platform'], Arm): skipit = "Arm doesn't support x86-specific instructions" diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py index 1b45290ae2..2b0988fc33 100644 --- a/tests/test_benchmark.py +++ b/tests/test_benchmark.py @@ -4,9 +4,11 @@ from benchmarks.user.benchmark import run from devito import configuration, switchconfig +from conftest import skipif from subprocess import check_call +@skipif('cpu64-icx') @pytest.mark.parametrize('mode, problem, op', [ ('run', 'acoustic', 'forward'), ('run', 'acoustic', 'adjoint'), ('run', 'acoustic', 'jacobian'), ('run', 'acoustic', 'jacobian_adjoint'), diff --git a/tests/test_buffering.py b/tests/test_buffering.py index 29aea2bc04..997a2f571b 100644 --- a/tests/test_buffering.py +++ b/tests/test_buffering.py @@ -701,7 +701,6 @@ def test_everything(): assert np.all(u.data == u1.data) -@skipif('cpu64-icc') @pytest.mark.parametrize('subdomain', ['domain', 'interior']) def test_stencil_issue_1915(subdomain): nt = 5 From ff8387ca5bb694eb36177624b60c5498ecf63ca9 Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Tue, 18 Apr 2023 16:22:24 +0000 Subject: [PATCH 09/15] arch: Systematically use avx512 --- devito/arch/archinfo.py | 35 +++++++++++++++++++++++++---------- devito/arch/compiler.py | 20 +++++++++++++++----- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/devito/arch/archinfo.py b/devito/arch/archinfo.py index bcff8eb365..70c25bcdb8 100644 --- a/devito/arch/archinfo.py +++ b/devito/arch/archinfo.py @@ -16,12 +16,17 @@ __all__ = ['platform_registry', 'get_cpu_info', 'get_gpu_info', 'get_nvidia_cc', 'get_cuda_path', 'get_hip_path', 'check_cuda_runtime', 'get_m1_llvm_path', - 'Platform', 'Cpu64', 'Intel64', 'Amd', 'Arm', 'Power', 'Device', - 'NvidiaDevice', 'AmdDevice', 'IntelDevice', - 'INTEL64', 'SNB', 'IVB', 'HSW', 'BDW', 'SKX', 'KNL', 'KNL7210', # Intel - 'AMD', 'ARM', 'M1', 'GRAVITON', # ARM - 'POWER8', 'POWER9', # Other loosely supported CPU architectures - 'AMDGPUX', 'NVIDIAX', 'INTELGPUX'] # GPUs + 'Platform', 'Cpu64', 'Intel64', 'IntelSkylake', 'Amd', 'Arm', 'Power', + 'Device', 'NvidiaDevice', 'AmdDevice', 'IntelDevice', + # Intel + 'INTEL64', 'SNB', 'IVB', 'HSW', 'BDW', 'KNL', 'KNL7210', + 'SKX', 'KLX', 'CLX', 'CLK', + # ARM + 'AMD', 'ARM', 'M1', 'GRAVITON', + # Other loosely supported CPU architectures + 'POWER8', 'POWER9', + # GPUs + 'AMDGPUX', 'NVIDIAX', 'INTELGPUX'] @memoized_func @@ -494,7 +499,7 @@ def get_platform(): if 'phi' in brand: # Intel Xeon Phi? return platform_registry['knl'] - # Unknown Xeon ? May happen on some virtualizes systems... + # Unknown Xeon ? May happen on some virtualized systems... return platform_registry['intel64'] elif 'intel' in brand: # Most likely a desktop i3/i5/i7 @@ -607,6 +612,14 @@ class Intel64(Cpu64): known_isas = ('cpp', 'sse', 'avx', 'avx2', 'avx512') +class IntelSkylake(Intel64): + pass + + +class IntelGoldenCode(Intel64): + pass + + class Arm(Cpu64): known_isas = ('fp', 'asimd', 'asimdrdm') @@ -725,11 +738,12 @@ def march(cls): IVB = Intel64('ivb') HSW = Intel64('hsw') BDW = Intel64('bdw', isa='avx2') -SKX = Intel64('skx') -KLX = Intel64('klx') -CLX = Intel64('clx') KNL = Intel64('knl') KNL7210 = Intel64('knl', cores_logical=256, cores_physical=64, isa='avx512') +SKX = IntelSkylake('skx') +KLX = IntelSkylake('klx') +CLX = IntelSkylake('clx') +CLK = IntelSkylake('clk') ARM = Arm('arm') GRAVITON = Arm('graviton') @@ -756,6 +770,7 @@ def march(cls): 'skx': SKX, # Skylake 'klx': KLX, # Kaby Lake 'clx': CLX, # Coffee Lake + 'clk': CLK, # Cascade Lake 'knl': KNL, 'knl7210': KNL7210, 'arm': ARM, # Generic ARM CPU diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 64001e2170..8920c6b9ea 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -12,8 +12,9 @@ from codepy.jit import compile_from_string from codepy.toolchain import GCCToolchain -from devito.arch import (AMDGPUX, Cpu64, M1, NVIDIAX, SKX, POWER8, POWER9, GRAVITON, - INTELGPUX, get_nvidia_cc, check_cuda_runtime, get_m1_llvm_path) +from devito.arch import (AMDGPUX, Cpu64, M1, NVIDIAX, POWER8, POWER9, GRAVITON, + IntelSkylake, get_nvidia_cc, check_cuda_runtime, + get_m1_llvm_path) from devito.exceptions import CompilationError from devito.logger import debug, warning, error from devito.parameters import configuration @@ -375,13 +376,22 @@ class GNUCompiler(Compiler): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.cflags += ['-march=native', '-Wno-unused-result', '-Wno-unused-variable', - '-Wno-unused-but-set-variable'] + platform = kwargs.pop('platform', configuration['platform']) + + self.cflags += ['-march=native', '-Wno-unused-result', + '-Wno-unused-variable', '-Wno-unused-but-set-variable'] + if configuration['safe-math']: self.cflags.append('-fno-unsafe-math-optimizations') else: self.cflags.append('-ffast-math') + if isinstance(platform, IntelSkylake): + # The default is `=256` because avx512 slows down the CPU frequency; + # however, we empirically found that stencils generally benefit + # from `=512` + self.cflags.append('-mprefer-vector-width=512') + language = kwargs.pop('language', configuration['language']) try: if self.version >= Version("4.9.0"): @@ -682,7 +692,7 @@ def __init__(self, *args, **kwargs): else: self.cflags.append('-fp-model=fast') - if platform is SKX: + if isinstance(platform, IntelSkylake): # Systematically use 512-bit vectors on skylake self.cflags.append("-qopt-zmm-usage=high") From 8e966a8edafedfe8d293b78a93ce278ab07b1c94 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Tue, 23 May 2023 16:26:22 +0300 Subject: [PATCH 10/15] flake: Fix not imported module --- devito/arch/compiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 8920c6b9ea..6c8ac002d4 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -13,7 +13,7 @@ from codepy.toolchain import GCCToolchain from devito.arch import (AMDGPUX, Cpu64, M1, NVIDIAX, POWER8, POWER9, GRAVITON, - IntelSkylake, get_nvidia_cc, check_cuda_runtime, + INTELGPUX, IntelSkylake, get_nvidia_cc, check_cuda_runtime, get_m1_llvm_path) from devito.exceptions import CompilationError from devito.logger import debug, warning, error From 0f9960fd96feac8e4cf2859c9ed14e032ee878c0 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Wed, 24 May 2023 13:06:55 +0300 Subject: [PATCH 11/15] compiler: Add condition in __init__ --- devito/arch/compiler.py | 2 +- devito/parameters.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 6c8ac002d4..b6934ce455 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -773,7 +773,7 @@ def __init__(self, *args, **kwargs): mpi_distro = sniff_mpi_distro('mpiexec') if mpi_distro != 'IntelMPI': warning("The MPI compiler `%s` doesn't use the Intel(R) oneAPI " - "DPC++/C++ compiler underneath" % self.MPICC) + "`%s` compiler underneath" % self.MPICC, self.CXX) def __lookup_cmds__(self): # OneAPI HPC ToolKit comes with icpx, which is clang++, diff --git a/devito/parameters.py b/devito/parameters.py index adfbf29d10..57073be4bf 100644 --- a/devito/parameters.py +++ b/devito/parameters.py @@ -235,14 +235,14 @@ class switchconfig(object): Decorator to temporarily change `configuration` parameters. """ - def __init__(self, **params): - params.pop('condition', None) + def __init__(self, condition=None, **params): + self.condition = condition self.params = {k.replace('_', '-'): v for k, v in params.items()} def __call__(self, func, *args, **kwargs): @wraps(func) - def wrapper(*args, condition=None, **kwargs): - if condition is False: + def wrapper(*args, **kwargs): + if self.condition is False: return previous = {} From 2be15bac5b9f80d240f1fc06d43076acf1c94100 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Wed, 24 May 2023 15:18:14 +0300 Subject: [PATCH 12/15] compiler: Drop condition check from __call__ --- devito/parameters.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/devito/parameters.py b/devito/parameters.py index 57073be4bf..3805ac73ae 100644 --- a/devito/parameters.py +++ b/devito/parameters.py @@ -235,16 +235,15 @@ class switchconfig(object): Decorator to temporarily change `configuration` parameters. """ - def __init__(self, condition=None, **params): - self.condition = condition - self.params = {k.replace('_', '-'): v for k, v in params.items()} + def __init__(self, condition=True, **params): + if condition: + self.params = {k.replace('_', '-'): v for k, v in params.items()} + else: + self.params = {} def __call__(self, func, *args, **kwargs): @wraps(func) def wrapper(*args, **kwargs): - if self.condition is False: - return - previous = {} for k, v in self.params.items(): previous[k] = configuration[k] From 6f0052aede08e2e791f732f7741afb7d667b3579 Mon Sep 17 00:00:00 2001 From: George BIsbas Date: Thu, 1 Jun 2023 08:45:29 +0100 Subject: [PATCH 13/15] docker: Push icx image with icc tag --- .github/workflows/docker-bases.yml | 2 +- .github/workflows/pytest-core-nompi.yml | 5 +---- devito/arch/compiler.py | 12 ++++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-bases.yml b/.github/workflows/docker-bases.yml index 2d10b3e7e8..65a12fb289 100644 --- a/.github/workflows/docker-bases.yml +++ b/.github/workflows/docker-bases.yml @@ -66,7 +66,7 @@ jobs: dockerfile: './docker/Dockerfile.cpu' runner: ubuntu-latest - - tag: 'devitocodes/bases:cpu-icc' + - tag: 'devitocodes/bases:cpu-icc, devitocodes/bases:cpu-icx' arch: 'arch=icc' version: '' dockerfile: './docker/Dockerfile.cpu' diff --git a/.github/workflows/pytest-core-nompi.yml b/.github/workflows/pytest-core-nompi.yml index 944bf6ae76..738daf79ed 100644 --- a/.github/workflows/pytest-core-nompi.yml +++ b/.github/workflows/pytest-core-nompi.yml @@ -96,7 +96,6 @@ jobs: python-version: '3.7' os: ubuntu-latest arch: "gcc" - tag: "gcc" language: "openmp" sympy: "1.10" @@ -104,7 +103,6 @@ jobs: python-version: '3.7' os: ubuntu-22.04 arch: "icc" - tag: "icc" language: "openmp" sympy: "1.11" @@ -112,7 +110,6 @@ jobs: python-version: '3.8' os: ubuntu-22.04 arch: "icx" - tag: "icc" language: "openmp" sympy: "1.11" @@ -139,7 +136,7 @@ jobs: - name: Build docker image if: contains(matrix.name, 'docker') run: | - docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-${{ matrix.tag }} + docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-${{ matrix.arch }} - name: Set run prefix run: | diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index b6934ce455..4591ecaf8b 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -424,7 +424,7 @@ def __init__(self, *args, **kwargs): class ClangCompiler(Compiler): def __init__(self, *args, **kwargs): - super(ClangCompiler, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.cflags += ['-Wno-unused-result', '-Wno-unused-variable'] if not configuration['safe-math']: @@ -491,7 +491,7 @@ class AOMPCompiler(Compiler): """AMD's fork of Clang for OpenMP offloading on both AMD and NVidia cards.""" def __init__(self, *args, **kwargs): - super(AOMPCompiler, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.cflags += ['-Wno-unused-result', '-Wno-unused-variable'] if not configuration['safe-math']: @@ -541,7 +541,7 @@ def __lookup_cmds__(self): class PGICompiler(Compiler): def __init__(self, *args, **kwargs): - super(PGICompiler, self).__init__(*args, cpp=True, **kwargs) + super().__init__(*args, cpp=True, **kwargs) self.cflags.remove('-std=c99') self.cflags.remove('-O3') @@ -681,7 +681,7 @@ def __lookup_cmds__(self): class IntelCompiler(Compiler): def __init__(self, *args, **kwargs): - super(IntelCompiler, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.cflags.append("-xHost") platform = kwargs.pop('platform', configuration['platform']) @@ -728,7 +728,7 @@ def __lookup_cmds__(self): class IntelKNLCompiler(IntelCompiler): def __init__(self, *args, **kwargs): - super(IntelKNLCompiler, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.cflags.append('-xMIC-AVX512') @@ -741,7 +741,7 @@ def __init__(self, *args, **kwargs): class OneapiCompiler(IntelCompiler): def __init__(self, *args, **kwargs): - super(OneapiCompiler, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) platform = kwargs.pop('platform', configuration['platform']) language = kwargs.pop('language', configuration['language']) From 8cd3677d6f72be2f2db06e36787b0bce761e546b Mon Sep 17 00:00:00 2001 From: George BIsbas Date: Thu, 1 Jun 2023 10:24:43 +0100 Subject: [PATCH 14/15] tests: Add safemath for icc in sparse_time_function test --- tests/test_dimension.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_dimension.py b/tests/test_dimension.py index af2a8bb753..a5a4804d88 100644 --- a/tests/test_dimension.py +++ b/tests/test_dimension.py @@ -10,7 +10,7 @@ Dimension, DefaultDimension, SubDimension, switchconfig, SubDomain, Lt, Le, Gt, Ge, Ne, Buffer, sin, SpaceDimension, CustomDimension, dimensions, configuration) -from devito.arch.compiler import OneapiCompiler +from devito.arch.compiler import IntelCompiler, OneapiCompiler from devito.ir.iet import (Conditional, Expression, Iteration, FindNodes, FindSymbols, retrieve_iteration_tree) from devito.symbolics import indexify, retrieve_functions, IntDiv @@ -1384,7 +1384,7 @@ def test_affiness(self): assert all(i.is_Affine for i in iterations) @switchconfig(condition=isinstance(configuration['compiler'], - OneapiCompiler), safe_math=True) + (IntelCompiler, OneapiCompiler)), safe_math=True) def test_sparse_time_function(self): nt = 20 From e355ed81cb1ffafa52a5f128d9fb9c5bae6fb5b4 Mon Sep 17 00:00:00 2001 From: George Bismpas Date: Mon, 5 Jun 2023 17:49:43 +0100 Subject: [PATCH 15/15] compiler: Refactor mpi distro check --- devito/arch/compiler.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 4591ecaf8b..452084bc91 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -683,9 +683,9 @@ class IntelCompiler(Compiler): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.cflags.append("-xHost") platform = kwargs.pop('platform', configuration['platform']) language = kwargs.pop('language', configuration['language']) + self.cflags.append("-xHost") if configuration['safe-math']: self.cflags.append("-fp-model=strict") @@ -703,8 +703,8 @@ def __init__(self, *args, **kwargs): if kwargs.get('mpi'): mpi_distro = sniff_mpi_distro('mpiexec') if mpi_distro != 'IntelMPI': - warning("The MPI compiler `%s` doesn't use the Intel " - "C/C++ compiler underneath" % self.MPICC) + warning("Expected Intel MPI distribution with `%s`, but found `%s`" + % (self.__class__.__name__, mpi_distro)) def __lookup_cmds__(self): self.CC = 'icc' @@ -768,13 +768,6 @@ def __init__(self, *args, **kwargs): self.cflags.append('-gline-tables-only') self.cflags.append('-fdebug-info-for-profiling') - # Make sure the MPI compiler uses `icx` underneath -- whatever the MPI distro is - if kwargs.get('mpi'): - mpi_distro = sniff_mpi_distro('mpiexec') - if mpi_distro != 'IntelMPI': - warning("The MPI compiler `%s` doesn't use the Intel(R) oneAPI " - "`%s` compiler underneath" % self.MPICC, self.CXX) - def __lookup_cmds__(self): # OneAPI HPC ToolKit comes with icpx, which is clang++, # and icx, which is clang