Skip to content
Closed
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
12 changes: 11 additions & 1 deletion pytato/target/loopy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,25 @@ class LoopyPyOpenCLTarget(LoopyTarget):

The :mod:`pyopencl` device used to construct the
:class:`loopy.PyOpenCLTarget`, or *None*.

.. attribute:: loopy_target

An optional :class:`loopy.PyOpenCLTarget` that gets used as the
underlying code generation target.
"""

def __init__(self, device: Optional["pyopencl.Device"] = None):
def __init__(self, device: Optional["pyopencl.Device"] = None,
Copy link
Collaborator Author

@matthiasdiener matthiasdiener Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a new constructor arg that accepts an lp.PyOpenCLTarget()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 2942fbf what you had in mind @inducer?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be sending you around in circles, but I just realized we don't even need any pytato changes. We can simply subclass LoopyPyOpenCLTarget in the array context and override get_loopy_target there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of inducer/arraycontext@2768fee ?

loopy_target: Optional[loopy.PyOpenCLTarget] = None) -> None:
if device is not None:
from warnings import warn
warn("Passing 'device' is deprecated and will stop working in 2023.",
DeprecationWarning, stacklevel=2)
self.loopy_target = loopy_target

def get_loopy_target(self) -> "loopy.LoopyPyOpenCLTarget":
if self.loopy_target:
return self.loopy_target

import loopy as lp
return lp.PyOpenCLTarget()

Expand Down