Hello Andrew,

You have to transfer your arrays to GPU memory before passing them to
the kernel (using pyopencl.array.to_device(), for example).

Best regards,
Bogdan

On Fri, Sep 30, 2011 at 11:08 PM, andrew cooke <[email protected]> wrote:
>
> Hi,
>
>
> I'm getting an error with my very first attempt at using pyopencl.  I'm sure
> this is something simple, but I can't work out what.  Please could someone
> take a moment to explain?  Code and error below.
>
> Thanks,
>
> Andrew
>
> PS The output is cut + pasted from Intellij Idea's output pane.  It really
> does repeat the messages about the kernel twice.  No idea why.
>
>
>
> import pyopencl as cl
> import numpy as n
>
>
> def main():
>
>    a = n.zeros(3, dtype=n.uint8)
>    a[0] = 32
>    a[1] = 43
>    a[2] = 129
>
>    ctx = cl.create_some_context()
>    queue = cl.CommandQueue(ctx)
>
>    prg = cl.Program(ctx, """
>        __kernel void test1(__global const uchar *a,
>                            __global int *b,
>                            __global int *c,
>                            __global int *d) {
>            *b = a[0];
>            *c = a[1];
>            *d = a[2];
>        }
>        """).build()
>
>    b, c, d = map(n.int32, [0, 0, 0])
>    print(a,b,c,d)
>    event = prg.test1(queue, 1, None, a, b, c, d)
>    event.wait()
>    print(a,b,c,d)
>
>
> if __name__ == '__main__':
>    main()
>
>
> /home/andrew/projects/personal/kultrung/env/bin/python3.2
> /home/andrew/projects/personal/kultrung/src/kultrung/test1.py
> /home/andrew/projects/personal/kultrung/env/lib/python3.2/site-packages/pyopencl/cache.py:343:
> UserWarning: Build succeeded, but resulted in non-empty logs:
> Build on <pyopencl.Device 'Intel(R) Core(TM)2 CPU         T5600  @ 1.83GHz' at
> 0x13778e0> succeeded, but said:
>
> Build started
> Kernel <test1> was successfully vectorized
> Done.
>  warn("Build succeeded, but resulted in non-empty logs:\n"+message)
> [ 32  43 129] 0 0 0
> /home/andrew/projects/personal/kultrung/env/lib/python3.2/site-packages/pyopencl/__init__.py:174:
> UserWarning: Build succeeded, but resulted in non-empty logs:
> Build on <pyopencl.Device 'Intel(R) Core(TM)2 CPU         T5600  @ 1.83GHz' at
> 0x13778e0> succeeded, but said:
>
> Build started
> Kernel <test1> was successfully vectorized
> Done.
>  warn("Build succeeded, but resulted in non-empty logs:\n"+message)
> Traceback (most recent call last):
>  File
>  "/home/andrew/projects/personal/kultrung/env/lib/python3.2/site-packages/pyopencl/__init__.py",
>  line 258, in kernel_set_args
>    arg_type_chars = self.__dict__["_arg_type_chars"]
> KeyError: '_arg_type_chars'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>  File
>  "/home/andrew/projects/personal/kultrung/env/lib/python3.2/site-packages/pyopencl/__init__.py",
>  line 261, in kernel_set_args
>    self.set_arg(i, arg)
> pyopencl.LogicError: clSetKernelArg failed: invalid arg size
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>  File "/home/andrew/projects/personal/kultrung/src/kultrung/test1.py", line
>  36, in <module>
>    main()
>  File "/home/andrew/projects/personal/kultrung/src/kultrung/test1.py", line
>  30, in main
>    event = prg.test1(queue, 1, None, a, b, c, d)
>  File
>  "/home/andrew/projects/personal/kultrung/env/lib/python3.2/site-packages/pyopencl/__init__.py",
>  line 238, in kernel_call
>    self.set_args(*args)
>  File
>  "/home/andrew/projects/personal/kultrung/env/lib/python3.2/site-packages/pyopencl/__init__.py",
>  line 278, in kernel_set_args
>    % (i+1, str(e)))
> pyopencl.LogicError: when processing argument #1 (1-based): clSetKernelArg
>  failed: invalid arg size
>
> Process finished with exit code 1
>
> _______________________________________________
> PyOpenCL mailing list
> [email protected]
> http://lists.tiker.net/listinfo/pyopencl
>

_______________________________________________
PyOpenCL mailing list
[email protected]
http://lists.tiker.net/listinfo/pyopencl

Reply via email to