aboutsummaryrefslogtreecommitdiff
path: root/simulation.py
diff options
context:
space:
mode:
Diffstat (limited to 'simulation.py')
-rw-r--r--simulation.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/simulation.py b/simulation.py
index 535310f..e2174ee 100644
--- a/simulation.py
+++ b/simulation.py
@@ -153,8 +153,17 @@ class Lattice:
self.platform = cl.get_platforms()[platform]
if opengl:
- self.context = cl.Context(
- properties=[(cl.context_properties.PLATFORM, self.platform)] + get_gl_sharing_context_properties())
+ try:
+ self.context = cl.Context(
+ properties = [
+ (cl.context_properties.PLATFORM, self.platform)
+ ] + get_gl_sharing_context_properties())
+ except:
+ self.context = cl.Context(
+ properties = [
+ (cl.context_properties.PLATFORM, self.platform)
+ ] + get_gl_sharing_context_properties(),
+ devices = [ self.platform.get_devices()[0] ])
else:
self.context = cl.Context(
properties=[(cl.context_properties.PLATFORM, self.platform)])
@@ -252,9 +261,7 @@ class Lattice:
def sync(self):
self.queue.finish()
- def get_moments(self):
- moments = numpy.ndarray(shape=(self.descriptor.d+1, self.memory.volume), dtype=self.float_type[0])
-
+ def update_moments(self):
if self.tick:
self.program.collect_moments(
self.queue, self.grid.size(), self.layout, self.memory.cl_pop_b, self.memory.cl_moments)
@@ -262,6 +269,8 @@ class Lattice:
self.program.collect_moments(
self.queue, self.grid.size(), self.layout, self.memory.cl_pop_a, self.memory.cl_moments)
+ def get_moments(self):
+ moments = numpy.ndarray(shape=(self.descriptor.d+1, self.memory.volume), dtype=self.float_type[0])
+ self.update_moments()
cl.enqueue_copy(self.queue, moments, self.memory.cl_moments).wait();
-
return moments