0

I am using the JOCL library (by JOGAMP) and I was wondering if it was possible to measure the time it took to transfer data from host to device, the time the kernel took and the time it took to get the results back separately?

Currently I am invoking my kernels like this:

queue.putReadBuffer(...).put1DKernel(...).putWriteBuffer(...)

Veles
  • 1,512
  • 4
  • 14
  • 28
  • JavaCL allows command queues with profiling (part of the OpenCL standard) so I'm sure JOCL provides it too in some form. The way to do this in OpenCL is to get an event object for the buffer read/write/kernel exec and, once the action has finished, query the profiling counters for the event to find out when the event started and finished. – chippies Apr 25 '13 at 13:35
  • I figured that out...but I still can't figure out how to create a CLEvent in JOCL and use it to measure the time? – Veles Apr 26 '13 at 10:30
  • I think [http://jogamp.org/deployment/jogamp-next/javadoc/jocl/javadoc/com/jogamp/opencl/CLEvent.html#getProfilingInfo(com.jogamp.opencl.CLEvent.ProfilingCommand)](http://jogamp.org/deployment/jogamp-next/javadoc/jocl/javadoc/com/jogamp/opencl/CLEvent.html#getProfilingInfo(com.jogamp.opencl.CLEvent.ProfilingCommand)) is what you are looking for. – chippies Apr 26 '13 at 13:37
  • Found that too today and managed to get my command queue into profiling mode. What I still dont know is how to create a CLEvent object (it has no constructor) and how to use it. There is not even single sample where they show how to do this... – Veles Apr 26 '13 at 17:20

1 Answers1

0

To answer my own question ;-) The procedure goes like this...first create a CLEventList with the desired capacity, since I only want to measure kernel execution I set this to 1.

CLEventList list = new CLEventList(1);

Now when you set your kernel into the command queue you add the list as a argument:

queue.putReadBuffer(...).put1DKernel(..., list).putWriteBuffer(...).finish();

Afterwards you can get the timing by calling:

long start = list.getEvent(0).getProfilingInfo(ProfilingCommand.START);
long end = list.getEvent(0).getProfilingInfo(ProfilingCommand.END);
long duration = end - start // time in nanoseconds

Don't forget to initialize your command queue with Mode.PROFILING_MODE enabled.

Veles
  • 1,512
  • 4
  • 14
  • 28