Changeset b297ba9 in sasmodels for sasmodels/kernelcl.py


Ignore:
Timestamp:
Mar 20, 2019 5:03:50 PM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
4e28511
Parents:
0d362b7
Message:

lint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernelcl.py

    r0d26e91 rb297ba9  
    5353from __future__ import print_function 
    5454 
     55import sys 
    5556import os 
    5657import warnings 
     
    6162    from time import perf_counter as clock 
    6263except ImportError: # CRUFT: python < 3.3 
    63     import sys 
    6464    if sys.platform.count("darwin") > 0: 
    6565        from time import time as clock 
     
    9999# CRUFT: pyopencl < 2017.1 (as of June 2016 needs quotes around include path). 
    100100def quote_path(v): 
     101    # type: (str) -> str 
    101102    """ 
    102103    Quote the path if it is not already quoted. 
     
    110111 
    111112def fix_pyopencl_include(): 
     113    # type: (None) -> None 
    112114    """ 
    113115    Monkey patch pyopencl to allow spaces in include file path. 
    114116    """ 
    115     import pyopencl as cl 
    116     if hasattr(cl, '_DEFAULT_INCLUDE_OPTIONS'): 
    117         cl._DEFAULT_INCLUDE_OPTIONS = [ 
    118             quote_path(v) for v in cl._DEFAULT_INCLUDE_OPTIONS 
     117    import pyopencl 
     118    if hasattr(pyopencl, '_DEFAULT_INCLUDE_OPTIONS'): 
     119        pyopencl._DEFAULT_INCLUDE_OPTIONS = [ 
     120            quote_path(v) for v in pyopencl._DEFAULT_INCLUDE_OPTIONS 
    119121            ] 
    120122 
     
    147149 
    148150def use_opencl(): 
     151    # type: () -> bool 
     152    """Return True if OpenCL is the default computational engine""" 
    149153    sas_opencl = os.environ.get("SAS_OPENCL", "OpenCL").lower() 
    150154    return HAVE_OPENCL and sas_opencl != "none" and not sas_opencl.startswith("cuda") 
     
    153157ENV = None 
    154158def reset_environment(): 
     159    # type: () -> None 
    155160    """ 
    156161    Call to create a new OpenCL context, such as after a change to SAS_OPENCL. 
     
    323328            return [cl.create_some_context(interactive=False)] 
    324329        except Exception as exc: 
     330            # TODO: Should warnings instead by put into logging.warn? 
    325331            warnings.warn(str(exc)) 
    326             warnings.warn("pyopencl.create_some_context() failed.  The " 
    327                 "environment variable 'SAS_OPENCL' or 'PYOPENCL_CTX' might " 
    328                 "not be set correctly") 
     332            warnings.warn( 
     333                "pyopencl.create_some_context() failed.  The environment " 
     334                "variable 'SAS_OPENCL' or 'PYOPENCL_CTX' might not be set " 
     335                "correctly") 
    329336 
    330337    return _get_default_context() 
Note: See TracChangeset for help on using the changeset viewer.