how to calculate execution time of program on GPU and CPU?

what to write and where to write, to calculate execution time of the program in openCL
thanks

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.

ok thanks
but i am new to openCL ,pls give information via which functions or any example regarding this can help much.

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.

i am using opencl c and os windows 7

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.

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!