Changeset 56b2687 in sasmodels for sasmodels/kernelcl.py
- Timestamp:
- Jul 14, 2016 1:35:58 PM (8 years ago)
- 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:
- 98ba1fc
- Parents:
- 61f8638 (diff), fa800e72 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernelcl.py
rae2b6b5 r56b2687 52 52 import os 53 53 import warnings 54 import logging 54 55 55 56 import numpy as np # type: ignore … … 60 61 # Ask OpenCL for the default context so that we know that one exists 61 62 cl.create_some_context(interactive=False) 62 except Exception as ocl_exc: 63 warnings.warn(str(ocl_exc)) 64 del ocl_exc 63 except Exception as exc: 64 warnings.warn("OpenCL startup failed with ***"+str(exc)+"***; using C compiler instead") 65 65 raise RuntimeError("OpenCL not available") 66 66 67 67 from pyopencl import mem_flags as mf # type: ignore 68 68 from pyopencl.characterize import get_fast_inaccurate_build_options # type: ignore 69 # CRUFT: pyopencl < 2017.1 (as of June 2016 needs quotes around include path) 70 def _quote_path(v): 71 """ 72 Quote the path if it is not already quoted. 73 74 If v starts with '-', then assume that it is a -I option or similar 75 and do not quote it. This is fragile: -Ipath with space needs to 76 be quoted. 77 """ 78 return '"'+v+'"' if v and ' ' in v and not v[0] in "\"'-" else v 79 80 if hasattr(cl, '_DEFAULT_INCLUDE_OPTIONS'): 81 cl._DEFAULT_INCLUDE_OPTIONS = [_quote_path(v) for v in cl._DEFAULT_INCLUDE_OPTIONS] 82 83 from pyopencl import mem_flags as mf 84 from pyopencl.characterize import get_fast_inaccurate_build_options 69 85 70 86 from . import generate … … 188 204 source = "\n".join(source_list) 189 205 program = cl.Program(context, source).build(options=options) 206 #print("done with "+program) 190 207 return program 191 208 … … 262 279 Compile the program for the device in the given context. 263 280 """ 264 key = "%s-%s -%s"%(name, dtype, fast)281 key = "%s-%s%s"%(name, dtype, ("-fast" if fast else "")) 265 282 if key not in self.compiled: 283 context = self.get_context(dtype) 284 logging.info("building %s for OpenCL %s" 285 % (key, context.devices[0].name.strip())) 286 program = compile_model(context, source, np.dtype(dtype), fast) 266 287 #print("OpenCL compile",name) 267 288 dtype = np.dtype(dtype)
Note: See TracChangeset
for help on using the changeset viewer.