Changeset cde11f0f in sasmodels
- Timestamp:
- Dec 23, 2015 10:07:37 AM (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:
- 07e72e6
- Parents:
- e3a9733
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
r5d316e9 rcde11f0f 65 65 return True 66 66 67 def load_model(model_definition, dtype="single", platform="ocl" , fast=False):67 def load_model(model_definition, dtype="single", platform="ocl"): 68 68 """ 69 69 Prepare the model for the default execution platform. … … 83 83 *platform* should be "dll" to force the dll to be used for C models, 84 84 otherwise it uses the default "ocl". 85 86 *fast* is True if fast inaccurate math is acceptable (40% speed increase).87 85 """ 88 86 if isstr(model_definition): … … 101 99 # source = open(info['name']+'.cl','r').read() 102 100 103 dtype = np.dtype(dtype)104 101 if (platform=="dll" 105 102 or not HAVE_OPENCL … … 107 104 return kerneldll.load_dll(source, info, dtype) 108 105 else: 109 return kernelcl.GpuModel(source, info, dtype , fast)106 return kernelcl.GpuModel(source, info, dtype) 110 107 111 108 def make_kernel(model, q_vectors): -
sasmodels/kernelcl.py
r5d316e9 rcde11f0f 183 183 184 184 def has_type(self, dtype): 185 dtype = np.dtype(dtype)185 dtype = generate.F32 if dtype == 'fast' else np.dtype(dtype) 186 186 return all(has_type(d, dtype) for d in self.context.devices) 187 187 … … 195 195 196 196 def compile_program(self, name, source, dtype, fast=False): 197 if name not in self.compiled: 197 key = "%s-%s-%s"%(name, dtype, fast) 198 if key not in self.compiled: 198 199 #print("compiling",name) 199 self.compiled[name] = compile_model(self.context, source, dtype, 200 fast) 201 return self.compiled[name] 200 dtype = np.dtype(dtype) 201 program = compile_model(self.context, source, dtype, fast) 202 self.compiled[key] = program 203 return self.compiled[key] 202 204 203 205 def release_program(self, name): … … 232 234 for single and 'd', 'float64' or 'double' for double. Double precision 233 235 is an optional extension which may not be available on all devices. 234 235 *fast* is True if fast inaccurate math is acceptable (40% speed increase) 236 """ 237 def __init__(self, source, info, dtype=generate.F32, fast=False): 236 Half precision ('float16','half') may be available on some devices. 237 Fast precision ('fast') is a loose version of single precision, indicating 238 that the compiler is allowed to take shortcuts. 239 """ 240 def __init__(self, source, info, dtype=generate.F32): 238 241 self.info = info 239 242 self.source = source 240 self.dtype = np.dtype(dtype)241 self.fast = fast243 self.dtype = generate.F32 if dtype=='fast' else np.dtype(dtype) 244 self.fast = (dtype == 'fast') 242 245 self.program = None # delay program creation 243 246
Note: See TracChangeset
for help on using the changeset viewer.