Skip to content

Commit

Permalink
support aborting on cache miss
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Feb 28, 2024
1 parent 5f098fa commit 8fd54b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions loopy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ def register_symbol_manglers(kernel, manglers):
and
"CG_NO_CACHE" not in os.environ)

from pytools import strtobool
ABORT_ON_CACHE_MISS = strtobool(os.environ.get("LOOPY_ABORT_ON_CACHE_MISS", "False"))


def set_caching_enabled(flag):
"""Set whether :mod:`loopy` is allowed to use disk caching for its various
Expand Down
5 changes: 4 additions & 1 deletion loopy/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def generate_code_v2(program):

# {{{ cache retrieval

from loopy import CACHING_ENABLED
from loopy import CACHING_ENABLED, ABORT_ON_CACHE_MISS

if CACHING_ENABLED:
input_program = program
Expand All @@ -583,6 +583,9 @@ def generate_code_v2(program):
" code generation cache hit")
return result
except KeyError:
if ABORT_ON_CACHE_MISS:
raise

logger.debug(f"TranslationUnit with entrypoints {program.entrypoints}:"
" code generation cache miss")

Expand Down

0 comments on commit 8fd54b7

Please sign in to comment.