Difference between revisions of "Memory System"

From gem5
Jump to: navigation, search
Line 6: Line 6:
 
===MemObjects===
 
===MemObjects===
 
All objects that connect to the memory system inherit from <code>MemObject</code>. This class adds the pure virtual function <code>getPort(const std::string &name)</code>which returns a port corresponding to the given name. This interface is used to connect memory objects together with the help of a connector (see below).
 
All objects that connect to the memory system inherit from <code>MemObject</code>. This class adds the pure virtual function <code>getPort(const std::string &name)</code>which returns a port corresponding to the given name. This interface is used to connect memory objects together with the help of a connector (see below).
 +
 +
=== Request ===
 +
A request, the overall memory request consisting of the parts of the request that are persistent throughout the transaction.
 +
 +
A request contains the following all of which are accessed by accessors to be certain the data is valid:
 +
* A physical address
 +
* A virtual address
 +
* A size
 +
* The time the request was created
 +
* The PC that caused this request if any
 +
* The Cpu/Thread that caused this request, if any.
  
 
=== Packet ===
 
=== Packet ===
 +
A Packet is used to encapsulate a transfer between two objects in the memory system (e.g., the L1 and L2 cache).  This is in contrast to a Request where a single Request travels all the way from the requester to the ultimate destination and back, possibly being conveyed by several different Packets along the way.
 +
 +
A packet contains the following all of which are accessed by accessors to be certain the data is valid:
 +
* An address for this request.
 +
* A size for this request.
 +
* A pointer to the data being manipulated.
 +
** Set by <code>dataStatic()</code>, <cede>dataDynamic()</code>, and <code>dataDynamicArray()</code> which control if the data associated with the packet is freed when the packet is, not, with <code>delete</code>, and with <code>delete []</code> respectively.
 +
** Allocated if not set by one of the above methods <code>allocate()</code> and the data is freed when the packet is destroyed. (Always safe to call).
 +
** A pointer can be retrived by calling <code>getPtr()</code>
 +
** <code>get()</code> and <code>set()</code> can be used to manipulate the data in the packet. The get() method does a guest-to-host endian conversion and t he set method does a host-to-guest endian conversion.
 +
* A status indicating Success, BadAddress, Not Acknowleged, and Unknown.
 +
* A list of command attributes associated with the packet
 +
* A <code>SenderState</code> pointer which is a virtual base opaque structure used to hold state associated with the packet but specific to the sending device (e.g., an MSHR).  A pointer to this state is returned in the packet's response so that the sender can quickly look up the state needed to process it.  A specific subclass would be derived from this to carry state specific to a particular sending device.
 +
* A <code>CoherenceState</code> pointer which is a virtual base opaque structure used to hold coherence-related state. A specific subclass would be derived from this to carry state specific to a particular coherence protocol.
 +
* A pointer to the request.
  
=== Request ===
 
  
 
===Ports===
 
===Ports===

Revision as of 16:27, 8 June 2006

M5's new memory system was redesigned with the following goals.

  1. Combine the timing and functional accesses into one. With the old memory system the timing accesses did not have data and just accounted for the time it would take to do an operation. Then the functional access actually made the operation visible to the system. This method was confusing, it allowed simulated components to accidently cheat, and wasn't reasonable for an execute-in-execute CPU model.
  2. Simplify the memory system code -- remove the huge amount of templating and duplicate code.
  3. Make changes easier. Specifically to allow other memory hierarchies other than a shared bus based memory system.

MemObjects

All objects that connect to the memory system inherit from MemObject. This class adds the pure virtual function getPort(const std::string &name)which returns a port corresponding to the given name. This interface is used to connect memory objects together with the help of a connector (see below).

Request

A request, the overall memory request consisting of the parts of the request that are persistent throughout the transaction.

A request contains the following all of which are accessed by accessors to be certain the data is valid:

  • A physical address
  • A virtual address
  • A size
  • The time the request was created
  • The PC that caused this request if any
  • The Cpu/Thread that caused this request, if any.

Packet

A Packet is used to encapsulate a transfer between two objects in the memory system (e.g., the L1 and L2 cache). This is in contrast to a Request where a single Request travels all the way from the requester to the ultimate destination and back, possibly being conveyed by several different Packets along the way.

A packet contains the following all of which are accessed by accessors to be certain the data is valid:

  • An address for this request.
  • A size for this request.
  • A pointer to the data being manipulated.
    • Set by dataStatic(), <cede>dataDynamic()</code>, and dataDynamicArray() which control if the data associated with the packet is freed when the packet is, not, with delete, and with delete [] respectively.
    • Allocated if not set by one of the above methods allocate() and the data is freed when the packet is destroyed. (Always safe to call).
    • A pointer can be retrived by calling getPtr()
    • get() and set() can be used to manipulate the data in the packet. The get() method does a guest-to-host endian conversion and t he set method does a host-to-guest endian conversion.
  • A status indicating Success, BadAddress, Not Acknowleged, and Unknown.
  • A list of command attributes associated with the packet
  • A SenderState pointer which is a virtual base opaque structure used to hold state associated with the packet but specific to the sending device (e.g., an MSHR). A pointer to this state is returned in the packet's response so that the sender can quickly look up the state needed to process it. A specific subclass would be derived from this to carry state specific to a particular sending device.
  • A CoherenceState pointer which is a virtual base opaque structure used to hold coherence-related state. A specific subclass would be derived from this to carry state specific to a particular coherence protocol.
  • A pointer to the request.


Ports

The next large part of the memory system in the idea of ports. Ports are used to interface memory objects to each other. They will always come in pairs and we refer to the other port object as the peer. These are used to make the design more modular. With ports a specific interface between every type of object doesn't have to be created. Every memory object has to have at least one port to be useful.

There are two groups of functions in the port object. The send* functions are called on the port by the object that owns that port. For example to send a packet in the memory system a CPU would call myPort->sendTiming(pkt) to send a packet. Each send function has a corresponding recv function that is called on the ports peer. So the implementation of the sendTiming() call above would simply be peer->recvTiming(pkt). Using this method we only have one virtual function call penalty but keep generic ports that can connect together any memory system objects.

Connectors

To connect ports together to make a useable configuration connector objects are used. These simple connector objects take two memory objects and port names as parameters and simply called p1 = obj1->getPort(); p2 = obj2->getPort(); p1->setPeer(p2); p2->setPeer(p1); (In reality more error checking is done). This happens during the connection phase of startup after all simobjects have been created.

Access Types

There are three types of accesses supported by the ports.

  1. Timing - Timing accesses are the most detailed access. They reflect our best effort for realistic timing and include the modeling of queuing delay and resource contention. Once a timing request is successfully sent at some point in the future the device that sent the request will either get the response or a NACK if the request could not be completed (more below). Timing and Atomic accesses can not coexist in the memory system.
  2. Atomic - Atomic accesses are a faster lest detailed access. They are used for fast forwarding and warming up caches and return an approximate time to complete the request without any resource contention or queuing delay. When a atomic access is sent the response is provided when the function returns. Atomic and timing accesses can not coexist in the memory system.
  3. Functional -- Like atomic accesses functional accesses happen instantaneously, but unlike atomic accesses they can coexist in the memory system with atomic on timing accesses. Functional accesses are used for things such as loading binaries, examining/changing variables in the simulated system, and allowing a remote debugger to be attached to the simulator. The important note is when a functional access is received by a device, if it contains a queue of packets all the packets must be searched for requests or responses that the functional access is effecting and they must be updated as appropriate. The Packet::intersect() and fixPacket() methods can help with this.

Timing Flow control

Response and Snoop ranges

Port Descendants