View Full Version : Relative Cost of Function Calls
05-06-2010, 04:32 AM
Where do you go to get information about the cost of library function calls (sqrt, sin, etc.) for your GPU? I have a GTX 280, but I am finding it difficult to find any of this information.
05-06-2010, 12:17 PM
One way you can do it is write a very simple shader, that does not uses any of these functions. Draw a single point. Measure the time of the frame that uses this shader. Repeat the same step but this time the sahder calls one of these functions only once.
The difference in time may give an approximate measure of GPU time taken to perform this instruction.
05-06-2010, 01:11 PM
"Draw a single point." lol and measure with granularity of billions of cycles?
Enable additive-blending, and draw a mesh of 60000 fullscreen triangles. With the two forementioned shaders; Tune that 60000 number so that the framerate is not above 60fps.
05-06-2010, 02:26 PM
I thought OpenGL has GPU timing facility now...??? That's why I said ONE point :)
05-06-2010, 03:14 PM
That's still with a mighty granularity, you know.
05-17-2010, 07:46 PM
Yes, there's the ARB_timer_query extension (http://www.opengl.org/registry/specs/ARB/timer_query.txt) to time the execution of various GL commands on the GPU, and that's definitely what you should be using for timing data in this case (definitely do NOT use CPU-side timers! That will generally just tell you how long it took for the CPU to write the relevant date to the GPU command buffer, which is likely to be entirely unrelated to your GLSL performance).
But yeah, you're still better off drawing/timing lots of pixels rather than just one. In addition to avoiding problems with timer resolution and smoothing out the data, it's probably a more accurate measurement overall given the ridiculously parallel nature of the GPU.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.