Issue
I found strange problem in my program using OpenCL
.
My device is android smartphone equipped with arm mali
.
So i use jni for executing OpenCL kernels.
The host(java) side calls native functions.
Then. native(c++) function sets environment for GPGPU usage.
creating buffers, setting up argument, and so on..
Do some jobs in GPGPU
after GPGPU execution,It write values back to native side, and it goes to host side.
I made my program native function internalize buffer,values every time.
But it does not release buffer after native(c++) function execution ended.
It holds value itself.
So if call native function again, it write value after previously written value.
Java ->>> Cpp ->>> Cl(increment some value buffer to 7) ->>> cpp(in this point, buffer should be deleted but it's not) ->>> java ->>> cpp ->>> Cl(increment 7 to 14) ->>>.....
In many document on the web, people said "you don't need release buffer, it is done by device automatically"
I didn't declared buffer as static,so it should be validate within single execution time.
How can i release buffer manually?
Solution
Always call clReleaseMemObject() to release CL buffer object or image object, after you finish your CL part and are ready to return the results to JAVA part. Otherwise the behavior of the buffer/image are not defined. Anything could happen, such as memory leakage, crash or else.
Answered By - Robert Wang
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.