Changeset 32c160a in sasmodels for sasmodels/core.py
- Timestamp:
- Aug 25, 2014 12:55:08 AM (10 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:
- 13d86bc
- Parents:
- 1f21edf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
rce27e21 r32c160a 8 8 import numpy as np 9 9 10 def load_model(modelname): 11 from os.path import abspath, join as joinpath, dirname 12 from sasmodels import gen 13 modelpath = abspath(joinpath(dirname(gen.__file__), 'models', 14 modelname+'.c')) 15 return gen.make(modelpath) 16 17 18 19 def opencl_model(modelname, dtype="single"): 20 from sasmodels import gpu 21 22 source, info, _ = load_model(modelname) 23 # for debugging, save source to a .cl file, edit it, and reload as model 10 11 def opencl_model(kernel_module, dtype="single"): 12 from sasmodels import gen, gpu 13 14 source, info = gen.make(kernel_module) 15 ## for debugging, save source to a .cl file, edit it, and reload as model 24 16 #open(modelname+'.cl','w').write(source) 25 17 #source = open(modelname+'.cl','r').read() … … 42 34 43 35 44 def dll_model( modelname):36 def dll_model(kernel_module): 45 37 import os 46 from sasmodels import dll 47 48 source, info, _ = load_model(modelname) 38 import tempfile 39 from sasmodels import gen, dll 40 41 source, info = gen.make(kernel_module) 49 42 dllpath = dll_path(info) 50 43 if not os.path.exists(dllpath) \ 51 44 or (os.path.getmtime(dllpath) < os.path.getmtime(info['filename'])): 52 45 # Replace with a proper temp file 53 srcfile = '/tmp/%s.c'%modelname46 srcfile = tempfile.mkstemp(suffix=".c",prefix="sas_"+info['name']) 54 47 open(srcfile, 'w').write(source) 55 48 os.system(COMPILE%(srcfile, dllpath)) 49 ## comment the following to keep the generated c file 50 #os.unlink(srcfile) 56 51 return dll.DllModel(dllpath, info) 57 52
Note: See TracChangeset
for help on using the changeset viewer.