Skip to content

Commit

Permalink
add characterize function for ICD source build caching
Browse files Browse the repository at this point in the history
  • Loading branch information
majosm committed Apr 24, 2024
1 parent 4c5805c commit a72c2b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pyopencl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,16 +508,14 @@ def build(self, options=None, devices=None, cache_dir=None):
cache_dir = getattr(self._context, "cache_dir", None)

build_descr = None
no_cache = _PYOPENCL_NO_CACHE
# Turn off caching when using pocl to avoid extra compile from
# get_info(BINARIES). See https://github.com/inducer/pyopencl/issues/731.
from pyopencl.characterize import get_pocl_version
no_cache |= get_pocl_version(self._context.devices[0].platform) is not None
if no_cache and self._prg is None:
from pyopencl.characterize import has_src_build_cache
if (
(_PYOPENCL_NO_CACHE or has_src_build_cache(self._context.devices[0]))
and self._prg is None):
if _PYOPENCL_NO_CACHE:
build_descr = "uncached source build (cache disabled by user)"
else:
build_descr = "uncached source build (cache disabled for pocl)"
build_descr = "source build via ICD cache"
self._prg = _cl._Program(self._context, self._source)

from time import time
Expand Down
10 changes: 10 additions & 0 deletions pyopencl/characterize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,13 @@ def has_fine_grain_buffer_svm_atomics(dev):
def has_fine_grain_system_svm_atomics(dev):
return has_fine_grain_system_svm(dev) and bool(dev.svm_capabilities
& cl.device_svm_capabilities.ATOMICS)


def has_src_build_cache(dev):
"""
Return *True* if *dev* has internal support for caching builds from source,
*False* if it doesn't, and *None* if unknown.
"""
if get_pocl_version(dev.platform) is not None:
return True
return None

0 comments on commit a72c2b9

Please sign in to comment.