Measuring performance of GPU and CPU

Started by
6 comments, last by Krohm 16 years, 10 months ago
I am doing an experiment on measuring hardware performance of GPU and CPU. I doing this by computing result[N] = a[N] + b[N] and record their runtime. However, the runtime is too small to be recorded. Even, I multiplies the total time by 10^100 or more, the resultant time is still zero. I record GPU timing as follows:

start_time = clock()
glBegin(GL_QUADS);
	glTexCoord2f(0.0, 0.0); 
	glVertex2f(0.0, 0.0);
	glTexCoord2f(width, 0.0); 
.................. 
glEnd();
end_time = clock();
Am I correct? How can I solve the problem? Any tools can help me recording the right timing? If I put a for-loop outside, will the result be unfair for GPU computation? [Edited by - rosicky2005 on May 30, 2007 4:17:13 AM]
Advertisement
OpenGL draw calls are asynchronous. So the Graphics card doesn't do anything in the time period you try to record. Put glFinish() before end_time = clock() to get correct results.
http://3d.benjamin-thaut.de
start_time = clock()
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex2f(0.0, 0.0);
glTexCoord2f(width, 0.0);
..................
glEnd();
/*-------->*/glFinish(); // Waits until data has been processed by the gpu
end_time = clock();

do that and you should be set..

also, you should consider using performance timers instead of the clock commands, since clock has a pretty bad resolution
Quote:Original post by LackOfGrace
also, you should consider using performance timers instead of the clock commands, since clock has a pretty bad resolution


Could you please tell me what is performance timers?
I have never heard this tool before.
Look at nehes lesson 21.
Nehe
http://3d.benjamin-thaut.de
Thanks everyone. I can now measure the performance of code accurately.

However, I found that the computation time of GPU is slower then CPU. My Graphic Card model is 6800 GeForce.
There is always some overhead associated with each draw. The best way IMHO to do these kind of measurements is to use sweeps. That is, constantly increase some property of your draw (such as the number of triangles) and measure the time of that draw. Plotting these measurements gives you a much better understanding on how the system (cpu and gpu) behaves than just a single measurement.
Quote:Original post by rosicky2005
However, I found that the computation time of GPU is slower then CPU. My Graphic Card model is 6800 GeForce.

I suggest to have a look at PC's architecture. You have no chance of beating the CPU with a so simple operation, you're basically measuring the IO time as well.
The sustained operations on GPUs is considerably higher but for simple apps, there's really no point in benchmarking hoping to beat CPUs in its land.

When you declare data, CPU does have access to it.
Pulling the same data to GPUs can easily eat up hundreds of cycles (the time taken to update a single uniform at best), let alone beat it.

Furthermore, even if you get the expected measurement, don't expect it to scale to a fully fledged system! Bus/memory transactions will screw up a bit.

Previously "Krohm"

This topic is closed to new replies.

Advertisement