Changeset 319ab14 in sasmodels for sasmodels/compare.py


Ignore:
Timestamp:
Nov 25, 2015 11:12:06 AM (9 years ago)
Author:
Paul Kienzle <pkienzle@…>
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:
0fa687d
Parents:
38d8774
Message:

allow comparison between double/quad precision and sasview

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    rdc056b9 r319ab14  
    278278 
    279279    # OpenCl calculation 
    280     if Nocl > 0: 
     280    if Nocl > 0 and "-ctypes" in opts and "-sasview" in opts: 
     281        try: 
     282            ocl, ocl_time = eval_sasview(model_definition, pars, data, Ncpu) 
     283            base = "sasview" 
     284            #print "ocl/sasview", (ocl-pars['background'])/(cpu-pars['background']) 
     285            print "sasview t=%.1f ms, intensity=%.0f"%(ocl_time, sum(ocl)) 
     286            #print "sasview",cpu 
     287        except ImportError: 
     288            traceback.print_exc() 
     289            Ncpu = 0 
     290    elif Nocl > 0: 
    281291        ocl, ocl_time = eval_opencl(model_definition, pars, data, 
    282292                                    dtype=dtype, cutoff=cutoff, Nevals=Nocl) 
     293        base = "ocl" 
    283294        print "opencl t=%.1f ms, intensity=%.0f"%(ocl_time, sum(ocl)) 
    284295        #print "ocl", ocl 
     
    311322        #bad = (relerr>1e-4) 
    312323        #print relerr[bad],cpu[bad],ocl[bad],data.qx_data[bad],data.qy_data[bad] 
    313         _print_stats("|ocl-%s|"%comp+(" "*(3+len(comp))), resid) 
    314         _print_stats("|(ocl-%s)/%s|"%(comp,comp), relerr) 
     324        _print_stats("|%s-%s|"%(base,comp)+(" "*(3+len(comp))), resid) 
     325        _print_stats("|(%s-%s)/%s|"%(base,comp,comp), relerr) 
    315326 
    316327    # Plot if requested 
     
    325336        if Ncpu > 0: plt.subplot(132) 
    326337        plot_theory(data, ocl, view=view, plot_data=False) 
    327         plt.title("opencl t=%.1f ms"%ocl_time) 
     338        plt.title("%s t=%.1f ms"%(base,ocl_time)) 
    328339        #cbar_title = "log I" 
    329340    if Ncpu > 0 and Nocl > 0: 
     
    388399    -preset*/-random[=seed] preset or random parameters 
    389400    -mono/-poly* force monodisperse/polydisperse 
    390     -ctypes/-sasview* whether cpu is tested using sasview or ctypes 
     401    -ctypes/-sasview* selects gpu:cpu, gpu:sasview, or sasview:cpu if both 
    391402    -cutoff=1e-5* cutoff value for including a point in polydispersity 
    392403    -pars/-nopars* prints the parameter set or not 
     
    406417NAME_OPTIONS = set([ 
    407418    'plot','noplot', 
    408     'single','double','longdouble', 
     419    'single','double','quad', 
    409420    'lowq','midq','highq','exq', 
    410421    '2d','1d', 
     
    442453def main(): 
    443454    opts = [arg for arg in sys.argv[1:] if arg.startswith('-')] 
    444     args = [arg for arg in sys.argv[1:] if not arg.startswith('-')] 
     455    popts = [arg for arg in sys.argv[1:] if not arg.startswith('-') and '=' in arg] 
     456    args = [arg for arg in sys.argv[1:] if not arg.startswith('-') and '=' not in arg] 
    445457    models = "\n    ".join("%-15s"%v for v in MODELS) 
    446458    if len(args) == 0: 
     
    451463        print "Model %r not available. Use one of:\n    %s"%(args[0],models) 
    452464        sys.exit(1) 
     465    if len(args) > 3: 
     466        print("expected parameters: model Nopencl Nsasview") 
    453467 
    454468    invalid = [o[1:] for o in opts 
     
    476490    # Fill in parameters given on the command line 
    477491    set_pars = {} 
    478     for arg in args[3:]: 
    479         k,v = arg.split('=') 
     492    for arg in popts: 
     493        k,v = arg.split('=',1) 
    480494        if k not in pars: 
    481495            # extract base name without distribution 
Note: See TracChangeset for help on using the changeset viewer.