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 Mar 30, 2023
1 parent f8f5c26 commit 6d717fd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 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
8 changes: 8 additions & 0 deletions devito/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ def __init__(self, **params):
def __call__(self, func, *args, **kwargs):
@wraps(func)
def wrapper(*args, **kwargs):
# Do not switch if condition is False
try:
condition = self.params.pop('condition')
if not condition:
return
except KeyError:
condition = True

previous = {}
for k, v in self.params.items():
previous[k] = configuration[k]
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
6 changes: 4 additions & 2 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 @@ -1383,7 +1384,8 @@ def test_affiness(self):
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 6d717fd

Please sign in to comment.