Hey HN, I wrote a compute shader emulator that started as a 50-line script to help me understand reduction shaders. What makes this implementation interesting is its technical approach; I've leveraged Nim's macros and closure iterators to simulate lockstep execution of logical threads.
The emulator runs GPU compute shaders on CPU, simulating workgroups and subgroups with proper synchronization. It supports GLSL subgroup operations and provides nice debugging messages. The emulator works with Nim code that follows compute shader patterns<p>I've documented some technical aspects here: <a href="https://x.com/planetis_m/status/1873857578931011614" rel="nofollow">https://x.com/planetis_m/status/1873857578931011614</a>
Demo/Repo: <a href="https://github.com/planetis-m/compute-sim">https://github.com/planetis-m/compute-sim</a>