From 58e62e718f9fb407a612ac8ac3fd62a5efed1236 Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Thu, 14 Nov 2019 19:27:54 +0100
Subject: [PATCH] Add friendly hint when calling OpenCL kernels with
 PyCUDA/Numpy arrays

---
 pystencils/opencl/opencljit.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pystencils/opencl/opencljit.py b/pystencils/opencl/opencljit.py
index c58f81e9d..6b5893865 100644
--- a/pystencils/opencl/opencljit.py
+++ b/pystencils/opencl/opencljit.py
@@ -117,6 +117,10 @@ def make_python_function(kernel_function_node, opencl_queue, opencl_ctx, argumen
         except KeyError:
             full_arguments = argument_dict.copy()
             full_arguments.update(kwargs)
+            assert not any(isinstance(a, np.ndarray)
+                           for a in full_arguments.values()), 'Calling a OpenCL kernel with a Numpy array!'
+            assert not any('pycuda' in str(type(a))
+                           for a in full_arguments.values()), 'Calling a OpenCL kernel with a PyCUDA array!'
             shape = _check_arguments(parameters, full_arguments)
 
             indexing = kernel_function_node.indexing
-- 
GitLab