Smoke Sim Optimizations
- 3 Devlogs
- 8 Total hours
Optimizing everything there is to optimize in Smoke Sim
Optimizing everything there is to optimize in Smoke Sim
So, the first idea was to implement shared memory into the smooth shader, and I did so. That brought down the average run time of the pressure solve shader from 15.4 ms to 13.87ms. Only 1.5 ms improvement.. why? Well, there was a halo of cells that had to be still fetched from global memory. So I thought to load those too to shared memory, but that introduced a ton of branching, which brought the average runtime to 29.7 ms… immediatelly reverted the change. At this point, unhappy with only 1.5 ms of change I didn’t stop here: fixing barrier bits brought down 13.87ms to 13.74ms, and changing the pressure and residual images from r32f to r16f (as that much precision is anyways not needed) brought it further down to 13.62ms. The biggest improvement was batching the gauss seidel calls: that allowed the GPU to better use the cached values and avoid CPU overhead. This brought the execution down to 8.93ms! This initial optimization sped up the pressure solve shader of a whooping 42%! And there is still the compute residual, prolong pressure, restrict residual and restrict solid shaders which too affect the pressure solve runtime!
TLDR:
took a long enough break from coding to forget a few things of my project, but that was helpful to rewrite the benchmarking logic: it was a complete mess. It now logs data correctly and makes a proper csv file! Now, I can cleanup the benchmark setup code and then I can finally start optimizing my shaders and seeing the effects of what I’m doing! (Gotta make benchmark enviroment end at a set amount of frames + skip first initial frames)
Started making a benchmark enviroment that saves the GPU times on a .csv to allow me to calculate how changes on the shaders impact performance. It is pretty messy for now, and that will be improved next, but at least I have some code to work on now.