Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecated kernel executor cache #904

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/tutorial.rst
Original file line number Diff line number Diff line change
@@ -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()

25 changes: 3 additions & 22 deletions loopy/translation_unit.py
Original file line number Diff line number Diff line change
@@ -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)
@@ -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.",
@@ -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"]

@@ -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):

Unchanged files with check annotations Beta

# pstate.expect(_colon):
pstate.advance()
subscript = self.parse_expression(pstate, _PREC_UNARY)
return SubArrayRef(swept_inames, subscript)

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest with Intel CL

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest with Intel CL

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest with Intel CL

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest with Intel CL

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest with Intel CL

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest with Intel CL

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (macos-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (macos-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (macos-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (macos-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (macos-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (macos-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (ubuntu-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (ubuntu-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (ubuntu-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (ubuntu-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (ubuntu-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest (ubuntu-latest)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest without arg check

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest without arg check

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest without arg check

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest without arg check

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest without arg check

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest without arg check

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest Twice (for cache behavior)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest Twice (for cache behavior)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest Twice (for cache behavior)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest Twice (for cache behavior)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest Twice (for cache behavior)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.

Check warning on line 1743 in loopy/symbolic.py

GitHub Actions / Conda Pytest Twice (for cache behavior)

swept_inames passed to SubArrayRef was not a tuple. This is deprecated and will stop working in 2025. Pass a tuple instead.
else:
pstate = rollback_pstate
return super().parse_prefix(rollback_pstate)
if inline:
caller = lp.inline_callable_kernel(caller, "wence_function")
_evt, (out, ) = caller(queue, x=x, y=y)

Check warning on line 370 in test/test_callables.py

GitHub Actions / Conda Pytest with Intel CL

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.

Check warning on line 370 in test/test_callables.py

GitHub Actions / Conda Pytest (macos-latest)

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.

Check warning on line 370 in test/test_callables.py

GitHub Actions / Conda Pytest (macos-latest)

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.

Check warning on line 370 in test/test_callables.py

GitHub Actions / Conda Pytest (ubuntu-latest)

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.

Check warning on line 370 in test/test_callables.py

GitHub Actions / Conda Pytest (ubuntu-latest)

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.

Check warning on line 370 in test/test_callables.py

GitHub Actions / Conda Pytest without arg check

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.

Check warning on line 370 in test/test_callables.py

GitHub Actions / Conda Pytest without arg check

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.

Check warning on line 370 in test/test_callables.py

GitHub Actions / Conda Pytest Twice (for cache behavior)

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.

Check warning on line 370 in test/test_callables.py

GitHub Actions / Conda Pytest Twice (for cache behavior)

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.
assert np.allclose(out, x-y)
if inline:
knl = lp.inline_callable_kernel(knl, "twice")
_evt, (out,) = knl(cq, x=np.ones((10, 10)))

Check warning on line 1258 in test/test_callables.py

GitHub Actions / Conda Pytest with Intel CL

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.

Check warning on line 1258 in test/test_callables.py

GitHub Actions / Conda Pytest (macos-latest)

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.

Check warning on line 1258 in test/test_callables.py

GitHub Actions / Conda Pytest (macos-latest)

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.

Check warning on line 1258 in test/test_callables.py

GitHub Actions / Conda Pytest (ubuntu-latest)

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.

Check warning on line 1258 in test/test_callables.py

GitHub Actions / Conda Pytest (ubuntu-latest)

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.

Check warning on line 1258 in test/test_callables.py

GitHub Actions / Conda Pytest without arg check

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.

Check warning on line 1258 in test/test_callables.py

GitHub Actions / Conda Pytest without arg check

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.

Check warning on line 1258 in test/test_callables.py

GitHub Actions / Conda Pytest Twice (for cache behavior)

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.

Check warning on line 1258 in test/test_callables.py

GitHub Actions / Conda Pytest Twice (for cache behavior)

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.
np.testing.assert_allclose(out[:5], 1)
np.testing.assert_allclose(out[5:], 2)