Skip to content

Commit b190305

Browse files
Merge pull request #6 from muditbhargava66/release/v1.4.0
Release v1.4.0: L3 Cache, MSI/MOESI Protocols, Ring/Torus Interconnects
2 parents 2ef5cbb + 6595b85 commit b190305

34 files changed

+3405
-1121
lines changed

CHANGELOG.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,77 @@ All notable changes to the Cache Simulator project will be documented in this fi
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.4.0] - 2026-01-08
9+
10+
### Added
11+
- **L3 Cache Support**
12+
- Optional third cache level in `MemoryHierarchy`
13+
- Configurable via JSON with `l3` section
14+
- Inclusive L3 policy for multi-core coherence
15+
- Statistics: `getL3Misses()`, `getL3HitRate()`, `getL3MissRate()`
16+
17+
- **MSI/MOESI Coherence Protocols**
18+
- `CoherenceProtocolBase` abstract interface
19+
- `MSIProtocol`: 3-state protocol (Modified, Shared, Invalid)
20+
- `MOESIProtocol`: 5-state protocol (Modified, Owned, Exclusive, Shared, Invalid)
21+
- Factory pattern: `CoherenceProtocolBase::create(type)`
22+
- State transition tracking and statistics
23+
24+
- **Ring and Torus Interconnects**
25+
- `RingInterconnect`: Bidirectional ring with shortest path routing
26+
- `TorusInterconnect`: 2D torus with wrap-around connections
27+
- Proper latency modeling based on hop count
28+
- Full implementation of `InterconnectInterface`
29+
30+
- **CLI Parser Module**
31+
- Extracted from main.cpp to `utils/cli_parser.h/cpp`
32+
- `CLIParser` class with static methods
33+
- Improved code organization and testability
34+
35+
- **Cache Visualization Module**
36+
- Extracted from main.cpp to `utils/cache_visualization.h/cpp`
37+
- `CacheVisualization` class with cache state extraction and ASCII rendering
38+
- `CacheBlockState` struct for block metadata
39+
40+
- **New Unit Tests**
41+
- `tests/unit/core/coherence_protocol_test.cpp` - MSI/MOESI protocol tests
42+
- `tests/unit/core/l3_cache_test.cpp` - L3 cache tests
43+
- `tests/unit/multiprocessor/interconnect_test.cpp` - Ring/Torus tests
44+
- `tests/unit/utils/cli_parser_test.cpp` - CLI parsing tests
45+
46+
- **Multiprocessor Protocol Selection**
47+
- Added `coherenceProtocol` and `interconnectType` to `MultiProcessorSystem::Config`
48+
- Supports MSI, MESI, MOESI protocol selection
49+
- Supports Bus, Crossbar, Mesh, Ring, Torus interconnect selection
50+
51+
### Changed
52+
- **Refactored main.cpp**: Reduced from 822 to 442 lines (-46%)
53+
- Now uses `CLIParser` for command-line parsing
54+
- Now uses `CacheVisualization` for cache state display
55+
- Updated `memory_hierarchy.h` with L3 configuration support
56+
- Updated `CMakeLists.txt` with new source files and tests
57+
- Made Doxygen configuration conditional on file existence
58+
- Updated documentation for all new features
59+
60+
### New Files
61+
- `src/core/coherence_protocol.h/cpp` - Protocol base class and factory
62+
- `src/core/msi_protocol.h/cpp` - MSI implementation
63+
- `src/core/moesi_protocol.h/cpp` - MOESI implementation
64+
- `src/utils/cli_parser.h/cpp` - CLI parsing module
65+
- `src/utils/cache_visualization.h/cpp` - Cache visualization module
66+
- `docs/features/l3-cache.md` - L3 cache documentation
67+
- `docs/features/coherence-protocols.md` - Protocol documentation
68+
- `docs/features/interconnects.md` - Interconnect documentation
69+
70+
### Technical Details
71+
- MOESI Owned state enables dirty sharing without memory writeback
72+
- Ring latency: `min(clockwise, counterclockwise) * hopLatency`
73+
- Torus latency: `(wrapDx + wrapDy) * hopLatency`
74+
- L3 inclusive policy maintains copy of all L1/L2 data
75+
- All 18 tests pass (unit, integration, performance)
76+
77+
---
78+
879
## [1.3.0] - 2026-01-07
980

1081
### Added
@@ -106,6 +177,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
106177
- The fixes ensure compatibility across Windows (GCC/MSVC), macOS (Clang/GCC), and Linux (GCC/Clang)
107178
- No functional changes - only build and compatibility improvements
108179

180+
---
181+
109182
## [1.2.1] - 2025-09-02
110183

111184
### Fixed
@@ -126,6 +199,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
126199
- [x] Compatible with all existing configuration files
127200
- [x] No performance regression
128201

202+
---
203+
129204
## [1.2.0] - 2025-07-19
130205

131206
### Added
@@ -193,6 +268,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
193268
- Fixed lambda capture warnings in victim_cache.h
194269
- Improved const-correctness throughout the codebase
195270

271+
---
272+
196273
## [1.1.0] - 2025-05-27
197274

198275
### Added
@@ -230,6 +307,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
230307
- Reduced memory footprint by 15% through better data structures
231308
- Optimized prefetcher reduces unnecessary memory traffic by 30%
232309

310+
---
311+
233312
## [1.0.0] - 2025-03-12
234313

235314
### Overview
@@ -290,7 +369,9 @@ This release marks the first stable version of the Cache Simulator, featuring a
290369
- Nodiscard attribute handling for method return values
291370
- String_view temporary object lifetime issues
292371

293-
### Future Development
372+
---
373+
374+
## Future Development
294375
- Identified TODOs for future enhancements (see TODO.md for details):
295376
- Multi-processor simulation
296377
- Additional replacement policies

CMakeLists.txt

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.14)
2-
project(CacheSimulator VERSION 1.3.0 LANGUAGES CXX)
2+
project(CacheSimulator VERSION 1.4.0 LANGUAGES CXX)
33

44
# Set C++20 as the required standard (required for designated initializers)
55
set(CMAKE_CXX_STANDARD 20)
@@ -54,6 +54,15 @@ list(APPEND CORE_SOURCES "src/core/write_policy.cpp")
5454
list(APPEND CORE_SOURCES "src/core/multiprocessor/processor_core.cpp")
5555
list(APPEND CORE_SOURCES "src/core/multiprocessor/coherence_controller.cpp")
5656
list(APPEND CORE_SOURCES "src/core/multiprocessor/interconnect.cpp")
57+
58+
# coherence protocols
59+
list(APPEND CORE_SOURCES "src/core/coherence_protocol.cpp")
60+
list(APPEND CORE_SOURCES "src/core/msi_protocol.cpp")
61+
list(APPEND CORE_SOURCES "src/core/moesi_protocol.cpp")
62+
63+
# CLI parser module
64+
list(APPEND UTILS_SOURCES "src/utils/cli_parser.cpp")
65+
5766
# Note: victim_cache.h, parallel_executor.h are header-only
5867

5968
# Define header files
@@ -128,6 +137,16 @@ foreach(TEST_SOURCE ${MODELS_TEST_SOURCES})
128137
add_test(NAME unit_models_${TEST_NAME} COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tests/unit/models/${TEST_NAME})
129138
endforeach()
130139

140+
# Add unit tests - Multiprocessor
141+
file(GLOB MULTIPROCESSOR_TEST_SOURCES "tests/unit/multiprocessor/*.cpp")
142+
foreach(TEST_SOURCE ${MULTIPROCESSOR_TEST_SOURCES})
143+
get_filename_component(TEST_NAME ${TEST_SOURCE} NAME_WE)
144+
add_executable(${TEST_NAME} ${TEST_SOURCE})
145+
target_link_libraries(${TEST_NAME} cachesim_lib)
146+
set_target_properties(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tests/unit/multiprocessor)
147+
add_test(NAME unit_multiprocessor_${TEST_NAME} COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tests/unit/multiprocessor/${TEST_NAME})
148+
endforeach()
149+
131150
# Add integration tests
132151
file(GLOB INTEGRATION_TEST_SOURCES "tests/integration/*.cpp")
133152
foreach(TEST_SOURCE ${INTEGRATION_TEST_SOURCES})
@@ -165,8 +184,8 @@ install(DIRECTORY scripts/
165184
)
166185

167186
# Documentation target if Doxygen is available
168-
find_package(Doxygen)
169-
if(DOXYGEN_FOUND)
187+
find_package(Doxygen QUIET)
188+
if(DOXYGEN_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/docs/Doxyfile.in")
170189
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/src)
171190
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/docs)
172191
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/html/index.html)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Mudit Bhargava
3+
Copyright (c) 2026 Mudit Bhargava
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<div align="center">
22

3-
# 🚀 Cache Simulator
3+
# Cache Simulator
44

5-
![Version](https://img.shields.io/badge/version-1.3.0-blue)
5+
![Version](https://img.shields.io/badge/version-1.4.0-blue)
66
![C++20](https://img.shields.io/badge/C%2B%2B-20-orange)
77
![License](https://img.shields.io/badge/license-MIT-green)
88
![Build Status](https://img.shields.io/badge/build-passing-brightgreen)
@@ -21,13 +21,14 @@
2121

2222
</div>
2323

24-
## What's New in v1.3.0
24+
## What's New in v1.4.0
2525

26-
- **Power Modeling**: CACTI-inspired energy analysis (dynamic + leakage)
27-
- **Area Estimation**: Silicon footprint breakdown by component
28-
- **Technology Nodes**: Support for 7nm, 14nm, 22nm, 32nm, 45nm
29-
- **CLI Integration**: `--power` and `--tech-node` flags
30-
- **Visualization Fix**: ASCII-safe table rendering for cross-platform console
26+
- **L3 Cache Support**: Optional third level cache with inclusive policy
27+
- **MSI/MOESI Protocols**: Extended coherence protocol support
28+
- **Ring/Torus Interconnects**: New network topologies with hop-based latency
29+
- **CLI Parser Module**: Refactored command-line parsing for maintainability
30+
- **Cache Visualization Module**: Extracted visualization code for reusability
31+
- **Main.cpp Refactoring**: Reduced from 822 to 442 lines (-46%)
3132

3233
## Key Features
3334

@@ -51,9 +52,9 @@
5152
- **Configurable Aggressiveness**: Tunable prefetch distance and accuracy
5253

5354
### Multi-Processor Features
54-
- **MESI Protocol**: Full Modified-Exclusive-Shared-Invalid implementation
55+
- **MESI/MSI/MOESI Protocol**: Full coherence protocol implementations
5556
- **Directory-Based Coherence**: Scalable coherence tracking
56-
- **Interconnect Models**: Bus, crossbar, and mesh topologies
57+
- **Interconnect Models**: Bus, Crossbar, Mesh, Ring, and Torus topologies
5758
- **Atomic Operations**: Support for synchronization primitives
5859
- **False Sharing Detection**: Identifies and reports cache line conflicts
5960

@@ -271,11 +272,11 @@ We welcome contributions! Please see our [Contributing Guide](contributing.md) f
271272
If you use this simulator in your research, please cite:
272273

273274
```bibtex
274-
@software{CacheSimulator2025,
275+
@software{CacheSimulator2026,
275276
author = {Mudit Bhargava},
276277
title = {Cache Simulator: A C++20 Cache and Memory Hierarchy Simulator},
277-
version = {1.3.0},
278-
year = {2025},
278+
version = {1.4.0},
279+
year = {2026},
279280
url = {https://github.com/muditbhargava66/CacheSimulator}
280281
}
281282
```
@@ -301,7 +302,7 @@ This simulator is ideal for:
301302

302303
<div align="center">
303304

304-
**Star this repo if you find it useful!**
305+
**Star this repo if you find it useful!**
305306

306307
[![Star History Chart](https://api.star-history.com/svg?repos=muditbhargava66/CacheSimulator&type=Date)](https://star-history.com/#muditbhargava66/CacheSimulator&Date)
307308

build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $ErrorActionPreference = "Stop"
77
$NUM_CORES = [Environment]::ProcessorCount
88
if ($NUM_CORES -eq 0) { $NUM_CORES = 4 }
99

10-
Write-Host "Building Cache Simulator v1.2.2" -ForegroundColor Cyan
10+
Write-Host "Building Cache Simulator v1.4.0" -ForegroundColor Cyan
1111
Write-Host "Detected $NUM_CORES CPU cores" -ForegroundColor Gray
1212

1313
# Create build directory if it doesn't exist

contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Development Setup
44

55
### Prerequisites
6-
- C++17 compatible compiler
6+
- C++20 compatible compiler (GCC 10+, Clang 10+, MSVC 2019+)
77
- CMake 3.14+
88
- Git
99
- Doxygen (for documentation)
@@ -31,7 +31,7 @@
3131
## Code Style Guidelines
3232

3333
### C++ Standards
34-
- Use C++17 features appropriately
34+
- Use C++20 features appropriately
3535
- Follow RAII principles
3636
- Use smart pointers for memory management
3737
- Prefer const-correctness

docs/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ Comprehensive documentation for the Cache Simulator.
2727

2828
| Document | Description |
2929
|----------|-------------|
30+
| [L3 Cache](features/l3-cache.md) | Third-level cache with inclusive policy |
31+
| [Coherence Protocols](features/coherence-protocols.md) | MSI, MESI, MOESI protocol implementations |
32+
| [Interconnects](features/interconnects.md) | Bus, Crossbar, Mesh, Ring, Torus topologies |
3033
| [Power Modeling](features/power-modeling.md) | CACTI-inspired power and area analysis |
3134
| [Replacement Policies](features/replacement-policies.md) | LRU, FIFO, NRU, PLRU, Random |
3235
| [Victim Cache](features/victim-cache.md) | Victim cache implementation |
33-
| [Multiprocessor](features/multiprocessor.md) | MESI coherence and multi-core simulation |
36+
| [Multiprocessor](features/multiprocessor.md) | Multi-core simulation and coherence |
3437
| [Prefetching](features/prefetching.md) | Stream buffer and stride prefetching |
3538

3639
### Platform Documentation

docs/developer/architecture.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ The `Cache` class provides a clean `access()` method that handles all the comple
109109

110110
The `MemoryHierarchy` class orchestrates the entire cache hierarchy, managing:
111111

112-
- Multiple cache levels (L1, L2)
112+
- Multiple cache levels (L1, L2, L3) - L3 support added in v1.4.0
113113
- Memory access flow through the hierarchy
114114
- Prefetching configuration and coordination
115115
- Statistics aggregation
@@ -118,6 +118,28 @@ The `MemoryHierarchy` class orchestrates the entire cache hierarchy, managing:
118118

119119
This class serves as the main API for applications interacting with the simulator, providing methods to access memory, process traces, and retrieve statistics.
120120

121+
#### L3 Cache Support
122+
123+
The `MemoryHierarchy` now supports an optional L3 cache with:
124+
- Configurable size, associativity, and block size
125+
- Inclusive or non-inclusive policy
126+
- Statistics tracking (hit rate, miss rate)
127+
- Proper access flow: L1 miss → L2 access → L2 miss → L3 access
128+
129+
#### Coherence Protocol Framework
130+
131+
Abstract `CoherenceProtocolBase` class with implementations:
132+
- **MSIProtocol**: 3-state (Modified, Shared, Invalid)
133+
- **MESIProtocol**: 4-state with Exclusive
134+
- **MOESIProtocol**: 5-state with Owned for dirty sharing
135+
136+
#### Interconnect Topologies
137+
138+
The `InterconnectFactory` supports:
139+
- Bus, Crossbar, Mesh (existing)
140+
- **RingInterconnect**: Bidirectional ring with wrap-around
141+
- **TorusInterconnect**: 2D torus with minimal path routing
142+
121143
### StreamBuffer
122144

123145
The `StreamBuffer` class implements a simple hardware prefetching mechanism:

0 commit comments

Comments
 (0)