This is a real-time, GPGPU-accelerated train network simulator developed as part of a master's-level university group project. It is built in C++17 and CUDA, using CMake as the build system.
Before you can build this project, you will need the following software installed:
-
A C++17 Compiler (e.g., Visual Studio 2019/2022, GCC 9+, Clang 10+).
-
CMake 3.18 or newer.
-
The NVIDIA CUDA Toolkit (e.g., CUDA 11.x or 12.x).
The project is configured using CMake.
University machines often use a module system to manage software.
Load the necessary modules. You must load the C++ compiler (if not default) and the CUDA toolkit. The exact names may differ, but the command will look like this:
module load gcc/11.4.0
module load cuda/11.8
Run the standard CMake build:
cd /path/to/TNSim
mkdir build
cd build
(This finds CUDA and generates the Makefiles)
cmake ..
(optional: to specify cmake generator and avoid nmake, use "cmake .. -G "Visual Studio 17 2022" -A x64" or similar)
cmake --build .
./TNSim
To run a clean local pipeline that rebuilds from scratch and runs a performance check only when you execute it:
./scripts/semi_auto_pipeline.sh
This script does:
- Delete
build/ - Recreate
build/ - Configure with CMake
- Run an initial build of target
TNSim - Run the full build
- Execute
./TNSim, then print:PERF_SUMMARY(tick timing from the simulator)PERF_RSS_KB(peak RAM from/usr/bin/time)- elapsed time and CPU%
You can pass configure arguments through the script, for example:
./scripts/semi_auto_pipeline.sh -DCMAKE_CUDA_ARCHITECTURES=86
You can also pass runtime args to ./TNSim after --, for example:
./scripts/semi_auto_pipeline.sh -DCMAKE_CUDA_ARCHITECTURES=86 -- --tick-ms 10 --max-ticks 800
./TNSim now prints a PERF_SUMMARY line at shutdown with average/p95/min/max tick timings in milliseconds.
Optional runtime flags:
./TNSim --tick-ms 14 --max-ticks 500
--tick-ms: target tick duration in ms--max-ticks: safety cap for benchmark/test run length
cd build
cmake --build . --config Debug
.\Debug\TNSim.exe 2>&1 | Tee-Object -FilePath crash.log
Make sure all prerequisites (Visual Studio, CUDA Toolkit, CMake) are installed and added to your system's PATH.
Follow the same build steps as above. On Windows, CMake will automatically generate a Visual Studio Solution (.sln) inside the build/ folder.
The project defaults to compiling for NVIDIA 40-series GPUs (Architecture "89"). If you are building on a machine with a different card (e.g., a 20-series "75" or 30-series "86"), you should override this default when you configure the project.
This ensures you are AOT-compiling for your specific hardware.
cd build
cmake .. -DCMAKE_CUDA_ARCHITECTURES="75"
cmake .. -DCMAKE_CUDA_ARCHITECTURES="86"