From 341c766e46eafb71340190fba50f2f18224e80b6 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Mon, 15 Jul 2013 15:56:05 -0400
Subject: [PATCH] Try and make map_to_host test work on GPUs

---
 test/test_array.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/test/test_array.py b/test/test_array.py
index 62904dce..dae8634e 100644
--- a/test/test_array.py
+++ b/test/test_array.py
@@ -684,7 +684,14 @@ def test_map_to_host(ctx_factory):
     context = ctx_factory()
     queue = cl.CommandQueue(context)
 
-    a_dev = cl_array.zeros(queue, (5, 6, 7,), dtype=np.float32)
+    if context.devices[0].type & cl.device_type.GPU:
+        mf = cl.mem_flags
+        allocator = cl_tools.DeferredAllocator(
+                context, mf.READ_WRITE | mf.ALLOC_HOST_PTR)
+    else:
+        allocator = None
+
+    a_dev = cl_array.zeros(queue, (5, 6, 7,), dtype=np.float32, allocator=allocator)
     a_host = a_dev.map_to_host()
     a_host[1, 2, 3] = 10
     a_dev[3, 2, 1] = 10
-- 
GitLab