PDA

View Full Version : how to calculate execution time of program on GPU and CPU?



jai
10-07-2012, 12:28 AM
what to write and where to write, to calculate execution time of the program in openCL
thanks

chippies
10-07-2012, 07:38 AM
Two options: you can measure the date and time at the start and end of your algorithm using an OS and language dependent function, or you can use cl_event objects to measure the time taken for each OpenCL function call. If you want to do the latter, have a look at section 5.9 "Profiling Operations on Memory Objects and Kernels" in the OpenCL specifications. Remember that the command queues you use must have profiling enabled if using this approach.

jai
10-07-2012, 08:00 AM
ok thanks
but i am new to openCL ,pls give information via which functions or any example regarding this can help much.

chippies
10-08-2012, 08:16 AM
Since I have not idea what operating system or programming language you are using, I cannot tell you what functions to use to measure wall time.

For the OpenCL functions, I'll stick to C and hope that helps you. First, you need to enable profiling on which ever command queue you are going to use. You can do this when creating the command queue by including the command queue property CL_QUEUE_PROFILING_ENABLE in your call to clCreateCommandQueue.

After enqueueing an operation that generates an event, which I'll call EV, you can use clGetEventProfilingInfo to obtain the following times: time when the command was enqueued, when it was submitted to the device, when it started executing on the device and finally, when it finished executing.

Note that this function will return the constant CL_SUCCESS if it could retrieve the requested counter, or CL_PROFILING_INFO_NOT_AVAILABLE if the counter isn't available yet. This would happen if, for example, you requested the finishing time but the operation is still executing.

jai
10-08-2012, 08:30 AM
i am using opencl c and os windows 7

chippies
10-10-2012, 02:27 AM
If you are using Visual Studio (Visual C++) then you can use the functions QueryPerformanceCounter and QueryPerformanceFrequency to get accurate measurements. If you are using another compiler, then you should look at the header file time.h (http://www.cplusplus.com/reference/clibrary/ctime/). There are two functions there that can help you: clock and time. time() is only accurate to seconds, while clock() is accurate to several milliseconds.

jai
10-10-2012, 06:09 AM
ok thanks but if i have to compare between CPU and GPU time.what time should i consider means time from "sending the command form CPU to GPU -to- read the result from CPU in its memory.or the execution time of running time at cores on GPU and CPU.

notzed
10-10-2012, 07:12 PM
ok thanks but if i have to compare between CPU and GPU time.what time should i consider means time from "sending the command form CPU to GPU -to- read the result from CPU in its memory.or the execution time of running time at cores on GPU and CPU.

Err, choose whichever you want. It's up to you!