From 5f697b529860ba4d6e9dbb4887f51b5c55e3aee4 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Thu, 18 Aug 2011 12:17:26 -0500 Subject: [PATCH] Test that memory pools properly interact with arrays. --- test/test_array.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/test_array.py b/test/test_array.py index 7bd1b97f..9854afdc 100644 --- a/test/test_array.py +++ b/test/test_array.py @@ -13,8 +13,9 @@ def have_cl(): return False if have_cl(): - import pyopencl.array as cl_array import pyopencl as cl + import pyopencl.array as cl_array + import pyopencl.tools as cl_tools from pyopencl.tools import pytest_generate_tests_for_pyopencl \ as pytest_generate_tests from pyopencl.characterize import has_double_support @@ -600,6 +601,20 @@ def test_vector_fill(ctx_factory): a_gpu = cl_array.zeros(queue, 100, dtype=cl_array.vec.float4) +@pytools.test.mark_test.opencl +def test_mem_pool_with_arrays(ctx_factory): + context = ctx_factory() + queue = cl.CommandQueue(context) + mem_pool = cl_tools.MemoryPool(cl_tools.CLAllocator(context)) + + a_dev = cl_array.arange(queue, 2000, dtype=np.float64, allocator=mem_pool) + b_dev = cl_array.to_device(queue, np.arange(2000), allocator=mem_pool) + 4000 + + result = cl_array.dot(a_dev, b_dev) + assert a_dev.allocator is mem_pool + assert b_dev.allocator is mem_pool + assert result.allocator is mem_pool + if __name__ == "__main__": # make sure that import failures get reported, instead of skipping the -- GitLab