Back to browse
GitHub Repository

A real-time CUDA accelerated Barnes-Hut tree code for the n-body problem using C++ and OpenGL.

5 starsCuda

Real-time n-body tree code in CUDA

by lechebs·Jul 10, 2026·4 points·0 comments

AI Analysis

●●SolidWizardryNiche Gem

4 million particles at 400ms per step with honest bottleneck analysis in the README.

Strengths
  • Real-time GPU simulation with octree visualization and interactive camera controls.
  • Author openly documents VRAM bottlenecks and missing heuristics for BFS queue sizing.
  • Includes energy conservation plots and acceleration error metrics for validation.
Weaknesses
  • Ubuntu-only with no Windows or macOS build instructions for broader accessibility.
  • Barnes-Hut on GPU is well-trodden territory without novel algorithmic contributions.
Target Audience

Graphics programmers and computational physics researchers

Similar To

Gadget-4 · PKDGRAV · CUDA n-body samples

Post Description

Sharing an old project of mine, on my RTX 500 Ada laptop GPU, it can simulate up to 4 million particles at ~400 ms per step using the Barnes-Hut algorithm, saturating the 4GB of VRAM available.

The octree construction is fast, as well as the traversal. The major bottlenecks are the VRAM usage (1 million bodies require ~1GB), which could be probably halved by reusing intermediate buffers, and the particle to leaf evaluation, which would benefit from more fp32 FLOPS. Moreover, I still don't have a good heuristic to predetermine the size of the BFS queue, perhaps some sort of memory paging could solve the issue.

Similar Projects

Open Source●●Solid

A Black Hole Simulator in CUDA C++

The repo actually implements an RK4 geodesic integrator in CUDA kernels to trace millions of rays and produce frame sequences — plus handy scripts to generate a Perlin accretion disk and preprocess NASA EXR star maps. It’s the sort of technical playground that shows real GPU know‑how and produces striking renders, but the experience is experimental: you must manually fetch assets, run preprocessing scripts, and there are no builds, benchmarks or accuracy notes to help anyone reproduce or compare results.

WizardryEye CandyNiche Gem
anwoy
204mo ago
Developer Tools●●Solid

ARB – A Differentiable Rigid Body Simulation Library Using C++23

C++ rigid body simulation with end-to-end automatic differentiation for ML.

WizardryNiche Gem
wbyates777
211mo ago