Changeset 09e15be in sasmodels for compare.py
- Timestamp:
- Jul 18, 2014 2:25:00 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:
- 79fcc40
- Parents:
- 8a21ba3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
compare.py
r8a21ba3 r09e15be 77 77 plt.show() 78 78 79 def ellipse(N= 1):79 def ellipse(N=4): 80 80 import sys 81 81 import matplotlib.pyplot as plt … … 83 83 if len(sys.argv) > 1: 84 84 N = int(sys.argv[1]) 85 data = load_data(' JUN03289.DAT')85 data = load_data('DEC07133.DAT') 86 86 set_beam_stop(data, 0.004) 87 87 … … 114 114 plt.show() 115 115 116 def coreshell(N=4): 117 import sys 118 import matplotlib.pyplot as plt 119 120 if len(sys.argv) > 1: 121 N = int(sys.argv[1]) 122 data = load_data('DEC07133.DAT') 123 set_beam_stop(data, 0.004) 124 125 pars = dict(scale= 1.77881e-06, radius=325, thickness=25, length=34.2709, 126 core_sld=1e-6, shell_sld=.291e-6, solvent_sld=7.105e-6, 127 background=223.827, axis_theta=90, axis_phi=0, 128 axis_theta_pd=15.8, 129 radius_pd=0.1, radius_pd_n=1, radius_pd_nsigma=0, 130 length_pd=0.1, length_pd_n=1, length_pd_nsigma=0, 131 thickness_pd=0.1, thickness_pd_n=1, thickness_pd_nsigma=0, 132 axis_theta_pd_n=10, axis_theta_pd_nsigma=3, 133 axis_phi_pd=0.0008748, axis_phi_pd_n=10, axis_phi_pd_nsigma=3,) 134 135 model = sasview_model('CoreShellCylinder', **pars) 136 tic() 137 for i in range(N): 138 cpu = sasview_eval(model, data) 139 cpu_time = toc()*1000./N 140 141 from code_coreshellcyl import GpuCoreShellCylinder 142 model = SasModel(data, GpuCoreShellCylinder, dtype='f', **pars) 143 tic() 144 for i in range(N): 145 gpu = model.theory() 146 gpu_time = toc()*1000./N 147 148 relerr = (gpu - cpu)/cpu 149 print "max(|(ocl-omp)/ocl|)", max(abs(relerr)) 150 print "omp t=%.1f ms"%cpu_time 151 print "ocl t=%.1f ms"%gpu_time 152 153 plt.subplot(131); plot_data(data, cpu); plt.title("omp t=%.1f ms"%cpu_time) 154 plt.subplot(132); plot_data(data, gpu); plt.title("ocl t=%.1f ms"%gpu_time) 155 plt.subplot(133); plot_data(data, 1e8*relerr); plt.title("relerr x 10^8"); plt.colorbar() 156 plt.show() 116 157 117 158 if __name__ == "__main__": 118 ellipse()159 coreshell() 119 160 120 161
Note: See TracChangeset
for help on using the changeset viewer.