AlgorithmsAdvanced~120 min

N-Body Gravitational Simulation

Simulate gravitational N-body dynamics on the GPU. Build the naive all-pairs force kernel, tile it with shared memory, implement leapfrog time integration, and track energy conservation.

N-bodyshared-memorytilingphysicsleapfrogAoS-SoA

// PROJECT PHASES

  1. 1

    Data layout and force kernel

    AoS vs SoA layout. Write naive all-pairs force kernel.

  2. 2

    Shared memory tiling

    Load TILE bodies at a time into shared memory.

  3. 3

    Leapfrog integrator

    Symplectic velocity-Verlet time integration.

  4. 4

    Energy conservation check

    Verify KE+PE is conserved across timesteps.

// SANDBOX

GPU execution
main.cu
loading editor…

// EXPECTED OUTPUT

Step   0: E = -1234.56 (baseline)
Step 100: E = -1234.59 (drift: 0.02%)

// YOUR PROGRESS

Log in to save progress

// DETAILS

Category
Algorithms
Difficulty
Advanced
Est. time
~120 min
Prerequisites
1

// LEARN THE THEORY

Algorithms concepts