1873744231719956872, 1870942850684420564, 1738800602568638492

This commit is contained in:
ed committed 2026-08-26 12:00:21 -04:00
1 parent ba3674cbd7
commit a6e6d7616c
15 files changed
+620

No files matched your search

@@ -0,0 +1,93 @@
---
title: "@NOTimothyLottes Humor me… have you tried entering in atomicAdd(adr,lane==0?v:0)? How bad is it relative to the rest?"
type: archive
source: twitter
source_url: "https://x.com/AgileJebrim/status/1870948791534203086"
author: "Jebrim"
handle: AgileJebrim
post_id: "1870948791534203086"
date: 2024-12-22
archived: 2026-08-26
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "@NOTimothyLottes Humor me… have you tried entering in atomicAdd(adr,lane==0?v:0)? How bad is it relative to the rest?"
in_reply_to: ""
parent_post_id: "1870942850684420564"
---
## Source
- URL: https://x.com/AgileJebrim/status/1870948791534203086
- Author: Jebrim (@AgileJebrim)
- Posted: 2024-12-22 21:45:27
## Branch
**1/** **@AgileJebrim** ^1870948791534203086
**@NOTimothyLottes**
Humor me… have you tried entering in atomicAdd(adr,lane==0?v:0)? How bad is it relative to the rest?
**2/** **@NOTimothyLottes** ^1870953014481269098
**@AgileJebrim**
You cannot get that behavior because the driver will "fix" it for you. There had been so many bad programmers not predicating atomics that the IHVs had been forced to workaround (too the expense of everyone who had optimized correctly)
**3/** **@AgileJebrim** ^1870953397920129344
**@NOTimothyLottes**
The driver is going to replace my code to what?
**4/** **@AgileJebrim** ^1870954001585607042
**@NOTimothyLottes**
This is why I said humor me. I’m frankly curious to see what performance it’ll get on your test suite. Just try it.
**5/** **@NOTimothyLottes** ^1870958724476461290
**@AgileJebrim**
110% if dividing by the type of the prior worst. So it's a bunch slower than the prior worst case. But I don't have NV's disassembly, so not sure exactly what it did under the hood.
**6/** **@NOTimothyLottes** ^1870961042257236009
**@AgileJebrim**
If we look at AMD disassembly for atomicAdd'ing "gl_LocalInvocationID.x==0?256:0" you will see the AMD driver do a wave-op ADD reduction (highlighted) and I'd suspect the same from NVIDIA. Note the atomic at the end of the shader uses my trick (and sums the runtime).
![](https://pbs.twimg.com/media/Gfb82ROXIAAtJff?format=png&name=orig)
**7/** **@AgileJebrim** ^1870962166796632486
**@NOTimothyLottes**
Even though it knows it’s 0 it’ll still waste time reducing? Lame.
**8/** **@NOTimothyLottes** ^1870963440485101720
**@AgileJebrim**
There have traditionally been a lot of driver workarounds in this area (like using ballot and bitcount if the adder is 1, etc). And I remember as far back as being at NV (so more than a decade ago) and having this same problem of NV drivers breaking perf of pre-optimized shaders.
**9/** **@NOTimothyLottes** ^1870963879255101507
**@AgileJebrim**
I do find it interesting that it took me a decade to figure out a proper good workaround. So yeah, I'm the "idiot" too. But I'm one workaround less of an idiot this week, which is progress.
**10/** **@AgileJebrim** ^1870964580085555600
**@NOTimothyLottes**
It’d be nice if there were a way to configure the optimizer settings like you can do with many compilers.
## Related
- Spine: [[archive/threads/NOTimothyLottes/2024-12-22-fixing-atomicadd-benchmarking-amd-nv]]
@@ -0,0 +1,61 @@
---
title: "@NOTimothyLottes I wonder is there explainable perf and algorithmic different between atomicAdd on uint cell vs incrementing a buffer counter (for append/consume buffer)"
type: archive
source: twitter
source_url: "https://x.com/Meetem4/status/1870944398839620087"
author: "Meetem"
handle: Meetem4
post_id: "1870944398839620087"
date: 2024-12-22
archived: 2026-08-26
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "@NOTimothyLottes I wonder is there explainable perf and algorithmic different between atomicAdd on uint cell vs incrementing a buffer counter (for append/consume buffer)"
in_reply_to: ""
parent_post_id: "1870942850684420564"
---
## Source
- URL: https://x.com/Meetem4/status/1870944398839620087
- Author: Meetem (@Meetem4)
- Posted: 2024-12-22 21:27:59
## Branch
**1/** **@Meetem4** ^1870944398839620087
**@NOTimothyLottes**
I wonder is there explainable perf and algorithmic different between atomicAdd on uint cell vs incrementing a buffer counter (for append/consume buffer)
**2/** **@NOTimothyLottes** ^1870946922233749918
**@Meetem4**
So I don't use the "fixed function" atomic counters (which are going to be emulated likely with global atomics), nor do I use the "fixed function" append or consume of graphics. However ...
**3/** **@NOTimothyLottes** ^1870947271568973944
**@Meetem4**
Some platforms probably optimized append and consume by parallelizing the global atomics to multiple L2 partitions (had parallel counters). Which of course one can do in software too.
**4/** **@NOTimothyLottes** ^1870947546987647064
**@Meetem4**
And at least AMD traditionally had GDS which could be used, but that is the great serializer, so not sure if that is wise for huge GPU appending (multiple append queues is probably better, in theory)
**5/** **@Meetem4** ^1870947985351483769
**@NOTimothyLottes**
Well, yeah, I was expecting some form of optimization here, because the counter is only valid for the current thread, according to D3D specification, which raises the suspicion that some higher level optimization can be applied
## Related
- Spine: [[archive/threads/NOTimothyLottes/2024-12-22-fixing-atomicadd-benchmarking-amd-nv]]
@@ -0,0 +1,94 @@
---
title: "@NOTimothyLottes I'm not going to pretend I understand a lick of this, which is why I have a humble request, well 2 actually:"
type: archive
source: twitter
source_url: "https://x.com/RouaniJihad/status/1870960478572499239"
author: "🕹️G🅰MESTUFFS🎮"
handle: RouaniJihad
post_id: "1870960478572499239"
date: 2024-12-22
archived: 2026-08-26
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "@NOTimothyLottes I'm not going to pretend I understand a lick of this, which is why I have a humble request, well 2 actually:"
in_reply_to: ""
parent_post_id: "1870942850684420564"
---
## Source
- URL: https://x.com/RouaniJihad/status/1870960478572499239
- Author: 🕹️G🅰MESTUFFS🎮 (@RouaniJihad)
- Posted: 2024-12-22 22:31:53
## Branch
**1/** **@RouaniJihad** ^1870960478572499239
**@NOTimothyLottes**
I'm not going to pretend I understand a lick of this, which is why I have a humble request, well 2 actually:
1- Is there a way for you to finish working on STP.
2- Can you create an open source denoiser for say, a real-time Path Tracer 👉👈
Reading this is enough as well... =]
**2/** **@NOTimothyLottes** ^1871178158155714646
**@RouaniJihad**
My recommendation: ask Unity to open source STP under a MIT license so any external person could finish it. And then both Unity and anyone else could benefit from it's long term evolution.
**3/** **@NOTimothyLottes** ^1871178888543687059
**@RouaniJihad**
One fundamental problem with bespoke high-tech solutions like these are that in many cases they become abandonware when all the original people involved in the projects no longer work at the company (which is the case here)
**4/** **@NOTimothyLottes** ^1871180562016387273
**@RouaniJihad**
There are very few people who could work on it, and after Unity shed it's high tech rendering staff during it's downsizing efforts to stay live during it's stock crash, who knows when they will have an environment that fosters that kind of R&D again
**5/** **@NOTimothyLottes** ^1871182399876559216
**@RouaniJihad**
As for STP it wasn't ever designed to denoise per say, it does get a little denoising as a side effect of temporal filtering though, but things like stochastic GI on disocclusions will show a mismatch in noise with other parts of the image that get good temporal feedback
**6/** **@NOTimothyLottes** ^1871183683459145777
**@RouaniJihad**
The cases where people have merged scaling TAAs and denoisers, they do so by augmenting the TAA with extra side channel information from the G-buffer {normals, albedo, etc} and then keep a lot more recurrent data in feedback across frames, this massively increases costs
**7/** **@NOTimothyLottes** ^1871184146795491786
**@RouaniJihad**
Traditionally those who have managed to improve temporal feedback in cases of {rendered mirror reflections, SSR, or even RT} have needed to generate a section reprojection vector of where the mirrored reflection was in the prior frame, this is something Unity doesn't have today
**8/** **@NOTimothyLottes** ^1871184992803672572
**@RouaniJihad**
There is another interesting option that a scaling-TAA typically tracks the amount of screen convergence, and one could pass that information back into an input denoiser before the TAA that denoises less where things have converged and a lot where things would be disoccluded
**9/** **@NOTimothyLottes** ^1871190322346377591
**@RouaniJihad**
Can watch videos like this https://www.youtube.com/watch?v=K3ZHzJ_bhaI ... and you start to see that no one has actually come to a great solution for screen-space denoise+scaling+TAA, even given the ML solutions ...
**10/** **@NOTimothyLottes** ^1871191321974817274
**@RouaniJihad**
Suggests maybe it would ultimately be better to push the RT usage back into the environment probe space and do the spatial temporal denoise there, and then use those probes to light the scene instead.
## Related
- Spine: [[archive/threads/NOTimothyLottes/2024-12-22-fixing-atomicadd-benchmarking-amd-nv]]
@@ -0,0 +1,58 @@
---
title: "__/ Fixing AtomicAdd - Benchmarking AMD+NV \\__"
type: archive
source: twitter
source_url: "https://x.com/NOTimothyLottes/status/1870942850684420564"
author: "NOTimothyLottes"
handle: NOTimothyLottes
post_id: "1870942850684420564"
date: 2024-12-22
archived: 2026-08-26
draft: false
tags:
- archive
- twitter
- NOTimothyLottes
description: "__/ Fixing AtomicAdd - Benchmarking AMD+NV \\__"
in_reply_to: ""
---
## Source
- URL: https://x.com/NOTimothyLottes/status/1870942850684420564
- Author: NOTimothyLottes (@NOTimothyLottes)
- Posted: 2024-12-22 21:21:50
## Thread
**1/** **@NOTimothyLottes** ^1870942850684420564
__/ Fixing AtomicAdd - Benchmarking AMD+NV \__
RTX 3060
100% - if(lane==0) atomicAdd(adr,v*lanes) ... smart
84% - atomicAdd(adr,v) ... stupid
82% - atomicAdd(lane==0?adr:-4,v*lanes) ... mine
NV's compiler has same "bug" as AMD :)
My workaround is faster than their compiler too!
Branches: [[archive/threads/NOTimothyLottes/2024-12-22-fixing-atomicadd-benchmarking-amd-nv/2024-12-22-Meetem4-i-wonder-is-there-explainable-perf-and]], [[archive/threads/NOTimothyLottes/2024-12-22-fixing-atomicadd-benchmarking-amd-nv/2024-12-22-AgileJebrim-humor-me-have-you-tried-entering-in-atomicadd-adr]], [[archive/threads/NOTimothyLottes/2024-12-22-fixing-atomicadd-benchmarking-amd-nv/2024-12-22-RouaniJihad-im-not-going-to-pretend-i-understand-a-lick-of]]
**2/** **@NOTimothyLottes** ^1870943585388110229
Review/
So NV and AMD share the same "optimization" that works as an "anti-optimization" if you predicate the atomic to one lane. Neither checks if the dev actually knows what they are doing and had already predicated to just one lane ...
**3/** **@NOTimothyLottes** ^1870944106463031312
The best workaround however is to rely on BUFFER bounds checking: instead of predicating to one lane, conditionally set the lanes to disable to out-of-bounds addresses instead!
Because then the compiler silly behavior is disabled. And that actually is faster too!
**4/** **@NOTimothyLottes** ^1870944638183538927
My easy access AMD machine is an APU right now, and the numbers were not rock stable like the NV dGPU. So I didn't get exact % (as my test wasn't written with long enough runtimes). But the AMD behavior looks similar.
**5/** **@NOTimothyLottes** ^1870945104586035589
If anyone is wondering how I tested: I wrapped the code with clockRealtimeEXT() and then summed the total runtimes across all waves. I find that is often better than trying to invoke some external profiler. I also have live shader editing so I can watch the behavior live too :)
+1
View File
@@ -54,6 +54,7 @@ tags:
- [[archive/threads/NOTimothyLottes/2024-12-20-raytastic-friday]]
- [[archive/threads/NOTimothyLottes/2024-12-21-hopefully-with-this-last-atomic-workaround-im]]
- [[archive/threads/NOTimothyLottes/2024-12-21-how-to-unbreak-atomicadd-on-amd-pc]]
- [[archive/threads/NOTimothyLottes/2024-12-22-fixing-atomicadd-benchmarking-amd-nv]]
- [[archive/threads/NOTimothyLottes/2024-12-24-been-playing-with-the-spatial-energy]]
- [[archive/threads/NOTimothyLottes/2025-01-04-for-the-love-of-octahedrons-https-fileadmin-cs]]
- [[archive/threads/NOTimothyLottes/2025-01-06-one-of-the-downsides-of-v-cndmask-b32-on-amd-is]]