From 30f262287bd43015b155b0e882e6478cfae2780c Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 27 Oct 2019 16:11:17 +0100 Subject: Extract target-dependent floating point type name --- boltzgen/kernel/generator.py | 6 ++---- boltzgen/kernel/target/precision.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 boltzgen/kernel/target/precision.py diff --git a/boltzgen/kernel/generator.py b/boltzgen/kernel/generator.py index ebe1018..47fb245 100644 --- a/boltzgen/kernel/generator.py +++ b/boltzgen/kernel/generator.py @@ -4,6 +4,7 @@ from mako.template import Template from pathlib import Path import kernel.target.layout +import kernel.target.precision class Generator: def __init__(self, descriptor, moments, collision): @@ -42,9 +43,6 @@ class Generator: if geometry.dimension() != self.descriptor.d: raise Exception('Geometry dimension must match descriptor dimension') - float_type = { - 'single': 'float', - 'double': 'double' - }.get(precision) + float_type = eval("kernel.target.precision.%s" % target).get_float_type(precision) return "\n".join(map(lambda f: self.instantiate(target, f, float_type, layout_impl, geometry, extras), functions)) diff --git a/boltzgen/kernel/target/precision.py b/boltzgen/kernel/target/precision.py new file mode 100644 index 0000000..45f84cf --- /dev/null +++ b/boltzgen/kernel/target/precision.py @@ -0,0 +1,15 @@ +class cpp: + @classmethod + def get_float_type(self, precision): + return { + 'single': 'float', + 'double': 'double' + }.get(precision) + +class cl: + @classmethod + def get_float_type(self, precision): + return { + 'single': 'float', + 'double': 'double' + }.get(precision) -- cgit v1.2.3