Changeset 151f3bc in sasmodels
- Timestamp:
- Mar 24, 2016 6:03:32 PM (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:
- ba32cdd
- Parents:
- 380e8c9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kerneldll.py
r380e8c9 r151f3bc 89 89 90 90 91 def dll_path(model_info, dtype="double"): 92 """ 93 Path to the compiled model defined by *model_info*. 94 """ 95 from os.path import join as joinpath, split as splitpath, splitext 96 basename = splitext(splitpath(model_info['filename'])[1])[0] 97 bits = 8*np.dtype(dtype).itemsize 98 return joinpath(DLL_PATH, "sas_%s%d.so"%(basename, bits)) 99 91 def dll_name(model_info, dtype): 92 """ 93 Name of the dll containing the model. This is the base file name without 94 any path or extension, with a form such as 'sas_sphere32'. 95 """ 96 bits = 8*dtype.itemsize 97 return "sas_%s%d"%(model_info['id'], bits) 98 99 def dll_path(model_info, dtype): 100 """ 101 Complete path to the dll for the model. Note that the dll may not 102 exist yet if it hasn't been compiled. 103 """ 104 return os.path.join(DLL_PATH, dll_name(model_info, dtype)+".so") 100 105 101 106 def make_dll(source, model_info, dtype="double"): … … 127 132 dtype = generate.F64 # Force 64-bit dll 128 133 129 if dtype == generate.F32: # 32-bit dll130 tempfile_prefix = 'sas_' + model_info['name'] + '32_'131 elif dtype == generate.F64:132 tempfile_prefix = 'sas_' + model_info['name'] + '64_'133 else:134 tempfile_prefix = 'sas_' + model_info['name'] + '128_'135 136 134 source = generate.convert_type(source, dtype) 137 135 newest = generate.timestamp(model_info) 138 136 dll = dll_path(model_info, dtype) 139 137 if not os.path.exists(dll) or os.path.getmtime(dll) < newest: 140 # Replace with a proper temp file141 fid, filename = tempfile.mkstemp(suffix=".c", prefix= tempfile_prefix)138 basename = dll_name(model_info, dtype) + "_" 139 fid, filename = tempfile.mkstemp(suffix=".c", prefix=basename) 142 140 os.fdopen(fid, "w").write(source) 143 141 command = COMPILE%{"source":filename, "output":dll}
Note: See TracChangeset
for help on using the changeset viewer.