- C++ 70.7%
- C 29.1%
Nothing is done with the detected collisions so far, but the math is done so throughput increases so I guess that makes it a perf commit. Recording the collision is always a huge performance loss for some reason |
||
|---|---|---|
| lib/imgui | ||
| resources | ||
| scripts | ||
| src | ||
| test | ||
| .gitignore | ||
| CMakeLists.txt | ||
| LICENSE | ||
| README.md | ||
| whitepaper.md | ||
| zorya.supp | ||
Zorya - C++26 Newtonian gravity engine with hotswappable backends
Zorya is a high performance modular N body newtonian gravity engine built in C++26 as my introduction to HPC and SIMD on CPU. Notable features are:
- Hot-swappable compute backends through zero-cost abstraction
- AVX2
- AVX-512
- ImGui control and performance overlay
For a deeper dive on the architecture behind Zorya check out the whitepaper
Build and run
Dependencies
- CMake 3.31+
- C++26
- glfw
- glew
- Catch2 (for tests only)
Build instructions
Start by cloning the repo
git clone https://dawn.wine/jojers/Zorya.git
Set up cmake and compile
cd Zorya
cmake -B build && cmake --build build -j $(nproc)
Run the application with ./build/zorya [args]. If compiled with tests, run them with ./build/zorya_tests
Runtime arguments
Zorya supports several arguments to control the way the engine generates the system. It makes the distinction between a major body and a minor body. They can be interpreted as either planets and asteroids or solar systems and lone stars. It depends on what scale you want to imagine.
| Toggle | Type | Default | Effects |
|---|---|---|---|
| -c, --count | Number | 10 | Number of major bodies |
| -r, --ratio | Number | 5 | Number of minor bodies per major body |
| -O, --orbit | Range | 50:500 | Width of the acceptable spawning area |
| -Mm, --major-mass | Range | 0.1:50 | Range of masses that a major body can be |
| -mm, --minor-mass | Range | 0.01:0.1 | Range of masses that a minor body can be |
| -b , --backend | Enum | scalar | Chooses the default backend at launch. Can be scalar, avx2 or avx512 |
A range must be formatted as from:to. Each side of the range is optional and omitting it will infer the default value. Please note that only positive values are accepted for both numbers and ranges.
For reference, the central star object has a mass of 1000.
Compile options
Zorya also has a some options passed at the CMake initialisation step like so cmake -B build [args]
| Option | Type | Default | Effects |
|---|---|---|---|
| ZORYA_TESTS | ON,OFF | ON | Toggle the build of the test executable |
| ZORYA_ENABLE_SIMD | ON,OFF | ON | Toggle SIMD capabilities (avx2, avx-512) |
License
This project is licensed under the GNU General Public License v3.0