Know how to write efficient shaders (Instruction Latencies)

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Know how to write efficient shaders (Instruction Latencies)

Post by devsh »

Since Nvidia doesnt publish much about how exactly their architecture works...

http://lpgpu.org/wp/wp-content/uploads/ ... es2014.pdf

The only thing missing from that chart is the latency of RSQRT which is 25 cycles on Tesla, you have to extrapolate to Kepler and Maxwell

so a combined latency of normalize() would be (6+2)+2*6 for 3 MULS and two ADDs or at least 2*6+1 2FMADs and one MUL to get the squared length of the vector and then ~25 for the RQSRT and finally 6+2 for the 3 MULS with the rsqrt
coming together to at least 46 cycles for a 3 component normalize

Finally you know not only which is the most expensive op, but also how much more!
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Know how to write efficient shaders (Instruction Latenci

Post by robmar »

interesting... but not everyone uses NVidia, some use Intel Iris or AMD GPUs.

Any data on which ops to avoid with AMD?
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Know how to write efficient shaders (Instruction Latenci

Post by Vectrotek »

So this could lead to a way to set shader parameters without using the names (and its related overhead)?
I think BAW already has this sorted but I'm still digging through the code..
Post Reply