GPU-GEMS-NBody-Simulation icon indicating copy to clipboard operation
GPU-GEMS-NBody-Simulation copied to clipboard

Incorrect force calculation

Open stndbye opened this issue 1 year ago • 0 comments
trafficstars

Thanks for getting this code on unity, was just what i needed to add to Sebastian Lague's SPH code to get a nice gas cloud :D Hope to tweak some galaxies out of it one day.

I had a problem initially, the force was reduced along the x axis - used a cube grid particle arrangement, and the error was very apparent - one side of the cube gained a much smaller acceleration then all the other ones.

Had to change the code so that number of threads became 256 along with p - and had to do 8x loop unroll vs 4x in the gravitation function. Now the grid collapses perfectly symmetrically.

The 64 / 4 arrangement doesn't work anyway, as then the GroupMemoryBarrierWithGroupSync call in computeBodyForce becomes conditional. No clue how it could work on CUDA, think it has a similar restriction. It is there to keep the GPU utilized with a small number of bodies anyway (numbodies / p less then multiprocessor count), so not a huge loss.

stndbye avatar Dec 12 '23 23:12 stndbye