Skip to main content

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.

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.

unsetNoncacheable

void unsetNoncacheable();

Clears the F_NONCACHEABLE flag on the Request.

getNoncacheable

bool getNoncacheable();

Returns whether the F_NONCACHEABLE flag has been set (true) or not (false).

setSuccess

void setSuccess();

Calling this function removes the F_FAIL flag from the Request, indicating that the Request was successful. It is not necessary to call this function on unconditional requests.

unsetSuccess

void unsetSuccess();

Set the F_FAIL flag on the Request, indicating that the request failed.

getSuccess

bool getSuccess();

Returns whether the request was successful by returning the status of the F_FAIL flag. Returns true if the request succeeded (F_FAIL not set) or false if it failed (F_FAIL is set).

setFail

void setFail();

Set the F_FAIL flag on the Request, indicating that the request failed.

unsetFail

void unsetFail();

Unset the F_FAIL flag on the Request, indicating that the request did not fail.

getFail

bool getFail();

Returns whether the request failed by returning the status of the F_FAIL flag. Returns true if the request failed (F_FAIL is set) or false if it did not fail (F_FAIL is not set).

setTrace

void setTrace();

Sets the F_TRACE flag on the Request. This indicates that any debug and/or tracing should include this Request.

unsetTrace

void unsetTrace();

Clears the F_TRACE flag on the Request.

getTrace

bool getTrace();

Returns whether the F_TRACE flag has been set (true) or not (false).

setFlag

void setFlag(flags_t flag);
void setFlag(Flag flag);

Sets the specified flag(s) to the Request.

unsetFlag

void unsetFlag(flags_t flag);
void unsetFlag(Flag flag);

Clears the specified flag(s) on the Request.

getFlag

bool getFlag(flags_t flag);
bool getFlag(Flag flag);

Returns whether the specified flag(s) are set.

clearAllFlags

void clearAllFlags();

Resets the Request's flags field to zero (no flags set).

getAllFlags

flags_t getAllFlags();

Return the value of the Request's flags field.

getFlagString

std::string getFlagString();

Returns a comma separated list (as a string) of the flags set on the request. Built in flags are listed by name (e.g., F_<FLAG>). Other flags are returned as F_<NUM> where NUM is the bit index of the set flag.