Starting with JOCL

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Starting with JOCL

Giovanni Idili
HI All,

I am getting started with JOCL, trying to run the HolleJOCL demo.

Here's my problem:

When creating buffers I get an error on buffer C, the only only created as WRITE_ONLY

CLBuffer<FloatBuffer> clBufferA = context.createFloatBuffer(globalWorkSize, READ_ONLY);
CLBuffer<FloatBuffer> clBufferB = context.createFloatBuffer(globalWorkSize, READ_ONLY);
CLBuffer<FloatBuffer> clBufferC = context.createFloatBuffer(globalWorkSize, WRITE_ONLY);

Error message:

Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory
        at java.nio.Bits.reserveMemory(Bits.java:633)
        at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:98)
        at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)
        at com.jogamp.common.nio.Buffers.newDirectByteBuffer(Buffers.java:67)
        at com.jogamp.common.nio.Buffers.newDirectFloatBuffer(Buffers.java:109)
        at com.jogamp.opencl.CLContext.createFloatBuffer(CLContext.java:316)
        at HelloJOCL.main(HelloJOCL.java:35)

Any idea what this is and how can I get past it?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Starting with JOCL

Michael Bien
Hi,

i got almost the same mail a few days ago :)
http://forum.jogamp.org/HelloJOCL-Problems-on-MacOSX-tp2456996p2456996.html

please reduce the buffer length or increase the direct memory size as mentioned in my answer. I will reduce the hardcoded value in the demo... which should make it compatible with more machines.

best regards,
and sorry for the inconveniences,

michael

On 02/12/2011 06:26 PM, John_Idol [via jogamp] wrote:
HI All,

I am getting started with JOCL, trying to run the HolleJOCL demo.

Here's my problem:

When creating buffers I get an error on buffer C, the only only created as WRITE_ONLY

CLBuffer<FloatBuffer> clBufferA = context.createFloatBuffer(globalWorkSize, READ_ONLY);
CLBuffer<FloatBuffer> clBufferB = context.createFloatBuffer(globalWorkSize, READ_ONLY);
CLBuffer<FloatBuffer> clBufferC = context.createFloatBuffer(globalWorkSize, WRITE_ONLY);

Error message:

Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory
        at java.nio.Bits.reserveMemory(Bits.java:633)
        at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:98)
        at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)
        at com.jogamp.common.nio.Buffers.newDirectByteBuffer(Buffers.java:67)
        at com.jogamp.common.nio.Buffers.newDirectFloatBuffer(Buffers.java:109)
        at com.jogamp.opencl.CLContext.createFloatBuffer(CLContext.java:316)
        at HelloJOCL.main(HelloJOCL.java:35)

Any idea what this is and how can I get past it?

Thanks!


If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Starting-with-JOCL-tp2481173p2481173.html
To start a new topic under jogamp, email [hidden email]
To unsubscribe from jogamp, click here.


-- 
- - - -
http://michael-bien.com
Reply | Threaded
Open this post in threaded view
|

Re: Starting with JOCL

Giovanni Idili
Hi Michael, 

Thanks a lot for your help, 

That got me past that line but then I started getting an error on this operation:

put1DRangeKernel(kernel, 0, globalWorkSize, localWorkSize)


Error message:


com.jogamp.opencl.CLException$CLInvalidWorkGroupSizeException: can not enqueue 1DRange CLKernel [id: 4756395056 name: VectorAdd]

 with gwo: null gws: {11520} lws: {256} 

cond.: null events: null [error: CL_INVALID_WORK_GROUP_SIZE]

at com.jogamp.opencl.CLException.newException(CLException.java:78)

Not too sure what this error means, but it looks like this was the cause --> CL_INVALID_WORK_GROUP_SIZE 


So from the same post you pointed out I used the following line to create the cmd queue:


CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); 


This does the trick, but to be honest I don't really understand why this works! :)


What does that line mean, am I using CPU, GPUS or both?


Thanks for your time man, 


Giovanni


On Sat, Feb 12, 2011 at 5:40 PM, Michael Bien [via jogamp] <[hidden email]> wrote:
Hi,

i got almost the same mail a few days ago :)
http://forum.jogamp.org/HelloJOCL-Problems-on-MacOSX-tp2456996p2456996.html

please reduce the buffer length or increase the direct memory size as mentioned in my answer. I will reduce the hardcoded value in the demo... which should make it compatible with more machines.

best regards,
and sorry for the inconveniences,

michael

On 02/12/2011 06:26 PM, John_Idol [via jogamp] wrote:
HI All,

I am getting started with JOCL, trying to run the HolleJOCL demo.

Here's my problem:

When creating buffers I get an error on buffer C, the only only created as WRITE_ONLY

CLBuffer<FloatBuffer> clBufferA = context.createFloatBuffer(globalWorkSize, READ_ONLY);
CLBuffer<FloatBuffer> clBufferB = context.createFloatBuffer(globalWorkSize, READ_ONLY);
CLBuffer<FloatBuffer> clBufferC = context.createFloatBuffer(globalWorkSize, WRITE_ONLY);

Error message:

Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory
        at java.nio.Bits.reserveMemory(Bits.java:633)
        at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:98)
        at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)
        at com.jogamp.common.nio.Buffers.newDirectByteBuffer(Buffers.java:67)
        at com.jogamp.common.nio.Buffers.newDirectFloatBuffer(Buffers.java:109)
        at com.jogamp.opencl.CLContext.createFloatBuffer(CLContext.java:316)
        at HelloJOCL.main(HelloJOCL.java:35)

Any idea what this is and how can I get past it?

Thanks!


If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Starting-with-JOCL-tp2481173p2481173.html
To start a new topic under jogamp, email [hidden email]
here.


-- 
- - - -
http://michael-bien.com



If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Starting-with-JOCL-tp2481173p2481259.html
To unsubscribe from Starting with JOCL, click here.

Reply | Threaded
Open this post in threaded view
|

Re: Starting with JOCL

Michael Bien
Hello Giovanni,

a CLPlatform (representing an OpenCL driver) can have multiple CLDevices of different types (CPU, GPU, FPGAs, other kind of accelerators). If you create a context with CLContext.create() it will bind all devices of the default platform to this new context.

thats the initialization. Later if you want to compute something you will have to create a CLCommandQueue first. A CLCommandQueue is bound to only *one* device. CLDevices have different capabilities. Thats the reason why HelloJOCL ran on one of your devices but didn't on the other one as you tested it.

Local work size is highly device specific and can vary a lot esp between CPUs and GPUs. You can read the max value with device.getMaxWorkgroupSize() but it showed in our tests that picking the max value is not always reliable on some drivers :)

you can go through all devices (CLPlatform.listDevices()) and pick the best you find or use a filter at context creation:
http://forum.jogamp.org/HelloJOCL-Problems-on-MacOSX-tp2456996p2461127.html

hope that helps,
best regards,

michael


On 02/12/2011 07:07 PM, giovanni.idili [via jogamp] wrote:
Hi Michael, 

Thanks a lot for your help, 

That got me past that line but then I started getting an error on this operation:

put1DRangeKernel(kernel, 0, globalWorkSize, localWorkSize)


Error message:


com.jogamp.opencl.CLException$CLInvalidWorkGroupSizeException: can not enqueue 1DRange CLKernel [id: 4756395056 name: VectorAdd]

 with gwo: null gws: {11520} lws: {256} 

cond.: null events: null [error: CL_INVALID_WORK_GROUP_SIZE]

at com.jogamp.opencl.CLException.newException(CLException.java:78)

Not too sure what this error means, but it looks like this was the cause --> CL_INVALID_WORK_GROUP_SIZE 


So from the same post you pointed out I used the following line to create the cmd queue:


CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); 


This does the trick, but to be honest I don't really understand why this works! :)


What does that line mean, am I using CPU, GPUS or both?


Thanks for your time man, 


Giovanni


On Sat, Feb 12, 2011 at 5:40 PM, Michael Bien [via jogamp] <[hidden email]> wrote:
Hi,

i got almost the same mail a few days ago :)
http://forum.jogamp.org/HelloJOCL-Problems-on-MacOSX-tp2456996p2456996.html

please reduce the buffer length or increase the direct memory size as mentioned in my answer. I will reduce the hardcoded value in the demo... which should make it compatible with more machines.

best regards,
and sorry for the inconveniences,

michael

On 02/12/2011 06:26 PM, John_Idol [via jogamp] wrote:
HI All,

I am getting started with JOCL, trying to run the HolleJOCL demo.

Here's my problem:

When creating buffers I get an error on buffer C, the only only created as WRITE_ONLY

CLBuffer<FloatBuffer> clBufferA = context.createFloatBuffer(globalWorkSize, READ_ONLY);
CLBuffer<FloatBuffer> clBufferB = context.createFloatBuffer(globalWorkSize, READ_ONLY);
CLBuffer<FloatBuffer> clBufferC = context.createFloatBuffer(globalWorkSize, WRITE_ONLY);

Error message:

Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory
        at java.nio.Bits.reserveMemory(Bits.java:633)
        at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:98)
        at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)
        at com.jogamp.common.nio.Buffers.newDirectByteBuffer(Buffers.java:67)
        at com.jogamp.common.nio.Buffers.newDirectFloatBuffer(Buffers.java:109)
        at com.jogamp.opencl.CLContext.createFloatBuffer(CLContext.java:316)
        at HelloJOCL.main(HelloJOCL.java:35)

Any idea what this is and how can I get past it?

Thanks!


If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Starting-with-JOCL-tp2481173p2481173.html
To start a new topic under jogamp, email [hidden email]
here.


-- 
- - - -
http://michael-bien.com



If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Starting-with-JOCL-tp2481173p2481259.html




If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Starting-with-JOCL-tp2481173p2481442.html
To start a new topic under jogamp, email [hidden email]
To unsubscribe from jogamp, click here.


-- 
- - - -
http://michael-bien.com
Reply | Threaded
Open this post in threaded view
|

Re: Starting with JOCL

Michael Bien
In reply to this post by Giovanni Idili
Reply | Threaded
Open this post in threaded view
|

Re: Starting with JOCL

Giovanni Idili
This works great!

Thanks a lot for your time and help.

- Giovanni

On Sat, Feb 12, 2011 at 8:08 PM, Michael Bien [via jogamp] <[hidden email]> wrote:
updated the sample:
https://github.com/mbien/jocl-demos/blob/d3d8c548223ec79987d7326c808f830bc3f65813/src/com/jogamp/opencl/demos/hellojocl/HelloJOCL.java

-michael



If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Starting-with-JOCL-tp2481173p2482060.html
To unsubscribe from Starting with JOCL, click here.