Login  Register

putMapBuffer - data In/Out performance issue

Posted by suleman on Jun 30, 2011; 4:12pm
URL: https://forum.jogamp.org/putMapBuffer-data-In-Out-performance-issue-tp3126498.html

Hi,

 I have implemented a JOCL program using putMapBuffer(...). Actual putMapBuffer call takes approximatly 0 milli seconds (on CPU based OpenCL execution). But after this call i have to copy data from my application buffer to the pointers (ByteArray h_data1 and h_data2 as shown in below code). These copying of data is a expensive in terms of time.
After invocation of kernel i copy back results using the pointer  (h_data3). The copying data back to host buffer is Ok and efficient in terms of time.

Am i doing correct steps or not?
Is there an efficient way to copy data from application buffers to the pointers returned by putMapBuffer methods ?

Many thanks

CODE EXAMPLE
------------------------------
....
   h_data1 = queue.putMapBuffer(clBufferA,WRITE,true);
   h_data2 = queue.putMapBuffer(clBufferB,WRITE,true);
...    
//input copy time (very expensive in terms of time)
long time1 = nanoTime();
h_data1.clear();
h_data1.asFloatBuffer().put(clBufferA.getBuffer());
h_data2.clear();
h_data2.asFloatBuffer().put(clBufferB.getBuffer());
time1 = nanoTime() - time1;            
             
//Kernel execution
 queue.put1DRangeKernel(kernel, 0, globalWorkSize, localWorkSize);
 queue.finish();

 //Output PutMapBuffer
 h_data3 = queue.putMapBuffer(clBufferC,READ,true);
               
//Data copy in App buffer  (very efficient in terms of time)
long time2 = nanoTime();
clBufferC = clBufferC.cloneWith(h_data3.asFloatBuffer());
time2 = nanoTime() - time2;