μMCX
The shortest GPU-accelerated 3D Monte Carlo photon transport simulator — in <1000 lines of portable C++11
🔬 What is uMCX?
uMCX (μMCX) is a miniaturized, maximally portable Monte Carlo photon transport simulator. It simulates light propagation in 3D voxelated turbid media such as biological tissues, with GPU acceleration — all in under 1000 lines of clean, rule-formatted C++11 code.
🏆 MCX Project
Part of the MCX project, supported by US NIH grant R01-GM114365. uMCX is backward-compatible with MCX JSON input files — existing MCX simulations run with minimal modification.
💡 Photon Transport Physics
uMCX implements the gold-standard stochastic Monte Carlo method for simulating photon migration in turbid media. Each photon is tracked from launch to absorption or escape.
🎯 Scattering
- Henyey-Greenstein phase function
- Per-voxel anisotropy factor g
- xorshift128+ RNG (one per thread)
🔀 Boundaries
- Refractive index mismatch
- Fresnel reflection / refraction
- Configurable reflective boundaries
📈 Output
- Fluence rate / fluence / energy deposition
- Time-gated 4D output (Nx×Ny×Nz×Nt)
- Detected photon partial path lengths
💡 Sources
- Pencil, isotropic, cone beam
- Disk (top-hat), planar widefield
- Widefield launch from outside domain
⚡ Performance
uMCX achieves competitive performance on all hardware via OpenMP 4.5 GPU offloading. Benchmarked on cube60 with 100M photons:
| Hardware | Build | Speed |
|---|---|---|
| NVIDIA RTX 5090 | make nvc | 175075 photon/ms (vs mcxcl: 204499 p/ms, mcx: 201613 p/ms) |
| NVIDIA RTX 4090 | make nvc | 133894 photon/ms (vs mcxcl: 166945 p/ms, mcx: 168350 p/ms) |
| NVIDIA RTX 3090 | make nvc | 63331 photon/ms (vs mcxcl: 123001 p/ms, mcx: 114679 p/ms) |
| AMD Radeon VII (gfx906) | make amdclang | ~1780 photon/ms |
| AMD Threadripper 3990X (128 threads) | make multi | ~3034 photon/ms |
📝 Forward-compatible NVIDIA builds
GCC/Clang NVIDIA builds embed PTX (virtual ISA). The CUDA driver JIT-compiles PTX at runtime, so a binary compiled with SM=sm_50 runs correctly on any newer NVIDIA GPU generation.
![[Home]](/img/mcx_wiki_banner.png)