Changeset 8a21ba3 in sasmodels for compare.py
- Timestamp:
- Jul 11, 2014 3:40:30 PM (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:
- 09e15be
- Parents:
- 496b252
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
compare.py
r8a20be5 r8a21ba3 38 38 return theory 39 39 40 def demo(N=1):40 def cyl(N=1): 41 41 import sys 42 42 import matplotlib.pyplot as plt 43 import numpy as np44 43 45 44 if len(sys.argv) > 1: … … 61 60 cpu_time = toc()*1000./N 62 61 63 from c ylcodeimport GpuCylinder62 from code_cylinder import GpuCylinder 64 63 model = SasModel(data, GpuCylinder, dtype='f', **pars) 64 tic() 65 for i in range(N): 66 gpu = model.theory() 67 gpu_time = toc()*1000./N 68 69 relerr = (gpu - cpu)/cpu 70 print "max(|(ocl-omp)/ocl|)", max(abs(relerr)) 71 print "omp t=%.1f ms"%cpu_time 72 print "ocl t=%.1f ms"%gpu_time 73 74 plt.subplot(131); plot_data(data, cpu); plt.title("omp t=%.1f ms"%cpu_time) 75 plt.subplot(132); plot_data(data, gpu); plt.title("ocl t=%.1f ms"%gpu_time) 76 plt.subplot(133); plot_data(data, 1e8*relerr); plt.title("relerr x 10^8"); plt.colorbar() 77 plt.show() 78 79 def ellipse(N=1): 80 import sys 81 import matplotlib.pyplot as plt 82 83 if len(sys.argv) > 1: 84 N = int(sys.argv[1]) 85 data = load_data('JUN03289.DAT') 86 set_beam_stop(data, 0.004) 87 88 pars = dict(scale=.027, radius_a=60, radius_b=180, sldEll=.297e-6, sldSolv=5.773e-6, background=4.9, 89 axis_theta=0, axis_phi=90, radius_a_pd=0.1, radius_a_pd_n=10, radius_a_pd_nsigma=3, radius_b_pd=0.1, radius_b_pd_n=10, 90 radius_b_pd_nsigma=3, axis_theta_pd=0.1, axis_theta_pd_n=6, axis_theta_pd_nsigma=3, axis_phi_pd=0.1, 91 axis_phi_pd_n=6, axis_phi_pd_nsigma=3,) 92 93 model = sasview_model('ellipsoid', **pars) 94 tic() 95 for i in range(N): 96 cpu = sasview_eval(model, data) 97 cpu_time = toc()*1000./N 98 99 from code_ellipse import GpuEllipse 100 model = SasModel(data, GpuEllipse, dtype='f', **pars) 65 101 tic() 66 102 for i in range(N): … … 80 116 81 117 if __name__ == "__main__": 82 demo()118 ellipse() 83 119 84 120
Note: See TracChangeset
for help on using the changeset viewer.