Changeset 17bbadd in sasmodels for sasmodels/kerneldll.py
- Timestamp:
- Mar 15, 2016 12:47:12 PM (8 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:
- 754e27b
- Parents:
- 5ceb7d0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kerneldll.py
reafc9fa r17bbadd 89 89 90 90 91 def dll_path( info, dtype="double"):92 """ 93 Path to the compiled model defined by * info*.91 def dll_path(model_info, dtype="double"): 92 """ 93 Path to the compiled model defined by *model_info*. 94 94 """ 95 95 from os.path import join as joinpath, split as splitpath, splitext 96 basename = splitext(splitpath( info['filename'])[1])[0]96 basename = splitext(splitpath(model_info['filename'])[1])[0] 97 97 if np.dtype(dtype) == generate.F32: 98 98 basename += "32" … … 104 104 105 105 106 def make_dll(source, info, dtype="double"):106 def make_dll(source, model_info, dtype="double"): 107 107 """ 108 108 Load the compiled model defined by *kernel_module*. … … 123 123 models are allowed as DLLs. 124 124 """ 125 if callable( info.get('Iq', None)):126 return PyModel( info)125 if callable(model_info.get('Iq', None)): 126 return PyModel(model_info) 127 127 128 128 dtype = np.dtype(dtype) … … 133 133 134 134 if dtype == generate.F32: # 32-bit dll 135 tempfile_prefix = 'sas_' +info['name']+'32_'135 tempfile_prefix = 'sas_' + model_info['name'] + '32_' 136 136 elif dtype == generate.F64: 137 tempfile_prefix = 'sas_' +info['name']+'64_'137 tempfile_prefix = 'sas_' + model_info['name'] + '64_' 138 138 else: 139 tempfile_prefix = 'sas_' +info['name']+'128_'139 tempfile_prefix = 'sas_' + model_info['name'] + '128_' 140 140 141 141 source = generate.convert_type(source, dtype) 142 source_files = generate.model_sources( info) + [info['filename']]143 dll = dll_path( info, dtype)142 source_files = generate.model_sources(model_info) + [model_info['filename']] 143 dll = dll_path(model_info, dtype) 144 144 newest = max(os.path.getmtime(f) for f in source_files) 145 145 if not os.path.exists(dll) or os.path.getmtime(dll) < newest: … … 159 159 160 160 161 def load_dll(source, info, dtype="double"):161 def load_dll(source, model_info, dtype="double"): 162 162 """ 163 163 Create and load a dll corresponding to the source, info pair returned … … 167 167 allowed floating point precision. 168 168 """ 169 filename = make_dll(source, info, dtype=dtype)170 return DllModel(filename, info, dtype=dtype)169 filename = make_dll(source, model_info, dtype=dtype) 170 return DllModel(filename, model_info, dtype=dtype) 171 171 172 172 … … 178 178 ctypes wrapper for a single model. 179 179 180 *source* and * info* are the model source and interface as returned180 *source* and *model_info* are the model source and interface as returned 181 181 from :func:`gen.make`. 182 182 … … 188 188 Call :meth:`release` when done with the kernel. 189 189 """ 190 def __init__(self, dllpath, info, dtype=generate.F32):191 self.info = info190 def __init__(self, dllpath, model_info, dtype=generate.F32): 191 self.info = model_info 192 192 self.dllpath = dllpath 193 193 self.dll = None … … 244 244 *kernel* is the c function to call. 245 245 246 * info* is the module information246 *model_info* is the module information 247 247 248 248 *q_input* is the DllInput q vectors at which the kernel should be … … 257 257 Call :meth:`release` when done with the kernel instance. 258 258 """ 259 def __init__(self, kernel, info, q_input):260 self.info = info259 def __init__(self, kernel, model_info, q_input): 260 self.info = model_info 261 261 self.q_input = q_input 262 262 self.kernel = kernel 263 263 self.res = np.empty(q_input.nq, q_input.dtype) 264 264 dim = '2d' if q_input.is_2d else '1d' 265 self.fixed_pars = info['partype']['fixed-'+dim]266 self.pd_pars = info['partype']['pd-'+dim]265 self.fixed_pars = model_info['partype']['fixed-' + dim] 266 self.pd_pars = model_info['partype']['pd-' + dim] 267 267 268 268 # In dll kernel, but not in opencl kernel
Note: See TracChangeset
for help on using the changeset viewer.