Ask Your Question
0

CPU GPU Performance Measurement

asked 2013-07-18 14:59:35 -0600

Ishita gravatar image

updated 2013-07-18 15:01:22 -0600

Does a cv::gpu API takes more time inside a for loop as compared to its corresponding C Style API in the for with same number of iterations.

i.e

` // GPU FOR LOOP

cv::gpu::GpuMat a , b; // assume they contain some data

for(int i = 0; i < 10180 ; i++)

cv::gpu::add(a ,b,a);

// CPU FOR LOOP

CvMat a1 , b1; //assume they contain some data

for(int i = 0; i < 10180 ; i++)

cvAdd(a1 ,b1,a1);

`

Timings:

GPU FOR LOOP : 0.87SEC

CPU FOR LOOP : 0.02SEC

why is it so ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-07-18 16:13:02 -0600

Because you are measuring it wrong :)

A GPU needs initialization each time a process wants to access it, before it can start calculating. Adding is one of the most basic operations, which can go extremely fast, on CPU and GPU. This means that the initialization time of the GPU is way larger than the actual processing time.

In order to see any difference, use heavy calculation algorithms, like for exampling matching features between a database of 1000 images and you will see imense increasing of processing speed.

Another approach is to apply the gpu loop two times after eachother and measure that, the initialization part should be left out at the second run.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-07-18 14:59:35 -0600

Seen: 893 times

Last updated: Jul 18 '13