[PyOpenCL] Passing Python int to kernels

Geordan Rosario geordan at gmail.com
Thu Jun 9 16:35:50 PDT 2011


Hi,

How do I pass a Python int to a kernel?  The docs refer to 
set_scalar_arg_dtypes but it's not exactly clear as to how it should be 
done.  I've tried this:

   prg = cl.Program(ctx, program_str).build()
   prg.myKernel.set_scalar_arg_dtypes([None, None, numpy.int32])
   prg.myKernel(queue, n_globals, None, some_buf, another_buf, some_int)

But I get the error:

   pyopencl.LogicError: when processing argument #3 (1-based): 
Kernel.set_arg failed: invalid value - invalid kernel argument

What is the correct way to do this?  (Other than creating a 1-length 
buffer.)

Thanks,
-geordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tiker.net/pipermail/pyopencl/attachments/20110609/55cf3763/attachment.html>


More information about the PyOpenCL mailing list