Api copy works when copying individual elements but not the entire buffer

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

Api copy works when copying individual elements but not the entire buffer

Coby Soss
This code doesn't appear to send the correct data to the kernel.

clBuffer.getBuffer().clear();
clBuffer.getBuffer().rewind();
clBuffer.getBuffer().put(Buffer,0, Buffer.length);
clQueue.putWriteBuffer(clBuffer, true);

This code does

clBuffer.getBuffer().clear();
clBuffer.getBuffer().rewind();
clBuffer.getBuffer().put(0,Buffer[0]);
clQueue.putWriteBuffer(clBuffer, true);

Both overloads of put are being used correctly according to the java documentation. Is there something about the JOCL API that causes one version of put to be sent to the kernel and not the other?

Reply | Threaded
Open this post in threaded view
|

Re: Api copy works when copying individual elements but not the entire buffer

gouessej
Administrator
Hi

The first put() method you use is relative whereas the second put() method you use is absolute (cf. the Java documentation). In the first case, just call clBuffer.getBuffer().rewind() before calling clQueue.putWriteBuffer(clBuffer, true) and it should work.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Api copy works when copying individual elements but not the entire buffer

Coby Soss
Thanks for the response. I believe I did use rewind in both scenarios. That is what is confusing me.