Skip to content

Commit 08f7e1c

Browse files
committed
tests: Add condition to switchconfig
1 parent f8f5c26 commit 08f7e1c

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

devito/arch/compiler.py

Lines changed: 2 additions & 2 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')

devito/parameters.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,14 @@ def __init__(self, **params):
241241
def __call__(self, func, *args, **kwargs):
242242
@wraps(func)
243243
def wrapper(*args, **kwargs):
244+
# Do not switch if condition is False
245+
try:
246+
condition = self.params.pop('condition')
247+
if not condition:
248+
return
249+
except KeyError:
250+
condition = True
251+
244252
previous = {}
245253
for k, v in self.params.items():
246254
previous[k] = configuration[k]

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 & 2 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
@@ -1383,7 +1384,8 @@ def test_affiness(self):
13831384
assert all(i.is_Affine for i in iterations)
13841385

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

0 commit comments

Comments
 (0)