Changeset 250fa25 in sasmodels
- Timestamp:
- Feb 16, 2015 9:01:09 AM (10 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 10576d1
- Parents:
- f786ff3
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernelcl.py
rf786ff3 r250fa25 23 23 factors and have instrumental resolution effects applied. 24 24 """ 25 import os 26 import warnings 27 25 28 import numpy as np 26 29 27 import pyopencl as cl 30 try: 31 import pyopencl as cl 32 except ImportError,exc: 33 warnings.warn(str(exc)) 34 raise RuntimeError("OpenCL not available") 35 28 36 from pyopencl import mem_flags as mf 29 37 … … 140 148 """ 141 149 def __init__(self): 142 self.context = cl.create_some_context() 143 self.queues = [cl.CommandQueue(self.context, d) 144 for d in self.context.devices] 150 # find gpu context 151 #self.context = cl.create_some_context() 152 153 self.context = None 154 if 'PYOPENCL_CTX' in os.environ: 155 self._create_some_context() 156 157 if not self.context: 158 self.context = self._find_context() 159 145 160 # Byte boundary for data alignment 146 161 #self.data_boundary = max(d.min_data_type_align_size 147 162 # for d in self.context.devices) 163 self.queues = [cl.CommandQueue(self.context, d) 164 for d in self.context.devices] 148 165 self.has_double = all(has_double(d) for d in self.context.devices) 149 166 self.compiled = {} 167 168 def _create_some_context(self): 169 try: 170 self.context = cl.create_some_context(interactive=False) 171 except Exception,exc: 172 warnings.warn(str(exc)) 173 warnings.warn("pyopencl.create_some_context() failed") 174 warnings.warn("the environment variable 'PYOPENCL_CTX' might not be set correctly") 175 176 def _find_context(self): 177 default = None 178 for platform in cl.get_platforms(): 179 for device in platform.get_devices(): 180 if device.type == cl.device_type.GPU: 181 return cl.Context([device]) 182 if default is None: 183 default = device 184 185 if not default: 186 raise RuntimeError("OpenCL device not found") 187 188 return cl.Context([default]) 150 189 151 190 def compile_program(self, name, source, dtype): … … 159 198 self.compiled[name].release() 160 199 del self.compiled[name] 200 161 201 162 202 class GpuModel(object): -
sasmodels/sasview_model.py
rf786ff3 r250fa25 28 28 except ImportError,exc: 29 29 warnings.warn(str(exc)) 30 warnings.warn(" OpenCL not available ---using ctypes instead")30 warnings.warn("using ctypes instead") 31 31 from .kerneldll import load_model 32 32
Note: See TracChangeset
for help on using the changeset viewer.