diff --git a/doc/ref_other.rst b/doc/ref_other.rst index 8ce3be0ca65107627f837b8bff6af3e7f00b2014..e5059380dd8276155bf2723e4b46fdb82c3b0046 100644 --- a/doc/ref_other.rst +++ b/doc/ref_other.rst @@ -9,6 +9,17 @@ Obtaining Kernel Performance Statistics Controlling caching ------------------- +.. envvar:: LOOPY_NO_CACHE +.. envvar:: CG_NO_CACHE + + By default, loopy will cache (on disk) the result of various stages + of code generation to speed up future code generation of the same kernel. + By setting the environment variables :envvar:`LOOPY_NO_CACHE` or + :envvar:`CG_NO_CACHE` to any + string that :func:`pytools.strtobool` evaluates as ``True``, this caching + is suppressed. + + .. autofunction:: set_caching_enabled .. autoclass:: CacheMode diff --git a/loopy/__init__.py b/loopy/__init__.py index e5aa4259a0ab0c72c93c092dbde98451210e6637..9ff944e93b0ca394fc8e2d6673655c36e74fb585 100644 --- a/loopy/__init__.py +++ b/loopy/__init__.py @@ -390,7 +390,7 @@ def register_preamble_generators(kernel: LoopKernel, preamble_generators): if pgen not in new_pgens: if not unpickles_equally(pgen): raise LoopyError("preamble generator '%s' does not " - "compare equally after being upickled " + "compare equally after being unpickled " "and would thus disrupt loopy's caches" % pgen) @@ -408,7 +408,7 @@ def register_symbol_manglers(kernel, manglers): if m not in new_manglers: if not unpickles_equally(m): raise LoopyError("mangler '%s' does not " - "compare equally after being upickled " + "compare equally after being unpickled " "and would disrupt loopy's caches" % m) @@ -422,10 +422,15 @@ def register_symbol_manglers(kernel, manglers): # {{{ cache control import os +from pytools import strtobool + +# Caching is enabled by default, but can be disabled by setting +# the environment variables LOOPY_NO_CACHE or CG_NO_CACHE to a +# 'true' value. CACHING_ENABLED = ( - "LOOPY_NO_CACHE" not in os.environ + not strtobool(os.environ.get("LOOPY_NO_CACHE", "false")) and - "CG_NO_CACHE" not in os.environ) + not strtobool(os.environ.get("CG_NO_CACHE", "false"))) def set_caching_enabled(flag):