Opened 2 years ago

Last modified 20 months ago

#842 new defect

allow specification of single and double precision opencl device

Reported by: pkienzle Owned by:
Priority: minor Milestone: SasView 4.3.0
Component: SasView Keywords:
Cc: Work Package: SasView Bug Fixing


The OpenCL setup dialog doesn't allow for the selection of single and double precision devices. If the device is single precision only and the model does not support single precision then the DLL is used even if there is a double precision device available.

Change History (2)

comment:1 Changed 2 years ago by pkienzle

The following patch allows both single and double precision devices to be set in the environment variable, separated by a comma:

diff --git a/sasmodels/ b/sasmodels/
index 2f4e4c4..d576d87 100644
--- a/sasmodels/
+++ b/sasmodels/
@@ -278,12 +278,18 @@ class GpuEnvironment(object):
         this if SAS_OPENCL is set in the environment.  Sets the *context*
+        context_spec = os.environ["PYOPENCL_CTX"]
-            self.context = [cl.create_some_context(interactive=False)]
+            self.context = []
+            for ctx in context_spec.split(','):
+                os.environ["PYOPENCL_CTX"] = ctx
+                self.context.append(cl.create_some_context(interactive=False))
         except Exception as exc:
             warnings.warn("pyopencl.create_some_context() failed")
             warnings.warn("the environment variable 'SAS_OPENCL' might not be set correctly")
+        finally:
+            os.environ["PYOPENCL_CTX"] = context_spec
     def compile_program(self, name, source, dtype, fast, timestamp):
         # type: (str, str, np.dtype, bool, float) -> cl.Program

comment:2 Changed 20 months ago by butler

  • Milestone changed from SasView 4.2.0 to SasView 4.3.0
Note: See TracTickets for help on using tickets.