diff options
-rw-r--r-- | boltzgen/kernel/generator.py | 6 | ||||
-rw-r--r-- | boltzgen/kernel/target/precision.py | 15 |
2 files changed, 17 insertions, 4 deletions
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) |