Changeset b3f6bc3 in sasmodels for sasmodels/gpu.py
- Timestamp:
- Feb 15, 2015 4:07:00 PM (9 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:
- f786ff3
- Parents:
- cb6ecf4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/gpu.py
rcb6ecf4 rb3f6bc3 24 24 """ 25 25 import numpy as np 26 26 27 import pyopencl as cl 27 28 from pyopencl import mem_flags as mf 28 29 29 30 from . import generate 31 from .pykernel import PyInput, PyKernel 30 32 31 33 F64_DEFS = """\ … … 185 187 186 188 def __call__(self, input): 189 # Support pure python kernel call 190 if input.is_2D and callable(self.info['Iqxy']): 191 return PyKernel(self.info['Iqxy'], self.info, input) 192 elif not input.is_2D and callable(self.info['Iq']): 193 return PyKernel(self.info['Iq'], self.info, input) 194 187 195 if self.dtype != input.dtype: 188 196 raise TypeError("data and kernel have different types") … … 202 210 Make q input vectors available to the model. 203 211 204 This only needs to be done once for all models that operate on the 205 same input. So for example, if you are adding two different models 206 together to compare to a data set, then only one model needs to 207 needs to call make_input, so long as the models have the same dtype. 212 Note that each model needs its own q vector even if the case of 213 mixture models because some models may be OpenCL, some may be 214 ctypes and some may be pure python. 208 215 """ 209 # Note: the weird interface, where make_input doesn't care which 210 # model calls it, allows us to ask the model to define the data 211 # and the caller does not need to know if it is opencl or ctypes. 212 # The returned data object is opaque. 213 return GpuInput(q_vectors, dtype=self.dtype) 216 # Support pure python kernel call 217 if len(q_vectors) == 1 and callable(self.info['Iq']): 218 return PyInput(q_vectors, dtype=self.dtype) 219 elif callable(self.info['Iqxy']): 220 return PyInput(q_vectors, dtype=self.dtype) 221 else: 222 return GpuInput(q_vectors, dtype=self.dtype) 214 223 215 224 # TODO: check that we don't need a destructor for buffers which go out of scope
Note: See TracChangeset
for help on using the changeset viewer.