diff options
author | Adrian Kummerlaender | 2019-10-27 16:11:17 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2019-10-27 16:11:17 +0100 |
commit | 30f262287bd43015b155b0e882e6478cfae2780c (patch) | |
tree | a55eb36d31ae3d630e3359b8a0b775d85f4547d9 | |
parent | 6938758f6c1754f0ee49d0709dd0ca376a146010 (diff) | |
download | boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.tar boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.tar.gz boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.tar.bz2 boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.tar.lz boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.tar.xz boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.tar.zst boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.zip |
Extract target-dependent floating point type name
-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) |