aboutsummaryrefslogtreecommitdiff
path: root/standalone_cpp_codegen.py
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-07-23 23:20:24 +0200
committerAdrian Kummerlaender2019-07-23 23:20:24 +0200
commit6e6624e5f90565e6b022f26fca1f32c5b28abed9 (patch)
tree708e186d9bcaf7dc87901f6d8fe0b5aeda759079 /standalone_cpp_codegen.py
parentb71608dd58d8ce38bc9f56615d7c2da1606975d1 (diff)
downloadsymlbm_playground-6e6624e5f90565e6b022f26fca1f32c5b28abed9.tar
symlbm_playground-6e6624e5f90565e6b022f26fca1f32c5b28abed9.tar.gz
symlbm_playground-6e6624e5f90565e6b022f26fca1f32c5b28abed9.tar.bz2
symlbm_playground-6e6624e5f90565e6b022f26fca1f32c5b28abed9.tar.lz
symlbm_playground-6e6624e5f90565e6b022f26fca1f32c5b28abed9.tar.xz
symlbm_playground-6e6624e5f90565e6b022f26fca1f32c5b28abed9.tar.zst
symlbm_playground-6e6624e5f90565e6b022f26fca1f32c5b28abed9.zip
Generate basic example in plain C++
An attempt to produce a minimal LBM implementation to benchmark various memory and vectorization schemes on the CPU.
Diffstat (limited to 'standalone_cpp_codegen.py')
-rw-r--r--standalone_cpp_codegen.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/standalone_cpp_codegen.py b/standalone_cpp_codegen.py
new file mode 100644
index 0000000..b38898a
--- /dev/null
+++ b/standalone_cpp_codegen.py
@@ -0,0 +1,32 @@
+import sympy
+from mako.template import Template
+from pathlib import Path
+
+from simulation import Geometry
+from symbolic.generator import LBM
+
+import symbolic.D2Q9 as D2Q9
+
+lbm = LBM(D2Q9)
+
+moments = lbm.moments(optimize = False)
+collide = lbm.bgk(f_eq = lbm.equilibrium(), tau = 0.6)
+
+geometry = Geometry(512, 512)
+
+program_src = Template(filename = str(Path(__file__).parent/'template/standalone.mako')).render(
+ descriptor = lbm.descriptor,
+ geometry = geometry,
+
+ steps = 100,
+
+ moments_subexpr = moments[0],
+ moments_assignment = moments[1],
+ collide_subexpr = collide[0],
+ collide_assignment = collide[1],
+
+ float_type = 'double',
+ ccode = sympy.ccode
+)
+
+print(program_src)