Skip to content
Snippets Groups Projects
Commit 6c8e41c5 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Suppress verbose compiler output unless asked not to.

parent 20e075d4
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,22 @@ CONSTANT_CLASSES = [
if _inspect.isclass(getattr(_cl, name))
and name[0].islower()]
class CompilerWarning(UserWarning):
pass
def compiler_output(text):
import os
from warnings import warn
if int(os.environ.get("PYOPENCL_COMPILER_OUTPUT", "0")):
warn(text, CompilerWarning)
else:
warn("Non-empty compiler output encountered. Set the "
"environment variable PYOPENCL_COMPILER_OUTPUT=1 "
"to see more.", CompilerWarning)
def _add_functionality():
cls_to_info_cls = {
_cl.Platform:
......@@ -160,8 +176,7 @@ def _add_functionality():
else:
raise RuntimeError("unexpected kind of program")
from warnings import warn
warn("%s succeeded, but resulted in non-empty logs:\n%s"
compiler_output("%s succeeded, but resulted in non-empty logs:\n%s"
% (build_type, message))
return self
......
......@@ -349,8 +349,10 @@ def _create_built_program_from_source_cached(ctx, src, options, devices, cache_d
if log is not None and log.strip())
if message:
from warnings import warn
warn("Built kernel retrieved from cache. Original from-source build had warnings:\n"+message)
from pyopencl import compiler_output
compiler_output(
"Built kernel retrieved from cache. Original from-source "
"build had warnings:\n"+message)
# {{{ build on the build-needing devices, in one go
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment