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.

Know how to write efficient shaders (Instruction Latencies)

Postby devsh » Tue Jan 17, 2017 10:23 am

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

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!
User avatar
Competition winner
Posts: 1857
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK

Re: Know how to write efficient shaders (Instruction Latenci

Postby robmar » Fri Jan 20, 2017 12:09 am

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

Any data on which ops to avoid with AMD?
Posts: 1028
Joined: Sun Aug 14, 2011 11:30 pm

Re: Know how to write efficient shaders (Instruction Latenci

Postby Vectrotek » Fri Jan 20, 2017 5:09 pm

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..
User avatar
Competition winner
Posts: 1076
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest