Changes in / [b26d4c8:025c82d] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernelcl.py

    rc094758 r4f9d3fd  
    7575 
    7676 
     77# Pragmas for enable OpenCL features.  Be sure to protect them so that they 
     78# still compile even if OpenCL is not present. 
     79_F16_PRAGMA = """\ 
     80#if defined(__OPENCL_VERSION__) // && !defined(cl_khr_fp16) 
     81#  pragma OPENCL EXTENSION cl_khr_fp16: enable 
     82#endif 
     83""" 
     84 
     85_F64_PRAGMA = """\ 
     86#if defined(__OPENCL_VERSION__) // && !defined(cl_khr_fp64) 
     87#  pragma OPENCL EXTENSION cl_khr_fp64: enable 
     88#endif 
     89""" 
     90 
     91 
    7792ENV = None 
    7893def environment(): 
     
    142157        raise RuntimeError("%s not supported for devices"%dtype) 
    143158 
    144     source = generate.convert_type(source, dtype) 
     159    source_list = [generate.convert_type(source, dtype)] 
     160 
     161    if dtype == generate.F16: 
     162        source_list.insert(0, _F16_PRAGMA) 
     163    elif dtype == generate.F64: 
     164        source_list.insert(0, _F64_PRAGMA) 
     165 
    145166    # Note: USE_SINCOS makes the intel cpu slower under opencl 
    146167    if context.devices[0].type == cl.device_type.GPU: 
    147         source = "#define USE_SINCOS\n" + source 
     168        source_list.insert(0, "#define USE_SINCOS\n") 
    148169    options = (get_fast_inaccurate_build_options(context.devices[0]) 
    149170               if fast else []) 
     171    source = "\n".join(source) 
    150172    program = cl.Program(context, source).build(options=options) 
    151173    return program 
Note: See TracChangeset for help on using the changeset viewer.