Skip to content

Commit 78741f4

Browse files
authored
Merge pull request #2929 from devitocodes/JDBetteridge/misc_test_fixes
tests: Miscellaneous fixes for the test suite
2 parents 0aa772b + 2458298 commit 78741f4

10 files changed

Lines changed: 53 additions & 23 deletions

File tree

‎conftest.py‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from sympy.printing import sstr
99

1010
from devito import Eq, Revolver, configuration # noqa
11-
from devito.arch import Arm, Cpu64, Device, get_advisor_path, sniff_mpi_distro
11+
from devito.arch import Arm, Cpu64, Device, Power, get_advisor_path, sniff_mpi_distro
1212
from devito.arch.compiler import (
13-
IntelCompiler, NvidiaCompiler, OneapiCompiler, compiler_registry
13+
GNUCompiler, IntelCompiler, NvidiaCompiler, OneapiCompiler, compiler_registry
1414
)
1515
from devito.checkpointing import NoopRevolver
1616
from devito.finite_differences.differentiable import EvalDerivative
@@ -35,10 +35,19 @@ def skipif(items, whole_module=False):
3535
items = as_tuple(items)
3636
# Sanity check
3737
accepted = set()
38-
accepted.update({'device', 'device-C', 'device-openmp', 'device-openacc',
39-
'device-aomp', 'cpu64-icc', 'cpu64-icx', 'cpu64-nvc',
40-
'noadvisor', 'cpu64-arm', 'cpu64-icpx', 'chkpnt'})
41-
accepted.update({'nodevice', 'noomp'})
38+
accepted.update({
39+
# GPU (device-language)
40+
'device', 'device-C', 'device-openmp', 'device-openacc', 'device-aomp',
41+
# CPU (cpu64-instruction set)
42+
'cpu64-icc', 'cpu64-icx', 'cpu64-nvc', 'cpu64-icpx',
43+
# CPU (cpu64-architecture)
44+
'cpu64-arm',
45+
# CPU (cpu64-architecture-compiler)
46+
'cpu64-power-gcc',
47+
# Miscellaneous
48+
'chkpnt'
49+
})
50+
accepted.update({'noadvisor', 'nodevice', 'noomp'})
4251
unknown = sorted(set(items) - accepted)
4352
if unknown:
4453
raise ValueError(f"Illegal skipif argument(s) `{unknown}`")
@@ -97,6 +106,11 @@ def skipif(items, whole_module=False):
97106
if i == 'cpu64-arm' and isinstance(configuration['platform'], Arm):
98107
skipit = "Arm doesn't support x86-specific instructions"
99108
break
109+
if i == 'cpu64-power-gcc' and \
110+
isinstance(configuration['platform'], Power) and \
111+
isinstance(configuration['compiler'], GNUCompiler):
112+
skipit = "GCC cannot compile these POWER instructions"
113+
break
100114
# Skip if pyrevolve not installed
101115
if i == 'chkpnt' and Revolver is NoopRevolver:
102116
skipit = "pyrevolve not installed"

‎devito/__init__.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ def _preprocess_autopadding(v):
128128
[False, True, 0, 1, np.float16, np.float32, np.float64],
129129
preprocessor=_preprocess_autopadding)
130130

131+
# Use any GPU present on the node to set parameters such as the autopadding
132+
# value. This can be disabled by setting this parameter to , but should not be
133+
# toggled. By setting the value to 'cpu-only' the user is promising that they
134+
# will not try to use the GPU at any point during the running of their script,
135+
# this is useful when iGPUs, APUs or disabled GPUs are present on a node.
136+
configuration.add('autopadding-mode', None, [None, 'cpu-only'])
137+
131138
# Select target device
132139
configuration.add('deviceid', -1, preprocessor=int, impacts_jit=False)
133140

‎devito/arch/archinfo.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import psutil
1616
from packaging.version import InvalidVersion, parse
1717

18+
from devito import configuration
1819
from devito.logger import warning
1920
from devito.tools import all_equal, as_tuple, memoized_func
2021

@@ -1245,7 +1246,7 @@ def node_max_mem_trans_nbytes(platform):
12451246

12461247
if isinstance(platform, Cpu64):
12471248
gpu_info = get_gpu_info()
1248-
if not gpu_info:
1249+
if configuration['autopadding-mode'] == 'cpu-only' or not gpu_info:
12491250
# This node may simply not have a GPU
12501251
return mmtb0
12511252

‎devito/logger.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ def set_log_level(level, comm=None):
9393
from devito import configuration
9494

9595
if comm is not None and configuration['mpi']:
96-
if comm.rank != 0:
96+
from devito.mpi.distributed import MPI
97+
if comm is not MPI.COMM_NULL and comm.rank != 0:
9798
logger.removeHandler(stream_handler)
9899
logger.addHandler(logging.NullHandler())
99100
else:

‎devito/parameters.py‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,21 @@ def _signature_items(self):
141141

142142
env_vars_mapper = {
143143
'DEVITO_ARCH': 'compiler',
144-
'DEVITO_PLATFORM': 'platform',
145-
'DEVITO_PROFILING': 'profiling',
144+
'DEVITO_AUTOPADDING_MODE': 'autopadding-mode',
145+
'DEVITO_AUTOTUNING': 'autotuning',
146146
'DEVITO_DEVELOP': 'develop-mode',
147-
'DEVITO_OPT': 'opt',
148-
'DEVITO_MPI': 'mpi',
149-
'DEVITO_TOPOLOGY': 'topology',
150147
'DEVITO_DEVICEID': 'deviceid',
151-
'DEVITO_LANGUAGE': 'language',
152-
'DEVITO_AUTOTUNING': 'autotuning',
153-
'DEVITO_LOGGING': 'log-level',
154148
'DEVITO_FIRST_TOUCH': 'first-touch',
155-
'DEVITO_JIT_BACKDOOR': 'jit-backdoor',
156149
'DEVITO_IGNORE_UNKNOWN_PARAMS': 'ignore-unknowns',
157-
'DEVITO_SAFE_MATH': 'safe-math'
150+
'DEVITO_JIT_BACKDOOR': 'jit-backdoor',
151+
'DEVITO_LANGUAGE': 'language',
152+
'DEVITO_LOGGING': 'log-level',
153+
'DEVITO_MPI': 'mpi',
154+
'DEVITO_OPT': 'opt',
155+
'DEVITO_PLATFORM': 'platform',
156+
'DEVITO_PROFILING': 'profiling',
157+
'DEVITO_SAFE_MATH': 'safe-math',
158+
'DEVITO_TOPOLOGY': 'topology',
158159
}
159160

160161
env_vars_deprecated = {

‎devito/passes/iet/parpragma.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def _make_partree(self, candidates, nthreads=None):
294294
prefix = []
295295
elif nthreads is not None:
296296
body = self.HostIteration(schedule='static',
297-
parallel=nthreads is not self.nthreads_nested,
297+
parallel=nthreads is not self.nthreads,
298298
ncollapsed=ncollapsed, nthreads=nthreads,
299299
**root.args)
300300
prefix = []

‎tests/test_autotuner.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ def test_hierarchical_blocking(opt_options):
290290
assert len(op._state['autotuning'][1]['tuned']) == 4
291291

292292

293+
@skipif('cpu64-power-gcc')
293294
@switchconfig(platform='cpu64-dummy', develop_mode=True) # `cpu64-dummy `to fix ncores
294295
@pytest.mark.parametrize('opt_options', [{'skewing': False}, {'skewing': True}])
295296
def test_multiple_threads(opt_options):
@@ -309,7 +310,7 @@ def test_multiple_threads(opt_options):
309310
assert len(op._state['autotuning'][0]['tuned']) == 3
310311

311312

312-
@skipif('cpu64-arm')
313+
@skipif(['cpu64-arm', 'cpu64-power-gcc'])
313314
@switchconfig(platform='knl7210', develop_mode=True) # `knl7210` for nested parallelsim
314315
def test_nested_nthreads():
315316
grid = Grid(shape=(96, 96, 96))

‎tests/test_data.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ def test_w_halo_wo_padding(self):
362362
) == u2.shape_with_halo
363363
assert u2.shape_with_halo == (11, 11, 11)
364364

365-
@switchconfig(autopadding=True, platform='bdw')
365+
# Platform is used to fix the pad value
366+
# GPU is disabled to prevent GPU pad value from being used
367+
@switchconfig(autopadding_mode='cpu-only', autopadding=True, platform='bdw')
366368
def test_w_halo_w_autopadding(self):
367369
grid = Grid(shape=(4, 4, 4))
368370
u0 = Function(name='u0', grid=grid, space_order=0)

‎tests/test_dle.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ def test_incr_perfect_outer(self):
10571057
op()
10581058
assert np.all(w.data == 10)
10591059

1060+
@skipif('cpu64-power-gcc')
10601061
def test_incr_perfect_sparse_outer(self):
10611062
grid = Grid(shape=(3, 3, 3))
10621063

‎tests/test_mpi.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from devito.mpi.distributed import CustomTopology
2222
from devito.mpi.routines import ComputeCall, HaloUpdateCall, HaloUpdateList, MPICall
2323
from devito.tools import Bunch
24+
from devito.types.dimension import ModuloDimension
2425
from examples.seismic.acoustic import acoustic_setup
2526

2627

@@ -3289,8 +3290,9 @@ def test_interpolation_at_uforward(self, mode):
32893290

32903291
calls, _ = check_halo_exchanges(op, 2, 1)
32913292
args = calls[0].arguments
3292-
assert args[-2].name == 't2'
3293-
assert args[-2].origin == t + 1
3293+
t2 = next(filter(lambda a: isinstance(a, ModuloDimension), args))
3294+
assert t2.name == 't2'
3295+
assert t2.origin == t + 1
32943296

32953297

32963298
def gen_serial_norms(shape, so):

0 commit comments

Comments
 (0)