StandardMem::Request
The Request class is the base class for all requests and responses that get sent through the StandardMem interface. Several basic request types are defined in the interface, including reads, writes, and flushes. In addition, a CustomReq
and CustomResp
type are provided. Implementations can use these to wrap custom request and response types that can also be passed through the interface alongside the basic request types.
It is not expected that every StandardMem implementation (and by extension, every memory system component) will handle all of the available request types. Some are specific to particular categories of memory component, for example, flushes may only apply to cache components. If a StandardMem implementation does not implement a handler for a particular type, passing that type to the interface will result in an error message indicating that the request type is not supported.
Types
StandardMem::Request defines two types.
- id_t (uint64_t) Every StandardMem::Request is assigned a unique (per-component) identifier. A request and response contain the same identifier to facilitate matching.
- flags_t (uint32_t) The flags field is a 32-bit vector. The lower 16 bits are either in use or reserved for future use by the StandardMem::Request field. The upper 16 bits are available for memory and endpoint libraries to define their own flags. The
F_RESERVED
flag marks the 16-bit boundary.- Flag::F_NONCACHEABLE (
0x1
) Indicates caches should be bypassed for this Request - Flag::F_FAIL (
0x2
) For accesses that can fail, this flag indicates that the access failed - Flag::F_TRACE (
0x4
) Set this flag to request that the memory system generate trace or debug output for this event - Flag::F_RESERVED (
0x10000
) Marks the 16-bit boundary between the lower 16 bits of the flag field that are reserved for StandardMem::Request use and the upper 16 that are available for implementations to define.
- Flag::F_NONCACHEABLE (
Request handling
Requests are handled by the interface using two visitor classes, RequestConverter
and RequestHandler
. The former is intended to be used by a StandardMem implementation to convert a StandardMem::Request into an SST::Event type used by the implementation internally. The latter is used by the interface to handle events coming in from the memory system according to type.
Functions
These functions are provided by the base StandardMem::Request
class and available to all child classes. The following functions must be defined by all child classes.
makeResponse
needsResponse
convert
handle
getString
getID
id_t getID();
Returns the request's identifier. A request and corresponding response will share an identifier.
makeResponse
virtual Request* makeResponse() =0;
This function must be implemented by all Request
classes. Interfaces and endpoints can call this function to generate an appropriate response type if the Request
is the request part of a request-response pair. Otherwise, it should return nullptr
.
needsResponse
virtual bool needsResponse() =0;
All Request
classes must implement this function. It should return true
if a response is expected for the Request
type.
convert
virtual SST::Event* convert(RequestConverter* converter) = 0;
All Request
classes must implement this function. It should return an event generated by called convert
on the converter
visitor class.
handle
virtual void handle(RequestHandler* handler) =0;
All Request
classes must implement this function. It should call handle
on the handler passed into the function.
getString
virtual std::string getString() =0;
This function returns a string representation of the class for debug or informational purposes.
setNoncacheable
void setNoncacheable();
Calling this function sets the F_NONCACHEABLE
flag on the Request
, indicating that the Request
is not intended to be cached.