Newer
Older
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
import numpy as np
import numpy.linalg as la # noqa: F401
import pyopencl as cl # noqa: F401
import pyopencl.array # noqa
import pyopencl.tools # noqa
import pyopencl.clrandom # noqa
import loopy as lp # noqa
import sys
import logging
import pytest
from pyopencl.tools import ( # noqa
pytest_generate_tests_for_pyopencl
as pytest_generate_tests)
import utilities as u
@pytest.mark.slow
def test_compute_flux_derivatives(ctx_factory):
prg = u.get_weno_program()
queue = u.get_queue(ctx_factory)
prg = prg.copy(target=lp.PyOpenCLTarget(queue.device))
lp.auto_test_vs_ref(prg, ctx_factory(), warmup_rounds=1,
parameters=dict(ndim=3, nvars=5, nx=16, ny=16, nz=16))
@pytest.mark.slow
def test_compute_flux_derivatives_gpu(ctx_factory, write_code=False):
prg = u.get_weno_program()
prg = u.transform_weno_for_gpu(prg)
queue = u.get_queue(ctx_factory)
prg = prg.copy(target=lp.PyOpenCLTarget(queue.device))
prg = lp.set_options(prg, no_numpy=True)
if write_code:
u.write_target_device_code(prg)
lp.auto_test_vs_ref(prg, ctx_factory(), warmup_rounds=1,
parameters=dict(ndim=3, nvars=5, nx=16, ny=16, nz=16))
# This lets you run 'python test.py test_case(cl._csc)' without pytest.
if __name__ == "__main__":
if len(sys.argv) > 1:
logging.basicConfig(level="INFO")
exec(sys.argv[1])
else:
pytest.main([__file__])