Skip to content

Commit eba596d

Browse files
committed
test: use MemoryPool in testing actx
1 parent fb971ab commit eba596d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

grudge/array_context.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def __init__(self, queue, allocator=None,
164164
warn("No memory allocator specified, please pass one. "
165165
"(Preferably a pyopencl.tools.MemoryPool in order "
166166
"to reduce device allocations)", stacklevel=2)
167+
167168
super().__init__(queue, allocator,
168169
compile_trace_callback=compile_trace_callback)
169170

@@ -509,11 +510,30 @@ class PytestPyOpenCLArrayContextFactory(
509510
_PytestPyOpenCLArrayContextFactoryWithClass):
510511
actx_class = PyOpenCLArrayContext
511512

513+
def __call__(self):
514+
from pyopencl.tools import ImmediateAllocator, MemoryPool
515+
516+
_ctx, queue = self.get_command_queue()
517+
alloc = MemoryPool(ImmediateAllocator(queue))
518+
519+
return self.actx_class(
520+
queue,
521+
allocator=alloc,
522+
force_device_scalars=self.force_device_scalars)
523+
512524

513525
class PytestPytatoPyOpenCLArrayContextFactory(
514526
_PytestPytatoPyOpenCLArrayContextFactory):
515527
actx_class = PytatoPyOpenCLArrayContext
516528

529+
def __call__(self):
530+
_ctx, queue = self.get_command_queue()
531+
532+
from pyopencl.tools import ImmediateAllocator, MemoryPool
533+
alloc = MemoryPool(ImmediateAllocator(queue))
534+
535+
return self.actx_class(queue, allocator=alloc)
536+
517537

518538
# deprecated
519539
class PytestPyOpenCLArrayContextFactoryWithHostScalars(

0 commit comments

Comments
 (0)