diff options
author | Adrian Kummerlaender | 2019-10-26 12:40:35 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2019-10-26 12:40:35 +0200 |
commit | 8e968727a9c2c5a1b3be858b1102e70651f34168 (patch) | |
tree | aceca27b4f23d2967808ebd6eff992567f381b96 | |
parent | 58d926cb7329a0da941ab1f3451ec0282795811c (diff) | |
download | boltzgen-8e968727a9c2c5a1b3be858b1102e70651f34168.tar boltzgen-8e968727a9c2c5a1b3be858b1102e70651f34168.tar.gz boltzgen-8e968727a9c2c5a1b3be858b1102e70651f34168.tar.bz2 boltzgen-8e968727a9c2c5a1b3be858b1102e70651f34168.tar.lz boltzgen-8e968727a9c2c5a1b3be858b1102e70651f34168.tar.xz boltzgen-8e968727a9c2c5a1b3be858b1102e70651f34168.tar.zst boltzgen-8e968727a9c2c5a1b3be858b1102e70651f34168.zip |
Generalize floating point precision argument
-rw-r--r-- | boltzgen.py | 2 | ||||
-rw-r--r-- | boltzgen/kernel/generator.py | 5 | ||||
-rw-r--r-- | boltzgen/kernel/template/basic.cpp.mako | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/boltzgen.py b/boltzgen.py index e5a8588..b487b07 100644 --- a/boltzgen.py +++ b/boltzgen.py @@ -6,7 +6,7 @@ from boltzgen import * argparser = argparse.ArgumentParser(description='Generate LBM kernels in various languages using a symbolic description.') argparser.add_argument('language', help = 'Target language (currently either "cl" or "cpp")') argparser.add_argument('--layout', dest = 'layout', help = 'Memory layout ("AOS" or "SOA")', required = True) -argparser.add_argument('--precision', dest = 'precision', help = 'Floating precision ("float" or "double")', required = True) +argparser.add_argument('--precision', dest = 'precision', help = 'Floating precision ("single" or "double")', required = True) args = argparser.parse_args() diff --git a/boltzgen/kernel/generator.py b/boltzgen/kernel/generator.py index e897325..d91ddd5 100644 --- a/boltzgen/kernel/generator.py +++ b/boltzgen/kernel/generator.py @@ -35,7 +35,10 @@ class Generator: collision_subexpr = self.collision[0], collision_assignment = self.collision[1], - float_type = precision, + float_type = { + 'single': 'float', + 'double': 'double' + }.get(precision), boundary_src = Template(self.boundary).render( descriptor = self.descriptor, diff --git a/boltzgen/kernel/template/basic.cpp.mako b/boltzgen/kernel/template/basic.cpp.mako index 529c1de..1036c8f 100644 --- a/boltzgen/kernel/template/basic.cpp.mako +++ b/boltzgen/kernel/template/basic.cpp.mako @@ -131,7 +131,7 @@ void test(std::size_t nStep) std::cout << "MLUPS: " << nStep*${geometry.volume}/(1e6*duration.count()) << std::endl; // calculate average rho as a basic quality check - double rho_sum = 0.0; + ${float_type} rho_sum = 0.0; for (std::size_t i = 0; i < ${geometry.volume*descriptor.q}; ++i) { rho_sum += f_next[i]; |