How riscv-software-src/riscv-perf-model works
Based on our analysis of the file structure and the README, Olympia is an out-of-order RISC-V CPU performance simulator built in C++ using the Sparta Modeling Framework. It is a trace-driven simulator that “runs” traces (in JSON or STF format) through various CPU pipeline components (like fetch, decode, dispatch, rename, execute, LSU, and vector units) while accepting configuration (via YAML and command‐line switches) and generating detailed simulation reports and performance event logs.
Main components of the system
• Simulator Core: This is the heart of the simulator, represented by the “sim” module (see sim/OlympiaSim.cpp) that loads trace inputs and drives simulation.
• CPU Core Model: Organized under the “core” directory, this includes submodules for:
– Fetch: Fetch unit (core/fetch) which contains modules like ICache and branch prediction (BranchPredIF).
– Decode: Decode unit (core/decode) for interpreting instructions and handling fusion (see FusionDecode.cpp, MavisUnit.cpp).
– Dispatch: Dispatch unit (core/dispatch) managing the distribution of instructions.
– Rename: Rename unit (core/rename) which is responsible for register renaming and dependency handling.
– Execute: Execute, including execution pipelines (core/execute) which cover unit operations such as ALU and FPU functions.
– LSU: Load-store unit (core/lsu) for memory operations including DCache functionalities.
– Vector Unit: Specific modules in core/vector handle vector instruction execution.
• Memory/Cache Subsystem: In addition to the core memory instructions, the simulation includes L2 caches and cache coherence elements (see mss/ and caches in core/).
• Architecture Configurations: The “arches” directory holds YAML files and JSON trace inputs for different core configurations (small_core, medium_core, big_core, fusion variants). These files define pipeline mappings, issue queue configurations, and rename mappings.
• Reporting and Logging: The simulation has built-in mechanisms for generating logs, performance events (PEvents), and reports (see reports directory and relevant command-line options). This includes report generation (core_report.def, core_timeseries.def) and log settings.
• Auxiliary Tools: There are helper scripts and supporting files (e.g., generation of configuration files, STF trace generation in traces/stf_trace_gen, and Python scripts for plotting in reports).
Architectural Patterns and Design Principles
• The simulator is designed using modular pipeline components. Each pipeline stage (fetch, decode, dispatch, rename, execute) is implemented in its own subdirectory with independently compiled C++ files.
• The design supports extensibility—new instructions or modules (e.g., branch prediction or prefetching enhancements) can be added easily. Indicate extension points where further customization is allowed.
• Integration with external systems (Sparta Modeling Framework, STF trace tools) should be visually represented as dependency components.
Technology and Tools
• C++ (core simulation modules, CPU core modeling)
• CMake (build management)
• Python (for processing reports and visualization, e.g., in reports/plot_ts.py)
• YAML/JSON (for configuration and traces)
• Concurrency aspects could be highlighted if applicable.
Essential Elements
• Clear labels for each primary block:
– Simulator Entry Point ("Olympia Simulator")
– CPU Pipeline stages: Fetch, Decode, Dispatch, Rename, Issue Queues, Execute, LSU, Vector
– Memory subsystem / L2 Cache (MSS)
– Reporting & Logging (PEvents, Report Generation)
– Configuration and Architecture files (arches directory)
– External Dependencies (Sparta, STF, conda environment)
– Show the instruction flow through the CPU pipeline.
– Indicate configuration inputs and output reporting flows.
• Annotations:
– Add notes for pipeline mapping and renaming strategy as seen in the README examples.
– Highlight that the simulator supports multiple core configurations (e.g., small, medium, and big core) based on the YAML configuration files.