Skip to content

Commit

Permalink
tests: Add condition to switchconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebisbas committed Apr 7, 2023
1 parent 6ec8b1e commit 7a269dd
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 39 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/docker-bases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/pytest-core-nompi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,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:
Expand Down Expand Up @@ -95,14 +95,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"
Expand All @@ -129,15 +129,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
Expand Down
10 changes: 5 additions & 5 deletions devito/arch/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions devito/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 0 additions & 8 deletions docker/Dockerfile.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,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
##############################################################
Expand Down
12 changes: 2 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from devito import Eq, configuration # noqa
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, OneapiCompiler,
NvidiaCompiler)
from devito.arch.compiler import compiler_registry, IntelCompiler, NvidiaCompiler
from devito.ir.iet import retrieve_iteration_tree, FindNodes, Iteration, ParallelBlock
from devito.tools import as_tuple

Expand All @@ -24,8 +23,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-icpx', 'cpu64-nvc',
'cpu64-arm'})
'device-aomp', 'cpu64-icc', 'cpu64-nvc', 'cpu64-arm'})
accepted.update({'nompi', 'nodevice'})
unknown = sorted(set(items) - accepted)
if unknown:
Expand Down Expand Up @@ -71,12 +69,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"
Expand Down
7 changes: 4 additions & 3 deletions tests/test_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 7a269dd

Please sign in to comment.