Changeset 7bf4757 in sasmodels
- Timestamp:
- May 6, 2016 3:08:14 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:
- 3a45c2c, e9d10a6
- Parents:
- 306e354
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
r4d76711 r7bf4757 7 7 ] 8 8 9 import os 9 10 from os.path import basename, dirname, join as joinpath, splitext 10 11 from glob import glob … … 139 140 # open(model_info['name']+'.c','w').write(source) 140 141 # source = open(model_info['name']+'.cl','r').read() 141 source = generate.make_source(model_info)142 if dtype is None:143 dtype = 'single' if model_info['single'] else 'double'144 142 if callable(model_info.get('Iq', None)): 145 143 return kernelpy.PyModel(model_info) 144 source = generate.make_source(model_info) 145 default_dtype = 'single' if model_info['single'] else 'double' 146 ocl_dtype = default_dtype if dtype is None else dtype 147 dll_dtype = 'double' if dtype is None else dtype 146 148 if (platform == "dll" 147 149 or not HAVE_OPENCL 148 or not kernelcl.environment().has_type( dtype)):149 return kerneldll.load_dll(source, model_info, d type)150 else: 151 return kernelcl.GpuModel(source, model_info, dtype)152 153 def precompile_dll (model_name, dtype="double"):154 """ 155 Precompile the dll for a model.156 157 Returns the path to the compiled model, or None if the model is a pure158 python model.150 or not kernelcl.environment().has_type(ocl_dtype)): 151 return kerneldll.load_dll(source, model_info, dll_dtype) 152 else: 153 return kernelcl.GpuModel(source, model_info, ocl_dtype) 154 155 def precompile_dlls(path, dtype="double"): 156 """ 157 Precompile the dlls for all builtin models, returning a list of dll paths. 158 159 *path* is the directory in which to save the dlls. It will be created if 160 it does not already exist. 159 161 160 162 This can be used when build the windows distribution of sasmodels 161 (which may be missing the OpenCL driver and the dll compiler), or 162 otherwise sharing models with windows users who do not have a compiler. 163 164 See :func:`sasmodels.kerneldll.make_dll` for details on controlling the 165 dll path and the allowed floating point precision. 166 """ 167 model_info = load_model_info(model_name) 168 source = generate.make_source(model_info) 169 return kerneldll.make_dll(source, model_info, dtype=dtype) if source else None 170 163 which may be missing the OpenCL driver and the dll compiler. 164 """ 165 if not os.path.exists(path): 166 os.makedirs(path) 167 compiled_dlls = [] 168 for model_name in list_models(): 169 model_info = load_model_info(model_name) 170 source = generate.make_source(model_info) 171 if source: 172 old_path = kerneldll.DLL_PATH 173 try: 174 kerneldll.DLL_PATH = path 175 dll = kerneldll.make_dll(source, model_info, dtype=dtype) 176 finally: 177 kerneldll.DLL_PATH = old_path 178 compiled_dlls.append(dll) 179 return compiled_dlls 171 180 172 181 def get_weights(model_info, pars, name):
Note: See TracChangeset
for help on using the changeset viewer.