Changeset b297ba9 in sasmodels for sasmodels/kernelcl.py
- Timestamp:
- Mar 20, 2019 5:03:50 PM (5 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernelcl.py
r0d26e91 rb297ba9 53 53 from __future__ import print_function 54 54 55 import sys 55 56 import os 56 57 import warnings … … 61 62 from time import perf_counter as clock 62 63 except ImportError: # CRUFT: python < 3.3 63 import sys64 64 if sys.platform.count("darwin") > 0: 65 65 from time import time as clock … … 99 99 # CRUFT: pyopencl < 2017.1 (as of June 2016 needs quotes around include path). 100 100 def quote_path(v): 101 # type: (str) -> str 101 102 """ 102 103 Quote the path if it is not already quoted. … … 110 111 111 112 def fix_pyopencl_include(): 113 # type: (None) -> None 112 114 """ 113 115 Monkey patch pyopencl to allow spaces in include file path. 114 116 """ 115 import pyopencl as cl116 if hasattr( cl, '_DEFAULT_INCLUDE_OPTIONS'):117 cl._DEFAULT_INCLUDE_OPTIONS = [118 quote_path(v) for v in cl._DEFAULT_INCLUDE_OPTIONS117 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 119 121 ] 120 122 … … 147 149 148 150 def use_opencl(): 151 # type: () -> bool 152 """Return True if OpenCL is the default computational engine""" 149 153 sas_opencl = os.environ.get("SAS_OPENCL", "OpenCL").lower() 150 154 return HAVE_OPENCL and sas_opencl != "none" and not sas_opencl.startswith("cuda") … … 153 157 ENV = None 154 158 def reset_environment(): 159 # type: () -> None 155 160 """ 156 161 Call to create a new OpenCL context, such as after a change to SAS_OPENCL. … … 323 328 return [cl.create_some_context(interactive=False)] 324 329 except Exception as exc: 330 # TODO: Should warnings instead by put into logging.warn? 325 331 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") 329 336 330 337 return _get_default_context()
Note: See TracChangeset
for help on using the changeset viewer.