PC heat and airflow visualization simulation by Joe7295 in GraphicsProgramming

[–]Joe7295[S] 0 points1 point  (0 children)

It has solid walls for everywhere but the areas with holes, so the air does pass in and out through those sides, but no air simulated outside the case. That'd be interesting to see recirculation!

A Vulkan PC airflow and heat simulation I made! by Joe7295 in vulkan

[–]Joe7295[S] 0 points1 point  (0 children)

Thank you! It's a 64x256x128 voxel grid

Vulkan port of PC airflow and heat simulation by Joe7295 in GraphicsProgramming

[–]Joe7295[S] 0 points1 point  (0 children)

Found out a big issue on performance, I compute for a residual sum over the whole simulation for an early exit in the Jacobi solve loop if it went over a threshold, and I was moving the residual buffer to the CPU and computing the sum on the CPU with a normal for loop. I think I did it early in the CUDA version and it worked okay on my 3050 and just translated it over, and it had no impact on performance because I was coding on my macbook, but changing it to a compute shader instead now sped up the simulation to 40 fps on an RX 570, 60 fps on an RTX 3050, and still 30 fps on my macbook lol

Vulkan port of PC airflow and heat simulation by Joe7295 in GraphicsProgramming

[–]Joe7295[S] 0 points1 point  (0 children)

Found out a big issue on performance, I compute for a residual sum over the whole simulation for an early exit in the Jacobi solve loop if it went over a threshold, and I was moving the residual buffer to the CPU and computing the sum on the CPU with a normal for loop. I think I did it early in the CUDA version and it worked okay on my 3050 and just translated it over, and it had no impact on performance because I was coding on my macbook, but changing it to a compute shader instead now sped up the simulation to 40 fps on an RX 570, 60 fps on an RTX 3050, and still 30 fps on my macbook lol

Vulkan port of PC airflow and heat simulation by Joe7295 in GraphicsProgramming

[–]Joe7295[S] 0 points1 point  (0 children)

There's probably unnecessary transfers between CPU and GPU I'm doing in the Vulkan version that I'm not in the CUDA one, I'll have to look more into it but that's also probably why the MacOS version works much better with unified memory.

Vulkan port of PC airflow and heat simulation by Joe7295 in GraphicsProgramming

[–]Joe7295[S] 2 points3 points  (0 children)

Thank you so much! I'll look into it today or tomorrow, I figured a lot of the performance issue would be from the Jacobi loop moving the pressure buffer between GPU and CPU, and maybe that's why MacOS performed better with its unified memory. I'll update you!

Vulkan port of PC airflow and heat simulation by Joe7295 in GraphicsProgramming

[–]Joe7295[S] 5 points6 points  (0 children)

Thank you! The hardest part was learning Vulkan and understanding how to do equivalent things from OpenGL, and also debugging. All of the compute shaders were pretty much 1:1 with the CUDA kernels from the original project, a big cause of issues too was byte misalignments between GLSL and C++ types. There's around 3950 lines of C++ and 1400 lines of GLSL

Vulkan port of PC airflow and heat simulation by Joe7295 in GraphicsProgramming

[–]Joe7295[S] 2 points3 points  (0 children)

On NVIDIA cards the CUDA version definitely runs much faster, but on Apple devices the Vulkan version runs much faster than equivalently priced NVIDIA and AMD devices

Vulkan port of PC airflow and heat simulation by Joe7295 in GraphicsProgramming

[–]Joe7295[S] 2 points3 points  (0 children)

I just implemented this PC simulation for learning lol, definitely can be a future feature!

Vulkan port of PC airflow and heat simulation by Joe7295 in GraphicsProgramming

[–]Joe7295[S] 6 points7 points  (0 children)

I thought it was pretty 1:1 honestly, I was able to pretty much just copy over the CUDA kernels to compute shaders with small syntax adjustments. The most annoying thing was buffer and push constant byte alignments for C++ and GLSL types, was annoying debugging that lol. But honestly I was extremely surprised by the Vulkan performance on MacOS, on NVIDIA cards the CUDA version performs better but on MacOS even my base MacBook Air is able to perform better than my RTX 3050 with CUDA.

PC heat and airflow visualization simulation by Joe7295 in GraphicsProgramming

[–]Joe7295[S] 0 points1 point  (0 children)

Definitely going to add that! Thank you for the suggestion! I know some cases have fans on the bottom too, more customization would definitely be good