Changeset a503bfd in sasmodels for compare.py
- Timestamp:
- Feb 16, 2015 7:41:55 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:
- a1542aae, 373d1b6
- Parents:
- d547f16
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
compare.py
rd547f16 ra503bfd 156 156 return data, index 157 157 158 def compare(name, pars, Ncpu, N gpu, opts, set_pars):158 def compare(name, pars, Ncpu, Nocl, opts, set_pars): 159 159 opt_values = dict(split 160 160 for s in opts for split in ((s.split('='),)) … … 185 185 186 186 # OpenCl calculation 187 if N gpu> 0:188 gpu, gpu_time = eval_opencl(name, pars, data, dtype, Ngpu)189 print "opencl t=%.1f ms, intensity=%.0f"%( gpu_time, sum(gpu[index]))190 #print max( gpu), min(gpu)187 if Nocl > 0: 188 ocl, ocl_time = eval_opencl(name, pars, data, dtype, Nocl) 189 print "opencl t=%.1f ms, intensity=%.0f"%(ocl_time, sum(ocl[index])) 190 #print max(ocl), min(ocl) 191 191 192 192 # ctypes/sasview calculation … … 201 201 202 202 # Compare, but only if computing both forms 203 if N gpu> 0 and Ncpu > 0:204 #print "speedup %.2g"%(cpu_time/ gpu_time)205 #print "max | gpu/cpu|", max(abs(gpu/cpu)), "%.15g"%max(abs(gpu)), "%.15g"%max(abs(cpu))206 #cpu *= max( gpu/cpu)207 resid, relerr = np.zeros_like( gpu), np.zeros_like(gpu)208 resid[index] = ( gpu- cpu)[index]203 if Nocl > 0 and Ncpu > 0: 204 #print "speedup %.2g"%(cpu_time/ocl_time) 205 #print "max |ocl/cpu|", max(abs(ocl/cpu)), "%.15g"%max(abs(ocl)), "%.15g"%max(abs(cpu)) 206 #cpu *= max(ocl/cpu) 207 resid, relerr = np.zeros_like(ocl), np.zeros_like(ocl) 208 resid[index] = (ocl - cpu)[index] 209 209 relerr[index] = resid[index]/cpu[index] 210 210 #bad = (relerr>1e-4) 211 #print relerr[bad],cpu[bad], gpu[bad],data.qx_data[bad],data.qy_data[bad]211 #print relerr[bad],cpu[bad],ocl[bad],data.qx_data[bad],data.qy_data[bad] 212 212 print "max(|ocl-%s|)"%comp, max(abs(resid[index])) 213 213 print "max(|(ocl-%s)/%s|)"%(comp,comp), max(abs(relerr[index])) … … 220 220 import matplotlib.pyplot as plt 221 221 if Ncpu > 0: 222 if N gpu> 0: plt.subplot(131)222 if Nocl > 0: plt.subplot(131) 223 223 plot_data(data, cpu, scale='log') 224 224 plt.title("%s t=%.1f ms"%(comp,cpu_time)) 225 if N gpu> 0:225 if Nocl > 0: 226 226 if Ncpu > 0: plt.subplot(132) 227 plot_data(data, gpu, scale='log')228 plt.title("opencl t=%.1f ms"% gpu_time)229 if Ncpu > 0 and N gpu> 0:227 plot_data(data, ocl, scale='log') 228 plt.title("opencl t=%.1f ms"%ocl_time) 229 if Ncpu > 0 and Nocl > 0: 230 230 plt.subplot(133) 231 231 err = resid if '-abs' in opts else relerr 232 232 errstr = "abs err" if '-abs' in opts else "rel err" 233 #err,errstr = gpu/cpu,"ratio"233 #err,errstr = ocl/cpu,"ratio" 234 234 plot_data(data, err, scale='linear') 235 235 plt.title("max %s = %.3g"%(errstr, max(abs(err[index])))) 236 236 if is2D: plt.colorbar() 237 237 238 if Ncpu > 0 and N gpu> 0 and '-hist' in opts:238 if Ncpu > 0 and Nocl > 0 and '-hist' in opts: 239 239 plt.figure() 240 240 v = relerr[index]
Note: See TracChangeset
for help on using the changeset viewer.