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
import numpy as np
import pyopencl as cl
import loopy as lp
import sys
from pyopencl.tools import ( # noqa
pytest_generate_tests_for_pyopencl
as pytest_generate_tests)
_WENO_PRG = []
def get_weno_program():
if _WENO_PRG:
return _WENO_PRG[0]
fn = "WENO.F90"
with open(fn, "r") as infile:
infile_content = infile.read()
prg = lp.parse_transformed_fortran(infile_content, filename=fn)
_WENO_PRG.append(prg)
return prg
def test_matvec(ctx_factory):
prg = get_weno_program()
prg = prg.copy(name="mult_mat_vec")
prg = lp.preprocess_kernel(prg)
print(prg)
# This lets you run 'python test.py test_case(cl._csc)' without pytest.
if __name__ == "__main__":
if len(sys.argv) > 1:
exec(sys.argv[1])
else:
from pytest import main
main([__file__])