From 77f60fa179c9c16071651a7662faebe4319c6aae Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Thu, 8 Oct 2015 08:52:25 -0500 Subject: [PATCH] Add note about kernel name lookup --- doc/runtime.rst | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/runtime.rst b/doc/runtime.rst index 3704fc59..a829381d 100644 --- a/doc/runtime.rst +++ b/doc/runtime.rst @@ -701,8 +701,25 @@ Programs and Kernels .. attribute:: kernel_name - :class:`Kernel` objects can be produced from a built - (see :meth:`build`) program simply by attribute lookup. + You may use ``program.kernel_name`` to obtain a :class:`Kernel` + objects from a program. Note that every lookup of this type + produces a new kernel object, so that this **won't** work:: + + prg.sum.set_args(a_g, b_g, res_g) + ev = cl.enqueue_nd_range_kernel(queue, prg.sum, a_np.shape, None) + + Instead, either use the (recommended, stateless) calling interface:: + + prg.sum(queue, prg.sum, a_np.shape, None) + + or keep the kernel in a temporary variable:: + + sum_knl = prg.sum + sum_knl.set_args(a_g, b_g, res_g) + ev = cl.enqueue_nd_range_kernel(queue, sum_knl, a_np.shape, None) + + Note that the :class:`Program` has to be built (see :meth:`build`) in + order for this to work simply by attribute lookup. .. note:: -- GitLab