From 58168322a9969194c8eb6a1fc22ba18c0842e1b2 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Thu, 24 May 2018 16:31:28 +0200 Subject: [PATCH] Print better error message for Array.get() on array without queue --- pyopencl/array.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyopencl/array.py b/pyopencl/array.py index 4d5334be..2d032079 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -677,8 +677,15 @@ class Array(object): assert self.flags.forc, "Array in get() must be contiguous" + queue = queue or self.queue + if queue is None: + raise ValueError("Cannot copy array to host. " + "Array has no queue. Use " + "'new_array = array.with_queue(queue)' " + "to associate one.") + if self.size: - cl.enqueue_copy(queue or self.queue, ary, self.base_data, + cl.enqueue_copy(queue, ary, self.base_data, device_offset=self.offset, is_blocking=not async_) -- GitLab