Titanium is a high-performance, heterogeneous trading engine framework designed for ultra-low latency execution. It leverages C++20 AVX2 SIMD for the matching logic and NVIDIA CUDA for asynchronous, high-intensity risk management.
The engine is built on four core high-performance pillars:
- L1 Cache Locality: Uses a Structure-of-Arrays (SoA) memory layout allowing the CPU to scan 8 price levels per clock cycle.
- Lock-Free Pipeline: A single-producer, single-consumer (SPSC) ring buffer manages communication between threads without kernel-level mutex stalls.
- Heterogeneous Decoupling: The engine spawns a background thread to manage GPU logistics, allowing the main Matching Engine to run at 100% throughput.
- Zero-Copy GPU Transfer: Uses
cudaHostRegisterto map system RAM directly to the GPU via DMA, eliminating the overhead of standardmemcpy.
- CPU: x86_64 with AVX2 support.
- GPU: NVIDIA GPU (Ampere architecture or newer recommended, e.g., RTX 30-series).
- OS: Windows 10/11 (with MSVC compiler).
- Toolchain: Visual Studio 2022 (with "Desktop development with C++").
- CUDA: NVIDIA CUDA Toolkit v12.x or 13.x.
- Build System: CMake 3.20+ and Ninja.
To build the engine with full optimizations (Release mode), follow these steps:
- Open PowerShell.
- Initialize the Environment:
cmd.exe /c 'call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 && powershell'
- Configure & Build:
cmake -B build -DCMAKE_BUILD_TYPE=Release cmake --build build
To run the apples-to-apples comparison between the CPU-only engine and the Asynchronous GPU pipeline:
.\build\titanium_bench_optimized.exeUnder a heavy risk load (50-iteration Monte Carlo simulation):
- Titanium CPU: ~1.0 Million Ops/Sec
- Titanium GPU Async: ~4.5+ Million Ops/Sec
Ensure the engine is functioning correctly by running the automated test suite:
- Logic Test:
.\build\titanium_test.exe(Verifies matching logic correctness).
- GPU Accuracy:
.\build\titanium_test_cuda.exe(Verifies GPU math against CPU). - Stress Test:
.\build\titanium_stress_spsc.exe(Tests 10M-order lock-free integrity).
This project is licensed under the MIT License.