aboutsummaryrefslogtreecommitdiff
path: root/boltzgen/kernel/target/layout/cpp.py
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-10-27 16:03:07 +0100
committerAdrian Kummerlaender2019-10-27 16:10:33 +0100
commit6938758f6c1754f0ee49d0709dd0ca376a146010 (patch)
tree53e196ae894bba8610f26fd9b418b802f9797a03 /boltzgen/kernel/target/layout/cpp.py
parent74c60dcbe56862d73b000d569423cb298fb06686 (diff)
downloadboltzgen-6938758f6c1754f0ee49d0709dd0ca376a146010.tar
boltzgen-6938758f6c1754f0ee49d0709dd0ca376a146010.tar.gz
boltzgen-6938758f6c1754f0ee49d0709dd0ca376a146010.tar.bz2
boltzgen-6938758f6c1754f0ee49d0709dd0ca376a146010.tar.xz
boltzgen-6938758f6c1754f0ee49d0709dd0ca376a146010.zip
Move layout implementations into separate folder
Diffstat (limited to 'boltzgen/kernel/target/layout/cpp.py')
-rw-r--r--boltzgen/kernel/target/layout/cpp.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/boltzgen/kernel/target/layout/cpp.py b/boltzgen/kernel/target/layout/cpp.py
new file mode 100644
index 0000000..bb5dba0
--- /dev/null
+++ b/boltzgen/kernel/target/layout/cpp.py
@@ -0,0 +1,33 @@
+class AOS:
+ def __init__(self, descriptor, geometry):
+ self.descriptor = descriptor
+ self.geometry = geometry
+
+ def gid_offset(self):
+ return self.descriptor.q
+
+ def pop_offset(self, i):
+ return i
+
+ def neighbor_offset(self, c_i):
+ return self.descriptor.q * {
+ 2: lambda: c_i[0]*self.geometry.size_y + c_i[1],
+ 3: lambda: c_i[0]*self.geometry.size_y*self.geometry.size_z + c_i[1]*self.geometry.size_z + c_i[2]
+ }.get(self.descriptor.d)()
+
+class SOA:
+ def __init__(self, descriptor, geometry):
+ self.descriptor = descriptor
+ self.geometry = geometry
+
+ def gid_offset(self):
+ return 1
+
+ def pop_offset(self, i):
+ return i * self.geometry.volume
+
+ def neighbor_offset(self, c_i):
+ return {
+ 2: lambda: c_i[0]*self.geometry.size_y + c_i[1],
+ 3: lambda: c_i[0]*self.geometry.size_y*self.geometry.size_z + c_i[1]*self.geometry.size_z + c_i[2]
+ }.get(self.descriptor.d)()