From 56e872a73bdbc07f54dcf5265b7fa03da6e96190 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 9 Dec 2016 00:06:00 -0600 Subject: [PATCH] Add some amount of binary cache miss/hit logging --- pyopencl/cache.py | 13 +++++++++++++ pyopencl/cffi_cl.py | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/pyopencl/cache.py b/pyopencl/cache.py index 95aeb0eb..3d8f8fa9 100644 --- a/pyopencl/cache.py +++ b/pyopencl/cache.py @@ -32,6 +32,10 @@ import sys import os from pytools import Record +import logging +logger = logging.getLogger(__name__) + + try: import hashlib new_hash = hashlib.md5 @@ -352,10 +356,14 @@ def _create_built_program_from_source_cached(ctx, src, options_bytes, cache_result = retrieve_from_cache(cache_dir, cache_key) if cache_result is None: + logger.info("build program: binary cache miss (key: %s)" % cache_key) + to_be_built_indices.append(i) binaries.append(None) logs.append(None) else: + logger.debug("build program: binary cache hit (key: %s)" % cache_key) + binary, log = cache_result binaries.append(binary) logs.append(log) @@ -382,9 +390,14 @@ def _create_built_program_from_source_cached(ctx, src, options_bytes, src = src + "\n\n__constant int pyopencl_defeat_cache_%s = 0;" % ( uuid4().hex) + logger.info("build program: start building program from source on %s" + % ", ".join(str(devices[i]) for i in to_be_built_indices)) + prg = _cl._Program(ctx, src) prg.build(options_bytes, [devices[i] for i in to_be_built_indices]) + logger.info("build program: from-source build complete") + prg_devs = prg.get_info(_cl.program_info.DEVICES) prg_bins = prg.get_info(_cl.program_info.BINARIES) prg_logs = prg._get_build_logs() diff --git a/pyopencl/cffi_cl.py b/pyopencl/cffi_cl.py index 16f18f1f..7a2b42e8 100644 --- a/pyopencl/cffi_cl.py +++ b/pyopencl/cffi_cl.py @@ -42,6 +42,9 @@ from .compyte.array import f_contiguous_strides, c_contiguous_strides from pyopencl._cffi import lib as _lib +import logging +logger = logging.getLogger(__name__) + class _CLKernelArg(object): pass @@ -1583,6 +1586,7 @@ class _Program(_Common): return build_logs def build(self, options_bytes, devices=None): + logger.debug("build program: start") err = None try: self._build(options=options_bytes, devices=devices) @@ -1602,8 +1606,12 @@ class _Program(_Common): if err is not None: # Python 3.2 outputs the whole list of currently active exceptions # This serves to remove one (redundant) level from that nesting. + + logger.debug("build program: completed, error") raise err + logger.debug("build program: completed, success") + message = (75*"="+"\n").join( "Build on %s succeeded, but said:\n\n%s" % (dev, log) for dev, log in self._get_build_logs() -- GitLab