11import numpy as np
2- import pyopencl as cl
2+ import pyopencl as cl # noqa
33import loopy as lp
44
55from pyopencl .tools import pytest_generate_tests_for_pyopencl \
6- as pytest_generate_tests
7-
8-
6+ as pytest_generate_tests # noqa
97
108
119def test_laplacian_stiffness (ctx_factory ):
1210 dtype = np .float32
1311 ctx = ctx_factory ()
1412 order = "C"
1513
16- dim = 2 # (baked into code)
14+ dim = 2 # (baked into code)
1715
18- Nq = 40 # num. quadrature points (baked into code)
19- Nb = 20 # num. basis functions (baked into code)
20- Nc = 100 # num. cells (run-time symbolic)
16+ Nq = 40 # num. quadrature points (baked into code) # noqa
17+ Nb = 20 # num. basis functions (baked into code) # noqa
18+ Nc = 100 # num. cells (run-time symbolic) # noqa
2119
2220 from pymbolic import var
23- Nc_sym = var ("Nc" )
21+ Nc_sym = var ("Nc" ) # noqa
2422
2523 knl = lp .make_kernel (ctx .devices [0 ],
26- "[Nc] -> {[K,i,j,q, dx_axis, ax_b]: 0<=K<Nc and 0<=i,j<%(Nb)d and 0<=q<%(Nq)d "
24+ "[Nc] -> {[K,i,j,q, dx_axis, ax_b]: 0<=K<Nc and 0<=i,j<%(Nb)d and 0<=q<%(Nq)d " # noqa
2725 "and 0<= dx_axis, ax_b < %(dim)d}"
2826 % dict (Nb = Nb , Nq = Nq , dim = dim ),
2927 [
3028 "dPsi(ij, dxi) := sum_float32(@ax_b,"
31- " jacInv[ax_b,dxi,K,q] * DPsi[ax_b,ij,q])" ,
29+ " jacInv[ax_b,dxi,K,q] * DPsi[ax_b,ij,q])" , # noqa
3230 "A[K, i, j] = sum_float32(q, w[q] * jacDet[K,q] * ("
3331 "sum_float32(dx_axis, dPsi$one(i,dx_axis)*dPsi$two(j,dx_axis))))"
3432 ],
@@ -55,15 +53,15 @@ def variant_pg4(knl):
5553 # This (mostly) reproduces the unlabeled code snippet on pg. 4.
5654
5755 knl = lp .tag_inames (knl , {"dx_axis" : "unr" })
58- Ncloc = 16
56+ Ncloc = 16 # noqa
5957 knl = lp .split_iname (knl , "K" , Ncloc ,
6058 outer_iname = "Ko" , inner_iname = "Kloc" )
6159 return knl , ["Ko" , "Kloc" , "i" , "j" , "q" , "ax_b_insn" ]
6260
6361 def variant_fig32 (knl ):
6462 # This (mostly) reproduces Figure 3.2.
6563
66- Ncloc = 16
64+ Ncloc = 16 # noqa
6765 knl = lp .split_iname (knl , "K" , Ncloc ,
6866 outer_iname = "Ko" , inner_iname = "Kloc" )
6967 knl = lp .precompute (knl , "dPsi" , np .float32 , ["i" , "q" , "dx_axis" ],
@@ -74,10 +72,10 @@ def variant_fig32(knl):
7472 def variant_fig33 (knl ):
7573 # This is meant to (mostly) reproduce Figure 3.3.
7674
77- Ncloc = 16
75+ Ncloc = 16 # noqa
7876 knl = lp .split_iname (knl , "K" , Ncloc ,
7977 outer_iname = "Ko" , inner_iname = "Kloc" )
80- knl = lp .precompute (knl , "dPsi$one" , np .float32 , ["dx_axis" ], default_tag = None )
78+ knl = lp .precompute (knl , "dPsi$one" , np .float32 , ["dx_axis" ], default_tag = None ) # noqa
8179 knl = lp .tag_inames (knl , {"j" : "ilp.seq" })
8280
8381 return knl , ["Ko" , "Kloc" ]
@@ -90,7 +88,7 @@ def variant_simple_gpu(knl):
9088 # help, too. :)
9189
9290 knl = lp .tag_inames (knl , {"dx_axis" : "unr" })
93- Ncloc = 16
91+ Ncloc = 16 # noqa
9492 knl = lp .split_iname (knl , "K" , Ncloc ,
9593 outer_iname = "Ko" , inner_iname = "Kloc" ,
9694 outer_tag = "g.0" )
@@ -105,7 +103,7 @@ def variant_simple_gpu_prefetch(knl):
105103 # fix that. (FIXME)
106104
107105 knl = lp .tag_inames (knl , {"dx_axis" : "unr" })
108- Ncloc = 16
106+ Ncloc = 16 # noqa
109107 knl = lp .split_iname (knl , "K" , Ncloc ,
110108 outer_iname = "Ko" , inner_iname = "Kloc" ,
111109 outer_tag = "g.0" )
@@ -132,13 +130,10 @@ def variant_simple_gpu_prefetch(knl):
132130 parameters = {"Nc" : Nc }, print_ref_code = True )
133131
134132
135-
136-
137133if __name__ == "__main__" :
138134 import sys
139135 if len (sys .argv ) > 1 :
140136 exec (sys .argv [1 ])
141137 else :
142138 from py .test .cmdline import main
143139 main ([__file__ ])
144-
0 commit comments