How cmu-safari/ramulator works
Project type and purpose
• Ramulator is a cycle-accurate DRAM simulator written in C++ (C++11).
• It can run in three modes: memory-trace–driven, CPU-trace–driven, and gem5-driven.
• There is an auxiliary Python-based test harness and a standalone trace-generator tool (Simpoint).
File structure
• Top level
• configs/: DRAM standard configuration files (DDR3, DDR4, LPDDR, HBM, etc.)
• src/: Core simulator source (Main.cpp, Config, MemoryFactory, Controllers, DRAM-model classes, Processor, Scheduler, Stats)
• cputraces/, dram.trace: Example input traces
• gem5-patch: gem5 integration patch + Gem5Wrapper.*
• mappings/: Address-interleaving maps
• test_*.py: Python scripts to automate cross-simulator comparisons and SPEC workloads
• plot.py: Post-processing and plotting of statistics
• trace_generator/: Standalone Simpoint-based trace generator (C++ and scripts)
• Patterns
• Factory (MemoryFactory) to instantiate DRAM model classes (DDR3, DDR4, etc.)
• Separation of concerns: Config parsing, request scheduling (Controller/Scheduler), memory model classes, statistics collection, external-simulator wrapper
README for additional insights
• Detailed description of the three usage modes
• gem5 integration via SWIG wrapper (Gem5Wrapper)
• Optional power-trace exports for DRAMPower/VAMPIRE
• References to academic papers & benchmarks (SPEC2006)
a. Main components
1. Input layer
• Configuration Parser (Config)
• Trace Loader
• Memory-trace loader (dram.trace)
• CPU-trace loader (cpu.trace, cputraces/*)
• gem5 interface (Gem5Wrapper)
• Mapping module (address-interleaving maps)
2. Core simulation engine
• MemoryFactory → instantiates concrete DRAM model (DDR3, DDR4, LPDDR, HBM, SALP, TL-DRAM, DSARP, etc.)
• Controller & Scheduler:
• Issues DRAM commands (activate, read, write, refresh)
• Implements scheduling policy (e.g., FR-FCFS, open-row)
• Processor model (for CPU-trace mode): counts non-memory instructions, generates requests
• Refresh logic (Refresh)
• Request queue management (in Cache or Controller classes)
3. Statistics & output
• Statistics collector (Statistics.h)
• Optional command-trace recorder (for power estimation)
• Python post-processing (plot.py)
• Python test harness (test_ddr3.py, test_spec.py, test_ramulator.py)
4. External integrations
• gem5 full-system simulator (via Gem5Wrapper; SWIG)
• DRAMPower / VAMPIRE power models (via recorded cmd trace)
5. Trace generator submodule
• Simpoint pipeline (trace_generator/Simpoint3.2)
• PinPoints instrumentation suite
• gettrace driver
b. Relationships and interactions
• Config → MemoryFactory → DRAM model classes
• Trace Loader → Processor (if CPU mode) or directly → Controller
• Controller ↔ DRAM model (calls into memory timing logic)
• Controller → Statistics collector (event hooks)
• Optional → Controller → cmd-trace writer → external power tools
• gem5Wrapper bridges gem5 memory requests → Controller
• test_* scripts drive Ramulator CLI → compare outputs
• plot.py reads output stats → generates visualizations
• trace_generator is a side module: independent pipeline producing cpu.trace inputs
c. Architectural patterns & design principles
• Modular DRAM models: one class per standard, all conforming to a DRAM interface
• Factory pattern for DRAM object creation based on config
• Clear separation: core engine vs. front-ends (trace loaders, gem5, power) vs. back-ends (stats, power tools)
• Extensibility: add new DRAM standard by dropping in new .cpp/.h and a config file
d. Key technologies, frameworks, and libraries
• C++11 (clang++, g++)
• Python 3 for test harness and plotting
• SWIG for gem5 integration
• Makefiles for build (root, trace_generator, Simpoint)
• Simpoint (PinPoints) for trace generation
• External DRAM power tools: VAMPIRE, DRAMPower