From 6d717fdb8f13d7a40a773e0126dc3ea495d75ca7 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Thu, 30 Mar 2023 12:05:08 +0100 Subject: [PATCH] tests: Add condition to switchconfig --- devito/arch/compiler.py | 4 ++-- devito/parameters.py | 8 ++++++++ tests/conftest.py | 12 ++---------- tests/test_dimension.py | 6 ++++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 2982e614d6..9ad1cacb00 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') diff --git a/devito/parameters.py b/devito/parameters.py index 0c56f10b44..84fb664d94 100644 --- a/devito/parameters.py +++ b/devito/parameters.py @@ -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] diff --git a/tests/conftest.py b/tests/conftest.py index 5c8c16fdeb..51d8e63138 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 @@ -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: @@ -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" diff --git a/tests/test_dimension.py b/tests/test_dimension.py index f38a8e18b8..f54f119c62 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 @@ -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