aboutsummaryrefslogtreecommitdiff
path: root/boltzgen/kernel/template/pattern/AA.cpp.mako
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-11-05 19:57:17 +0100
committerAdrian Kummerlaender2019-11-05 19:57:17 +0100
commit02cb01c94fe26d425371ab74feeb50e8a9bf6bf6 (patch)
treeacfbca6533a1a8d9c22afac9f4be14bf08bb9c63 /boltzgen/kernel/template/pattern/AA.cpp.mako
parent78f5edec8151db38ebf933e915fcca5f65b1cad5 (diff)
downloadboltzgen-02cb01c94fe26d425371ab74feeb50e8a9bf6bf6.tar
boltzgen-02cb01c94fe26d425371ab74feeb50e8a9bf6bf6.tar.gz
boltzgen-02cb01c94fe26d425371ab74feeb50e8a9bf6bf6.tar.bz2
boltzgen-02cb01c94fe26d425371ab74feeb50e8a9bf6bf6.tar.xz
boltzgen-02cb01c94fe26d425371ab74feeb50e8a9bf6bf6.zip
Implement AA pattern for C++ target
Note that special care has to be taken to provide ghost cells around active cells so the algorithm has somewhere to stream to and from. This is also the case for the AB pattern but there they only have to be equilibrilized once instead of after every other time step. Even when such an equilibrilization is performed there is still a potential bug as inbound populations at the outer boundary are never streamed to (this is not a problem for AB using pull-only streaming). A vectorizable solution may require direction-specific ghost cell equilibrization.
Diffstat (limited to 'boltzgen/kernel/template/pattern/AA.cpp.mako')
-rw-r--r--boltzgen/kernel/template/pattern/AA.cpp.mako83
1 files changed, 83 insertions, 0 deletions
diff --git a/boltzgen/kernel/template/pattern/AA.cpp.mako b/boltzgen/kernel/template/pattern/AA.cpp.mako
new file mode 100644
index 0000000..a61bb41
--- /dev/null
+++ b/boltzgen/kernel/template/pattern/AA.cpp.mako
@@ -0,0 +1,83 @@
+<%def name="operator(name, params = None)">
+void ${name}_tick(
+ ${float_type}* f
+ , std::size_t gid
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+ ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${i} = preshifted_f[${layout.pop_offset(i)}];
+% endfor
+
+ ${caller.body()}
+
+% for i, c_i in enumerate(descriptor.c):
+ preshifted_f[${layout.pop_offset(i)}] = f_next_${descriptor.c.index(-c_i)};
+% endfor
+}
+
+void ${name}_tock(
+ ${float_type}* f
+ , std::size_t gid
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+ ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${descriptor.c.index(-c_i)} = preshifted_f[${layout.pop_offset(i) + layout.neighbor_offset(c_i)}];
+% endfor
+
+ ${caller.body()}
+
+% for i, c_i in enumerate(descriptor.c):
+ preshifted_f[${layout.pop_offset(i) + layout.neighbor_offset(c_i)}] = f_next_${i};
+% endfor
+}
+</%def>
+
+<%def name="functor(name, params = None)">
+void ${name}_tick(
+ const ${float_type}* f
+ , std::size_t gid
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+ const ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${i} = preshifted_f[${layout.pop_offset(descriptor.c.index(-c_i))}];
+% endfor
+
+ ${caller.body()}
+}
+
+void ${name}_tock(
+ const ${float_type}* f
+ , std::size_t gid
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+ const ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${i} = preshifted_f[${layout.pop_offset(i) + layout.neighbor_offset(c_i)}];
+% endfor
+
+ ${caller.body()}
+}
+</%def>