Ask Your Question
0

CPU GPU Performance Measurement

asked Jul 18 '13

Ishita gravatar image

updated Jul 18 '13

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 ?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
3

answered Jul 18 '13

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.

Preview: (hide)

Question Tools

Stats

Asked: Jul 18 '13

Seen: 1,147 times

Last updated: Jul 18 '13