CUDA implementation of relativistic Monte Carlo code. Based on grmonty and grmonty: A Monte Carlo Code for Relativistic Radiative Transport .
Build dependencies:
- C++20 compiler (gcc/clang)
- CUDA
- Bazel
- Python 3 (optional, for spectrum plotting)
To build CPU-only version, run:
bazel build -c opt //cuda_grmonty:mainthen run it with:
./bazel-bin/cuda_grmonty/main --harm_dump_path ./dump019 --spectrum_path ./spectrum -photon_n 5000000The HARM dump file can be downloaded from grmonty repository.
To build the program with CUDA acceleration, run:
bazel build -c opt //cuda_grmonty:main --config=cudaand run it the same as above.
To plot the spectrum, run plot_spectrum.py, preferably using uv as follows:
uv run ./plot_spectrum.py --spectrum_path ./spectrum --plot_path ./spectrum.pngIf you want to use Python directly instead, install dependencies specified in plot_spectrum.py#4. And run:
python3 ./plot_spectrum.py --spectrum_path ./spectrum --plot_path ./spectrum.pngTo enable recording photons positions for visualizations install OpenCV and add --trajectories_recording_path parameter.
./bazel-bin/cuda_grmonty/main --harm_dump_path ./dump019 --spectrum_path ./spectrum -photon_n 5000000 --trajectories_recording_path ./trajectories.mp4Input parameters:
- HARM dump: dump019
- Estimate of photon number: 1000000
- Mass unit: 4.e19
System:
- Arch Linux (6.18.6-arch1-1)
- CUDA 13.1
- clang 21.1.6
Hardware:
- CPU: i9-14900k
- RAM: 2x32 GB (4800 Mhz)
- GPU: RTX 3060 12 GB
| Version | Other parameters / notes | Photon rate [1/s] | Total duration [s] |
|---|---|---|---|
| grmonty | OMP_NUM_THREADS=1 |
59743 | 272.51 |
| grmonty | OMP_NUM_THREADS=32 |
289866 | 55.36 |
| v0.0.1 | CPU only | 51429 | 317.02 |
| v0.1.0 | 65119 | 241.84 | |
| v0.1.1 | 137939 | 114.95 | |
| v0.1.2 | 246538 | 64.91 | |
| v0.1.3 | 307186 | 52.41 | |
| v0.1.4 | 352152 | 45.88 |
The tests can be ran with:
bazel test //cuda_grmonty/tests/...
