3.8. Ctypes model evaluator¶
3.8.1. sasmodels.kerneldll¶
C types wrapper for sasview models.
The global attribute ALLOW_SINGLE_PRECISION_DLLS should be set to True if you wish to allow single precision floating point evaluation for the compiled models, otherwise it defaults to False.
- class sasmodels.kerneldll.DllKernel(kernel, info, q_input)¶
Bases: object
Callable SAS kernel.
kernel is the c function to call.
info is the module information
q_input is the DllInput q vectors at which the kernel should be evaluated.
The resulting call method takes the pars, a list of values for the fixed parameters to the kernel, and pd_pars, a list of (value,weight) vectors for the polydisperse parameters. cutoff determines the integration limits: any points with combined weight less than cutoff will not be calculated.
Call release() when done with the kernel instance.
- release()¶
- class sasmodels.kerneldll.DllModel(dllpath, info, dtype=dtype('float32'))¶
Bases: object
ctypes wrapper for a single model.
source and info are the model source and interface as returned from gen.make().
dtype is the desired model precision. Any numpy dtype for single or double precision floats will do, such as ‘f’, ‘float32’ or ‘single’ for single and ‘d’, ‘float64’ or ‘double’ for double. Double precision is an optional extension which may not be available on all devices.
Call release() when done with the kernel.
- make_input(q_vectors)¶
Make q input vectors available to the model.
Note that each model needs its own q vector even if the case of mixture models because some models may be OpenCL, some may be ctypes and some may be pure python.
- release()¶
- sasmodels.kerneldll.dll_path(info, dtype='double')¶
Path to the compiled model defined by info.
- sasmodels.kerneldll.load_dll(source, info, dtype='double')¶
Create and load a dll corresponding to the source,info pair returned from sasmodels.generate.make() compiled for the target precision.
See make_dll() for details on controlling the dll path and the allowed floating point precision.
- sasmodels.kerneldll.make_dll(source, info, dtype='double')¶
Load the compiled model defined by kernel_module.
Recompile if any files are newer than the model file.
dtype is a numpy floating point precision specifier indicating whether the model should be single or double precision. The default is double precision.
The DLL is not loaded until the kernel is called so models can be defined without using too many resources.
Set sasmodels.kerneldll.DLL_PATH to the compiled dll output path. The default is the system temporary directory.
Set sasmodels.ALLOW_SINGLE_PRECISION_DLLS to True if single precision models are allowed as DLLs.