Skip to content

Commit

Permalink
remove deprecated kernel executor cache (#904)
Browse files Browse the repository at this point in the history
* remove deprecated kernel executor cache

* fix doctest
  • Loading branch information
matthiasdiener authored Jan 28, 2025
1 parent 3cf8c93 commit 87d6ccf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
1 change: 1 addition & 0 deletions doc/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ For convenience, loopy kernels also directly accept :mod:`numpy` arrays:

.. doctest::

>>> knl = lp.set_options(knl, write_code=False)
>>> evt, (out,) = knl(queue, a=x_vec_host)
>>> assert (out == (2*x_vec_host)).all()

Expand Down
25 changes: 3 additions & 22 deletions loopy/translation_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,9 @@ class TranslationUnit:
entrypoints: frozenset[str]

def __post_init__(self):

assert isinstance(self.entrypoints, abc_Set)
assert isinstance(self.callables_table, Map)

object.__setattr__(self, "_program_executor_cache", {})

def copy(self, **kwargs: Any) -> Self:
target = kwargs.pop("target", None)
t_unit = replace(self, **kwargs)
Expand Down Expand Up @@ -411,7 +408,7 @@ def __call__(self, *args, **kwargs):
#
# In addition, the executor interface speeds up kernel invocation
# by removing one unnecessary layer of function call.
warn("TranslationUnit.__call__ will become uncached in 2024, "
warn("TranslationUnit.__call__ is uncached as of 2025, "
"meaning it will incur possibly substantial compilation cost "
"with every invocation. Use TranslationUnit.executor to obtain "
"an object that holds longer-lived caches.",
Expand Down Expand Up @@ -444,12 +441,7 @@ def __call__(self, *args, **kwargs):

kwargs["entrypoint"] = entrypoint

key = self.target.get_kernel_executor_cache_key(*args, **kwargs)
try:
pex = self._program_executor_cache[key] # pylint: disable=no-member
except KeyError:
pex = self.target.get_kernel_executor(self, *args, **kwargs)
self._program_executor_cache[key] = pex # pylint: disable=no-member
pex = self.target.get_kernel_executor(self, *args, **kwargs)

del kwargs["entrypoint"]

Expand All @@ -460,20 +452,9 @@ def __str__(self):

return "\n".join(
str(clbl.subkernel)
for name, clbl in self.callables_table.items()
for _name, clbl in self.callables_table.items()
if isinstance(clbl, CallableKernel))

# FIXME: Delete these when _program_executor_cache leaves the building
def __getstate__(self):
from dataclasses import asdict
return asdict(self)

def __setstate__(self, state_obj):
for k, v in state_obj.items():
object.__setattr__(self, k, v)

object.__setattr__(self, "_program_executor_cache", {})

# FIXME: This is here because Firedrake expects it, for some legacy reason.
# Without that, it would be safe to delete.
def update_persistent_hash(self, key_hash, key_builder):
Expand Down

0 comments on commit 87d6ccf

Please sign in to comment.