forked from devitocodes/devito
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_benchmark.py
More file actions
87 lines (74 loc) · 2.62 KB
/
Copy pathtest_benchmark.py
File metadata and controls
87 lines (74 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import pytest
import os
import sys
from benchmarks.user.benchmark import run
from devito import configuration, switchconfig
from subprocess import check_call
@pytest.mark.parametrize('mode, problem, op', [
('run', 'acoustic', 'forward'), ('run', 'acoustic', 'adjoint'),
('run', 'acoustic', 'jacobian'), ('run', 'acoustic', 'jacobian_adjoint'),
('run', 'tti', 'forward'), ('run', 'elastic', 'forward'),
('run', 'viscoelastic', 'forward'), ('run', 'acoustic_sa', 'forward'),
('run', 'acoustic_sa', 'adjoint'), ('run', 'acoustic_sa', 'jacobian'),
('run', 'acoustic_sa', 'jacobian_adjoint'), ('run', 'tti', 'jacobian_adjoint')
])
def test_bench(mode, problem, op):
"""
Test the Devito benchmark framework on various combinations of modes and problems.
"""
tn = 4
nx, ny, nz = 16, 16, 16
if configuration['language'] == 'openmp':
nthreads = int(os.environ.get('OMP_NUM_THREADS',
configuration['platform'].cores_physical))
else:
nthreads = 1
pyversion = sys.executable
baseline = os.path.realpath(__file__).split("tests/test_benchmark.py")[0]
benchpath = '%sbenchmarks/user/benchmark.py' % baseline
command_bench = [pyversion, benchpath, mode,
'-P', problem, '-d', '%d' % nx, '%d' % ny, '%d' % nz, '--tn',
'%d' % tn, '-op', op]
if mode == "bench":
command_bench.extend(['-x', '1'])
check_call(command_bench)
dir_name = 'results/'
base_filename = problem
filename_suffix = '.json'
arch = 'arch[unknown]'
shape = 'shape[%d,%d,%d]' % (nx, ny, nz)
nbl = 'nbl[10]'
t = 'tn[%d]' % tn
so = 'so[2]'
to = 'to[2]'
opt = 'opt[advanced]'
at = 'at[aggressive]'
nt = 'nt[%d]' % nthreads
mpi = 'mpi[False]'
np = 'np[1]'
rank = 'rank[0]'
if mode == "bench":
bench_corename = os.path.join('_'.join([base_filename, arch, shape, nbl, t,
so, to, opt, at, nt, mpi, np, rank]))
bench_filename = "%s%s%s" % (dir_name, bench_corename, filename_suffix)
assert os.path.isfile(bench_filename)
else:
assert True
@pytest.mark.parallel(mode=2)
@switchconfig(profiling='advanced')
def test_run_mpi():
"""
Test the `run` mode over MPI, with all key arguments used.
"""
kwargs = {
'space_order': [4],
'time_order': [2],
'autotune': 'off',
'block_shape': [],
'shape': (16, 16, 16),
'tn': 4,
'warmup': False,
'dump_summary': 'summary.txt',
'dump_norms': 'norms.txt'
}
run('acoustic', **kwargs)