Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
30 posts
|
Are you ready for yet another OpenCL/JOCL beginner question?
Here we go: I am in need of passing down to a given kernel an array of arrays, frantically looking for examples but can't seem to find any. Can I do something like the following? CLBuffer<CLBuffer<FloatBuffer>> clBufferOfBuffers = new etc. Or am I better off just passing different buffers one for each of the items I need to pass for a given index? Any help/advice appreciated. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
407 posts
|
Hello John,
i am afraid but i believe you can't do that with OpenCL yet. for example a kernel declaration would have to look like: kernel void compute(global int** array) { } but that won't compile with current drivers. OpenCL spec 6.8 Language Restrictions: "Arguments to __kernel functions in a program cannot be declared as a pointer to a pointer(s). Variables inside a function or arguments to non __kernel functions in a program can be declared as a pointer to a pointer(s)." So you will have to find a workaround. You could try to flatten out your ND buffer in a 1D buffer and calculate the offset in the kernel. If its rather a small array of buffers but not a ND buffer, you could just pass every buffer as kernel argument. a few features which might be useful: - you can create CLSubBuffers from CLBuffers if you are using CL1.1 - (or you could just use a plain CLBuffer, calculate offsets in the kernel and .slice() the java.util.Buffer for your convenience) just keep your questions coming :) best regards, michael On 05/10/2011 02:47 PM, John_Idol [via jogamp] wrote: > > Are you ready for yet another OpenCL/JOCL beginner question? > > Here we go: I am in need of passing down to a given kernel an array of > arrays, frantically looking for examples but can't seem to find any. > > Can I do something like the following? > > CLBuffer<CLBuffer<FloatBuffer>> clBufferOfBuffers = new etc. > > Or am I better off just passing different buffers one for each the items I > need to pass for a given index? > > Any help/advice appreciated. > ... [show rest of quote] |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
30 posts
|
Thanks a lot for this Michael,
I think I will pass every buffer as a kernel argument as I need to pass down only a few variable, so I won't bother calculating offsets. As a matter of interest though, would you be able to point me to an usage example of CLSubBuffers and how they are declared in the __kernel functions? Best Regards, Giovanni |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
407 posts
|
sub buffers are behaving just like normal buffers and are used in the
kernel like normal global memory. They are views of certain buffer regions and may even overlap with other subbuffers. CLBuffer<FloatBuffer> buffer = context.createFloatBuffer(64); CLSubBuffer<FloatBuffer> subBuffer = buffer.createSubBuffer(start, lenght); CLSubBuffer extends CLBuffer. OpenCL 1.1 does only support creating subbuffers from buffers, deeper hierarchies are not supported. (very similar as the java.nio.Buffer.slice() API but you can slice() as deep as you wish) best regards, michael On 05/10/2011 05:38 PM, John_Idol [via jogamp] wrote: > Thanks a lot for this Michael, > > I think I will pass every buffer as a kernel argument as I need to pass down > only a few variable, so I won't bother calculating offsets. > > As a matter of interest though, would you be able to point me to an usage > example of CLSubBuffers and how they are declared in the __kernel functions? > > Best Regards, > > Giovanni > |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
30 posts
|
I went for separate buffers, but this is very useful info - Thanks!
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
1 post
|
Hi,
I am working with a image processing code (using Image2d class). According to the ImageTest example in jocl i have coded the program but i am facing below exception while executing the kernel?
Attitude
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Administrator
857 posts
|
I don't see your exception trace. Does ImageTest fail for you, or is it just your own new code that's failing?
|
Free forum by Nabble | Edit this page |