Changeset 5464d68 in sasmodels


Ignore:
Timestamp:
Mar 20, 2016 4:55:33 PM (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:
4f9d3fd
Parents:
cf52f9c
Message:

move opencl pragmas into kernelcl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernelcl.py

    rc094758 r5464d68  
    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 
     166 
    145167    # Note: USE_SINCOS makes the intel cpu slower under opencl 
    146168    if context.devices[0].type == cl.device_type.GPU: 
    147         source = "#define USE_SINCOS\n" + source 
     169        source_list.insert(0, "#define USE_SINCOS\n") 
    148170    options = (get_fast_inaccurate_build_options(context.devices[0]) 
    149171               if fast else []) 
     172    source = "\n".join(source) 
    150173    program = cl.Program(context, source).build(options=options) 
    151174    return program 
Note: See TracChangeset for help on using the changeset viewer.