diff --git a/doc/source/runtime.rst b/doc/source/runtime.rst index c6738e53403d3a6f8328fb354feedca28fa98294..4e30345636a385de23f01b3461b164e220160759 100644 --- a/doc/source/runtime.rst +++ b/doc/source/runtime.rst @@ -621,17 +621,19 @@ Programs and Kernels *options* is a string of compiler flags. Returns *self*. - By default, built binaries are cached in an on-disk cache - called :file:`pyopencl-compiler-cache-vN-uidNAME-pyVERSION` - in the directory returned by :func:`tempfile.gettempdir`. - By setting the environment variable :envvar:`PYOPENCL_NO_CACHE` - to any non-empty value, this caching is suppressed. + By default, built binaries are cached in an on-disk cache called + :file:`pyopencl-compiler-cache-vN-uidNAME-pyVERSION` in the directory + returned by :func:`tempfile.gettempdir`. By setting the environment + variable :envvar:`PYOPENCL_NO_CACHE` to any non-empty value, this + caching is suppressed. Any options found in the environment variable + :envvar:`PYOPENCL_BUILD_OPTIONS` will be appened to *options*. .. versionchanged:: 2011.1 *options* may now also be a :class:`list` of :class:`str`. .. versionchanged:: 2013.1 Added :envvar:`PYOPENCL_NO_CACHE`. + Added :envvar:`PYOPENCL_BUILD_OPTIONS`. .. method:: compile(self, options=[], devices=None, headers=[]) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 1f4b4984897ae5c61e07d168ecb9e661705a5817..60de5a1ad561464f9ee20c9ca562698369d7c5cf 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -138,14 +138,15 @@ class Program(object): options = options + ["-I", _find_pyopencl_include_path()] import os + forced_options = os.environ.get("PYOPENCL_BUILD_OPTIONS") + if forced_options: + options = options + forced_options.split() + if os.environ.get("PYOPENCL_NO_CACHE") and self._prg is None: self._prg = _cl._Program(self._context, self._source) if self._prg is not None: - if isinstance(options, list): - options = " ".join(options) - - self._prg._build(options, devices) + self._prg._build(" ".join(options), devices) else: from pyopencl.cache import create_built_program_from_source_cached