Cache Coherence: System Config for C++ implementation
Now let’s talk about the system config which will be used in C++ implementation of MOESI cache coherence.
There are three main components:
- CPU: Containing eight cores
- Bus: Point of coherence and serialization
- Memory
Let’s see what these queues are used for.
- core2bus_req: This queue contains requests sent by the core to bus.
These requests can be:
→ CoreRead request: Core sends read request to bus which will either send to Memory or get data from cache.
→ CoreMemWriteBack: Core sends write-back request to bus which will forward to memory.
→ CoreCacheInvalidateReq: Whenever there is a write request, Core sends an invalidate bus request which will send to other cores having copy of that line.
2. core2bus_rsp: This queue contains responses sent by core to bus.
The responses can be:
→ CoreInvalidateAck: When the core invalidates its line copy, it sends Ack to bus.
→ CoreDataResponse: Whenever there is read request from bus to core having the line, core responds with the data.
3. bus2core: This queue contains requests and responses from bus to core.
Request includes:
→ BusReadReq: Bus sends read request to core which has the copy of line.
→ BusCacheInvalidate: Bus receives invalidate request from core (source) and then bus sends an invalidate req to cores having that line.
Possible responses:
→ BusDataResponse: Bus forwards the data it received from the source core.
→ BusInvalidateAck: Once all cores having line invalidate their copy and send invalidateAck to bus, bus sends source core the acknowledgement meaning that it can perform write operation on the line.
→ BusWriteAck: Bus forwards the acknowledgement from memory to Core meaning that memory is now updated and the core can remove the line.
4. mem2bus: This queue contains MemWriteAck and MemDataResponse provided by bus. The bus will then forward it to the corresponding core in CPU.
5. bus2mem: This queue has MemRead and MemWrite request
I have added some documentation to the codebase and one can find it in doc directory in the GitHub repository:
https://github.com/himanshu5-prog/coherent_protocols/tree/main