I have written a function to add 2 images in cuda-c and now I want to measure the time both cuda-c and just use opencv c++ ( library with cuda) is it right to use :
cudaEvent_t start, stop;
to measure both to find out which is faster?
it’s not possible to declare the correctness of using cuda event based timing without actual code to study. cuda event based timing may not measure host activity correctly. cuda event based timing may not measure multistream or multithreaded activity correctly.
There are lots and lots of questions on various forums that discuss CUDA timing methods. If you do a bit of searching, you will find them.
For a general starting point, for single threaded and single-GPU activity, I would recommend to start with host-based timing. Place a
cudaDeviceSynchronize() before you start your timing region, and place another before you close the region. That should give reasonably good and comparable results with few hazards. The best timing option for CUDA activity is usually careful use of a profiler.