aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-10-27 16:11:17 +0100
committerAdrian Kummerlaender2019-10-27 16:11:17 +0100
commit30f262287bd43015b155b0e882e6478cfae2780c (patch)
treea55eb36d31ae3d630e3359b8a0b775d85f4547d9
parent6938758f6c1754f0ee49d0709dd0ca376a146010 (diff)
downloadboltzgen-30f262287bd43015b155b0e882e6478cfae2780c.tar
boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.tar.gz
boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.tar.bz2
boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.tar.xz
boltzgen-30f262287bd43015b155b0e882e6478cfae2780c.zip
Extract target-dependent floating point type name
-rw-r--r--boltzgen/kernel/generator.py6
-rw-r--r--boltzgen/kernel/target/precision.py15
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)