From 74b00d82ed785de4afb16a2e918bfeeb65f345b4 Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Wed, 14 Aug 2024 14:51:14 -0500 Subject: [PATCH] attempt to improve compatibility --- arraycontext/impl/pyopencl/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arraycontext/impl/pyopencl/__init__.py b/arraycontext/impl/pyopencl/__init__.py index 6c326374..83dc9c05 100644 --- a/arraycontext/impl/pyopencl/__init__.py +++ b/arraycontext/impl/pyopencl/__init__.py @@ -125,6 +125,12 @@ def __init__(self, if wait_event_queue_length is None: wait_event_queue_length = 10 + self._force_device_scalars = True + # Subclasses might still be using the old + # "force_devices_scalars: bool = False" interface, in which case we need + # to explicitly pass force_device_scalars=True in clone() + self._passed_force_device_scalars = force_device_scalars is not None + self._wait_event_queue_length = wait_event_queue_length self._kernel_name_to_wait_event_queue: Dict[str, List[cl.Event]] = {} @@ -260,8 +266,13 @@ def call_loopy(self, t_unit, **kwargs): return {name: tga.to_tagged_cl_array(ary) for name, ary in result.items()} def clone(self): - return type(self)(self.queue, self.allocator, - wait_event_queue_length=self._wait_event_queue_length) + if self._passed_force_device_scalars: + return type(self)(self.queue, self.allocator, + wait_event_queue_length=self._wait_event_queue_length, + force_device_scalars=True) + else: + return type(self)(self.queue, self.allocator, + wait_event_queue_length=self._wait_event_queue_length) # }}}