CLBuffer.getBuffer() & rewind

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

CLBuffer.getBuffer() & rewind

Felix
Hi,

I experienced several JVM crashes on OSX 10.6 with varying crash reports (Crashed compile thread2, modified freed object, System.getEnv() - method not found, to name a few). Basically the only thing my program did was:

(1) creating an uninitialized buffer using "context.createFloatBuffer(warpGlobalWorkSize, CLMemory.Mem.READ_WRITE)"
(2) reading a CLBuffer<FloatBuffer> back to main memory using "putReadBuffer"
(3) Getting the FloatBuffer using "getBuffer"
(4) reading some floats from the buffer which changes the buffer's position
(5) goto 2
For now things seam to be much better after I added "buffer.rewind()" after reading the floats in (4).

Is that the expected behavior? Is rewind() necessary by design? Couldn't rewind be called internally?

Felix
Reply | Threaded
Open this post in threaded view
|

Re: CLBuffer.getBuffer() & rewind

notzed
Yes you have to use rewind() all the time if you're just using get() and put(x).

This is pretty much how the nio api's work afaik, and it wouldn't make much sense for a third party library to be twiddling with your buffer state.