From 0aebd7bc94a2cebcbf33e7a8191560b750d755e4 Mon Sep 17 00:00:00 2001
From: zachjweiner <zachjweiner@gmail.com>
Date: Sun, 1 Nov 2020 16:06:50 -0600
Subject: [PATCH] Don't exceed max_mem_alloc_size in test

---
 test/test_array.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/test/test_array.py b/test/test_array.py
index 381105bf..b5e99273 100644
--- a/test/test_array.py
+++ b/test/test_array.py
@@ -208,11 +208,13 @@ def test_vector_fill(ctx_factory):
 def test_zeros_large_array(ctx_factory):
     context = ctx_factory()
     queue = cl.CommandQueue(context)
+    dev = queue.device
 
-    if queue.device.address_bits == 64:
+    size = 2**28 + 1
+    if dev.address_bits == 64 and dev.max_mem_alloc_size >= 8 * size:
         # this shouldn't hang/cause errors
         # see https://github.com/inducer/pyopencl/issues/395
-        a_gpu = cl_array.zeros(queue, (2**28 + 1,), dtype="float64")
+        a_gpu = cl_array.zeros(queue, (size,), dtype="float64")
         # run a couple kernels to ensure no propagated runtime errors
         a_gpu[...] = 1.
         a_gpu = 2 * a_gpu - 3
-- 
GitLab