Changeset 5d316e9 in sasmodels for sasmodels/compare.py


Ignore:
Timestamp:
Dec 8, 2015 8:08:51 AM (8 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:
cf404cb
Parents:
eaca9eb
Message:

support fast and loose single precision and half precision

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    r9404dd3 r5d316e9  
    190190    return value, average_time 
    191191 
    192 def eval_opencl(model_definition, pars, data, dtype='single', Nevals=1, cutoff=0.): 
     192def eval_opencl(model_definition, pars, data, dtype='single', Nevals=1, 
     193                cutoff=0., fast=False): 
    193194    try: 
    194         model = core.load_model(model_definition, dtype=dtype, platform="ocl") 
     195        model = core.load_model(model_definition, dtype=dtype, 
     196                                platform="ocl", fast=fast) 
    195197    except Exception as exc: 
    196198        print(exc) 
    197199        print("... trying again with single precision") 
    198         model = core.load_model(model_definition, dtype='single', platform="ocl") 
     200        model = core.load_model(model_definition, dtype='single', 
     201                                platform="ocl", fast=fast) 
    199202    calculator = DirectModel(data, model, cutoff=cutoff) 
    200203    value = None  # silence the linter 
     
    259262    dtype = ('longdouble' if '-quad' in opts 
    260263             else 'double' if '-double' in opts 
     264             else 'half' if '-half' in opts 
    261265             else 'single') 
    262266    cutoff = float(opt_values.get('-cutoff','1e-5')) 
     267    fast = "-fast" in opts and dtype is 'single' 
    263268 
    264269    # randomize parameters 
     
    282287        base_name = target.name 
    283288        base, base_time = eval_ctypes(target, pars, data, 
    284                          dtype='longdouble', cutoff=0., Nevals=Ncomp) 
     289                dtype='longdouble', cutoff=0., Nevals=Ncomp) 
    285290    elif Nbase > 0 and "-ctypes" in opts and "-sasview" in opts: 
    286291        try: 
     
    295300    elif Nbase > 0: 
    296301        base, base_time = eval_opencl(model_definition, pars, data, 
    297                                     dtype=dtype, cutoff=cutoff, Nevals=Nbase) 
     302                dtype=dtype, cutoff=cutoff, Nevals=Nbase, fast=fast) 
    298303        base_name = "ocl" 
    299304        print("opencl t=%.1f ms, intensity=%.0f"%(base_time, sum(base))) 
     
    304309    if Ncomp > 0 and "-ctypes" in opts: 
    305310        comp, comp_time = eval_ctypes(model_definition, pars, data, 
    306                                     dtype=dtype, cutoff=cutoff, Nevals=Ncomp) 
     311                dtype=dtype, cutoff=cutoff, Nevals=Ncomp) 
    307312        comp_name = "ctypes" 
    308313        print("ctypes t=%.1f ms, intensity=%.0f"%(comp_time, sum(comp))) 
     
    398403 
    399404    -plot*/-noplot plots or suppress the plot of the model 
    400     -single*/-double/-quad use single/double/quad precision for comparison 
     405    -half/-single*/-double/-quad/-fast sets the calculation precision 
    401406    -lowq*/-midq/-highq/-exq use q values up to 0.05, 0.2, 1.0, 10.0 
    402407    -Nq=128 sets the number of Q points in the data set 
     
    411416    -hist/-nohist* plot histogram of relative error 
    412417    -res=0 sets the resolution width dQ/Q if calculating with resolution 
    413     -accuracy=Low resolution accuracy Low, Mid, High, Xhigh 
     418    -accuracy=Low accuracy of the resolution calculation Low, Mid, High, Xhigh 
    414419 
    415420Key=value pairs allow you to set specific values to any of the model 
     
    421426 
    422427NAME_OPTIONS = set([ 
    423     'plot','noplot', 
    424     'single','double','quad', 
    425     'lowq','midq','highq','exq', 
    426     '2d','1d', 
    427     'preset','random', 
    428     'poly','mono', 
    429     'sasview','ctypes', 
    430     'nopars','pars', 
    431     'rel','abs', 
     428    'plot', 'noplot', 
     429    'half', 'single', 'double', 'quad', 'fast', 
     430    'lowq', 'midq', 'highq', 'exq', 
     431    '2d', '1d', 
     432    'preset', 'random', 
     433    'poly', 'mono', 
     434    'sasview', 'ctypes', 
     435    'nopars', 'pars', 
     436    'rel', 'abs', 
    432437    'linear', 'log', 'q4', 
    433     'hist','nohist', 
     438    'hist', 'nohist', 
    434439    ]) 
    435440VALUE_OPTIONS = [ 
Note: See TracChangeset for help on using the changeset viewer.