Skip to content

Commit 0202e68

Browse files
committed
tests: Add condition to switchconfig
1 parent 6ec8b1e commit 0202e68

File tree

7 files changed

+28
-40
lines changed

7 files changed

+28
-40
lines changed

.github/workflows/docker-bases.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ jobs:
7272
dockerfile: './docker/Dockerfile.cpu'
7373
runner: ubuntu-latest
7474

75-
- tag: 'devitocodes/bases:cpu-icx'
76-
arch: 'arch=icx'
77-
version: ''
78-
dockerfile: './docker/Dockerfile.cpu'
79-
runner: ubuntu-latest
80-
8175
- tag: 'devitocodes/bases:cpu-nvc'
8276
arch: 'arch=nvc-host'
8377
version: ''

.github/workflows/pytest-core-nompi.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
pytest-ubuntu-py39-gcc9-omp,
3535
pytest-osx-py37-clang-omp,
3636
pytest-docker-py37-gcc-omp,
37-
pytest-docker-py37-icc-omp,
38-
pytest-docker-py38-icx-omp
37+
pytest-docker-py37-intel-omp,
38+
pytest-docker-py38-intel-omp
3939
]
4040
set: [base, adjoint]
4141
include:
@@ -95,14 +95,14 @@ jobs:
9595
language: "openmp"
9696
sympy: "1.10"
9797

98-
- name: pytest-docker-py37-icc-omp
98+
- name: pytest-docker-py37-intel-omp
9999
python-version: '3.7'
100100
os: ubuntu-22.04
101101
arch: "icc"
102102
language: "openmp"
103103
sympy: "1.11"
104104

105-
- name: pytest-docker-py38-icx-omp
105+
- name: pytest-docker-py38-intel-omp
106106
python-version: '3.8'
107107
os: ubuntu-22.04
108108
arch: "icx"
@@ -129,15 +129,20 @@ jobs:
129129
with:
130130
python-version: ${{ matrix.python-version }}
131131

132-
- name: Build docker image
133-
if: contains(matrix.name, 'docker')
132+
- name: Build docker image for GCC variants
133+
if: "contains(matrix.name, 'docker') && contains(matrix.name, 'gcc')"
134134
run: |
135135
docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-${{ matrix.arch }}
136136
137+
- name: Build docker image for INTEL variants
138+
if: "contains(matrix.name, 'docker') && contains(matrix.name, 'intel')"
139+
run: |
140+
docker build . --file docker/Dockerfile.devito --tag devito_img --build-arg base=devitocodes/bases:cpu-icc
141+
137142
- name: Set run prefix
138143
run: |
139144
if [[ "${{ matrix.name }}" =~ "docker" ]]; then
140-
echo "RUN_CMD=docker run --rm -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} --name testrun devito_img" >> $GITHUB_ENV
145+
echo "RUN_CMD=docker run --rm -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e DEVITO_ARCH=${{ matrix.arch }} --name testrun devito_img" >> $GITHUB_ENV
141146
else
142147
echo "RUN_CMD=" >> $GITHUB_ENV
143148
fi

devito/arch/compiler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ def __init__(self, *args, **kwargs):
552552
self.cflags.append('-fsycl-targets=spir64')
553553

554554
if language == 'openmp':
555-
# To be switched to `-fiopenmp` or `-qopenmp` as soon as
556-
# it is fixed in the new Intel OneAPI release
555+
# TODO: To be switched to `-fiopenmp` or `-qopenmp` as soon as
556+
# it is fixed in the new Intel OneAPI release (current: 2023.0)
557557
self.cflags.append('-fopenmp')
558558
if platform is NVIDIAX:
559559
self.cflags.append('-fopenmp-targets=nvptx64-cuda')
@@ -854,11 +854,11 @@ def __lookup_cmds__(self):
854854
'nvidia': NvidiaCompiler,
855855
'cuda': CudaCompiler,
856856
'osx': ClangCompiler,
857-
'intel': IntelCompiler,
858-
'icpc': IntelCompiler,
859-
'icc': IntelCompiler,
857+
'intel': OneapiCompiler,
860858
'icx': OneapiCompiler,
861859
'icpx': OneapiCompiler,
860+
'icc': IntelCompiler,
861+
'icpc': IntelCompiler,
862862
'intel-knl': IntelKNLCompiler,
863863
'knl': IntelKNLCompiler,
864864
'dpcpp': DPCPPCompiler,

devito/parameters.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,13 @@ class switchconfig(object):
238238
def __init__(self, **params):
239239
self.params = {k.replace('_', '-'): v for k, v in params.items()}
240240

241-
def __call__(self, func, *args, **kwargs):
241+
def __call__(self, func, *args, condition=False, **kwargs):
242242
@wraps(func)
243243
def wrapper(*args, **kwargs):
244+
# Do not switch if condition is False
245+
if not condition:
246+
return
247+
244248
previous = {}
245249
for k, v in self.params.items():
246250
previous[k] = configuration[k]

docker/Dockerfile.cpu

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ ENV DEVITO_LANGUAGE="openmp"
5555
# MPICC compiler for mpi4py
5656
ENV MPICC=$I_MPI_ROOT/bin/mpiicc
5757

58-
##############################################################
59-
# ICX image
60-
##############################################################
61-
FROM icc as icx
62-
63-
# Devito config
64-
ENV DEVITO_ARCH="icx"
65-
6658
##############################################################
6759
# Published image
6860
##############################################################

tests/conftest.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from devito import Eq, configuration # noqa
88
from devito.finite_differences.differentiable import EvalDerivative
99
from devito.arch import Cpu64, Device, sniff_mpi_distro, Arm
10-
from devito.arch.compiler import (compiler_registry, IntelCompiler, OneapiCompiler,
11-
NvidiaCompiler)
10+
from devito.arch.compiler import compiler_registry, IntelCompiler, NvidiaCompiler
1211
from devito.ir.iet import retrieve_iteration_tree, FindNodes, Iteration, ParallelBlock
1312
from devito.tools import as_tuple
1413

@@ -24,8 +23,7 @@ def skipif(items, whole_module=False):
2423
# Sanity check
2524
accepted = set()
2625
accepted.update({'device', 'device-C', 'device-openmp', 'device-openacc',
27-
'device-aomp', 'cpu64-icc', 'cpu64-icpx', 'cpu64-nvc',
28-
'cpu64-arm'})
26+
'device-aomp', 'cpu64-icc', 'cpu64-nvc', 'cpu64-arm'})
2927
accepted.update({'nompi', 'nodevice'})
3028
unknown = sorted(set(items) - accepted)
3129
if unknown:
@@ -71,12 +69,6 @@ def skipif(items, whole_module=False):
7169
isinstance(configuration['platform'], Cpu64):
7270
skipit = "`icc+cpu64` won't work with this test"
7371
break
74-
# Skip if it won't run with OneAPICompiler
75-
if i == 'cpu64-icpx' and \
76-
isinstance(configuration['compiler'], OneapiCompiler) and \
77-
isinstance(configuration['platform'], Cpu64):
78-
skipit = "`icpx+cpu64` won't work with this test"
79-
break
8072
# Skip if it won't run on Arm
8173
if i == 'cpu64-arm' and isinstance(configuration['platform'], Arm):
8274
skipit = "Arm doesn't support x86-specific instructions"

tests/test_dimension.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
SparseFunction, SparseTimeFunction, Eq, Operator, Constant,
1010
Dimension, DefaultDimension, SubDimension, switchconfig,
1111
SubDomain, Lt, Le, Gt, Ge, Ne, Buffer, sin, SpaceDimension,
12-
CustomDimension, dimensions)
12+
CustomDimension, dimensions, configuration)
13+
from devito.arch.compiler import OneapiCompiler
1314
from devito.ir.iet import (Conditional, Expression, Iteration, FindNodes,
1415
FindSymbols, retrieve_iteration_tree)
1516
from devito.symbolics import indexify, retrieve_functions, IntDiv
@@ -1382,8 +1383,8 @@ def test_affiness(self):
13821383
iterations = [i for i in FindNodes(Iteration).visit(op) if i.dim is not time]
13831384
assert all(i.is_Affine for i in iterations)
13841385

1385-
# Skipping this test with icx, as it requires safe-math
1386-
@skipif('cpu64-icpx')
1386+
@switchconfig(condition=isinstance(configuration['compiler'],
1387+
OneapiCompiler), safe_math=True)
13871388
def test_sparse_time_function(self):
13881389
nt = 20
13891390

0 commit comments

Comments
 (0)