1from kernel_impl
import impl, Enumerator
4 def __init__(self, patch, dim, patch_size, n_patches=1, halo_size=1, file="test.cpp",debug=False,namespace=None):
22 k.namespace(namespace)
26 def halo(self,which=[1,1,1],name=None):
27 its = [[_
for _
in range(0,self.
np)]]
28 for dim
in range(self.
d):
29 start = self.
h - which[dim]
31 raise Exception(
"halo requested too large, increase halo_size")
32 end = self.
p + self.
h + which[dim]
33 its.append([_
for _
in range(start,end)])
34 iterators = [
"patch",
"i",
"j",
"k"]
44 def Evaluate(self, name, expression, enum=None):
45 if type(enum) == type(
None):
46 enum = self.
halo([self.
h for _
in range(self.
d)])
48 if name
not in self.
names:
50 self.
names.append(name)
51 self.
enums[name] = enum.RETURN()
52 k.loop(name,expression,self.
enums,self.
d)
56 def Stencil(self, out_name, names, stencil, scale=1,var_list=[],enum=None,special=None):
57 if type(enum) == type(
None):
58 enum = self.
halo([0,0,0])
60 if out_name
not in self.
names:
61 k.alloc(out_name,enum)
62 self.
names.append(out_name)
63 self.
enums[out_name] = enum
64 k.stencil(out_name,names,stencil,scale,var_list,self.
enums,self.
d,special,enum)
70 for item
in file_list:
71 self.
pre =
'#include "' + item +
'"\n' +self.
pre
79 self.
pre += f
"\nvoid time_step(double* {self.patch}"
83 self.
pre +=
", " + name
84 self.
pre +=
")"+
" {\n"
88 for _
in range(self.
scope):
92 with open(self.
file,
'w')
as FOUT:
Evaluate(self, name, expression, enum=None)
__init__(self, patch, dim, patch_size, n_patches=1, halo_size=1, file="test.cpp", debug=False, namespace=None)
halo(self, which=[1, 1, 1], name=None)
Stencil(self, out_name, names, stencil, scale=1, var_list=[], enum=None, special=None)