Changes in / [45330ed:4416868] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kerneldll.py
r17bbadd r6ad0e87 51 51 import ctypes as ct 52 52 from ctypes import c_void_p, c_int, c_longdouble, c_double, c_float 53 import _ctypes 53 54 54 55 import numpy as np … … 125 126 if callable(model_info.get('Iq', None)): 126 127 return PyModel(model_info) 127 128 128 129 dtype = np.dtype(dtype) 129 130 if dtype == generate.F16: … … 138 139 else: 139 140 tempfile_prefix = 'sas_' + model_info['name'] + '128_' 140 141 141 142 source = generate.convert_type(source, dtype) 142 143 source_files = generate.model_sources(model_info) + [model_info['filename']] … … 188 189 Call :meth:`release` when done with the kernel. 189 190 """ 191 190 192 def __init__(self, dllpath, model_info, dtype=generate.F32): 191 193 self.info = model_info … … 217 219 self.Iqxy = self.dll[generate.kernel_name(self.info, True)] 218 220 self.Iqxy.argtypes = IQXY_ARGS + pd_args_2d + [fp]*Nfixed2d 221 222 self.release() 219 223 220 224 def __getstate__(self): … … 230 234 kernel = self.Iqxy if q_input.is_2d else self.Iq 231 235 return DllKernel(kernel, self.info, q_input) 232 236 233 237 def release(self): 234 238 """ 235 239 Release any resources associated with the model. 236 240 """ 237 pass # TODO: should release the dll 241 if os.name == 'nt': 242 #dll = ct.cdll.LoadLibrary(self.dllpath) 243 dll = ct.CDLL(self.dllpath) 244 libHandle = dll._handle 245 #libHandle = ct.c_void_p(dll._handle) 246 del dll, self.dll 247 self.dll = None 248 #_ctypes.FreeLibrary(libHandle) 249 ct.windll.kernel32.FreeLibrary(libHandle) 250 else: 251 pass 238 252 239 253
Note: See TracChangeset
for help on using the changeset viewer.