14 #ifndef SST_CORE_INTERFACES_STANDARDMEM_H 15 #define SST_CORE_INTERFACES_STANDARDMEM_H 17 #include "sst/core/link.h" 18 #include "sst/core/params.h" 19 #include "sst/core/sst_types.h" 20 #include "sst/core/ssthandler.h" 21 #include "sst/core/subcomponent.h" 22 #include "sst/core/warnmacros.h" 35 namespace Interfaces {
97 template <
typename classT,
typename dataT =
void>
106 typedef uint64_t
Addr;
107 #define PRI_ADDR PRIx64 115 typedef uint64_t id_t;
116 typedef uint32_t flags_t;
124 F_NONCACHEABLE = 1 << 1,
127 F_RESERVED = 1 << 16,
135 Request(id_t rid, flags_t flags = 0) :
139 virtual ~Request() {}
141 id_t getID() {
return id; }
145 virtual bool needsResponse() = 0;
148 virtual SST::Event* convert(RequestConverter* converter) = 0;
150 virtual void handle(RequestHandler* handler) = 0;
153 virtual std::string getString() = 0;
156 void setNoncacheable() { flags |=
static_cast<int>(Flag::F_NONCACHEABLE); }
157 void unsetNoncacheable() { flags &= ~(
static_cast<int>(Flag::F_NONCACHEABLE)); }
158 bool getNoncacheable() {
return flags &
static_cast<int>(Flag::F_NONCACHEABLE); }
160 void setSuccess() { unsetFail(); }
161 void unsetSuccess() { setFail(); }
162 bool getSuccess() {
return (flags & static_cast<int>(Flag::F_FAIL)) == 0; }
163 bool getFail() {
return flags &
static_cast<int>(Flag::F_FAIL); }
164 void setFail() { flags |=
static_cast<int>(Flag::F_FAIL); }
165 void unsetFail() { flags &= ~(
static_cast<int>(Flag::F_FAIL)); }
167 void setTrace() { flags |=
static_cast<int>(Flag::F_TRACE); }
168 void unsetTrace() { flags &= (~static_cast<
int>(Flag::F_TRACE)); }
169 bool getTrace() {
return flags &
static_cast<int>(Flag::F_TRACE); }
171 void setFlag(flags_t flag) { flags |= flag; }
172 void setFlag(
Flag flag) { flags |=
static_cast<flags_t
>(flag); }
173 void unsetFlag(flags_t flag) { flags &= (~flag); }
174 void unsetFlag(
Flag flag) { flags &= ~(
static_cast<flags_t
>(flag)); }
175 bool getFlag(flags_t flag) {
return flags & flag; }
176 bool getFlag(
Flag flag) {
return flags &
static_cast<flags_t
>(flag); }
178 void clearAllFlags() { flags = 0; }
179 flags_t getAllFlags() {
return flags; }
181 std::string getFlagString()
184 std::ostringstream str;
186 if ( getNoncacheable() ) {
187 str <<
"F_NONCACHEABLE";
191 if ( comma ) { str <<
","; }
198 if ( comma ) { str <<
","; }
204 for (
unsigned int i = 4; i <
sizeof(flags_t) * CHAR_BIT; i++ ) {
205 flags_t shift = 1 << i;
206 if ( getFlag(shift) ) {
207 if ( comma ) { str <<
","; }
222 static std::atomic<id_t> main_id;
235 class StoreConditional;
248 Read(
Addr physAddr, uint64_t size, flags_t flags = 0,
Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
264 std::vector<uint8_t> datavec(
270 bool needsResponse()
override {
return true; }
272 SST::Event* convert(RequestConverter* converter)
override {
return converter->convert(
this); }
274 void handle(RequestHandler* handler)
override {
return handler->handle(
this); }
276 std::string getString()
override 278 std::ostringstream str;
279 str <<
"ID: " <<
id <<
", Type: Read, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex << pAddr
280 <<
", VirtAddr: 0x" << vAddr;
281 str <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec
299 id_t rid,
Addr physAddr, uint64_t size, std::vector<uint8_t> respData, flags_t flags = 0,
Addr virtAddr = 0,
300 Addr instPtr = 0, uint32_t tid = 0) :
311 Request(readEv->getID(), readEv->getAllFlags()),
312 pAddr(readEv->pAddr),
313 vAddr(readEv->vAddr),
322 Request* makeResponse()
override {
return nullptr; }
324 bool needsResponse()
override {
return false; }
328 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
330 std::string getString()
override 332 std::ostringstream str;
333 str <<
"ID: " <<
id <<
", Type: ReadResp, Flags: [" << getFlagString() <<
"] PhysAddr: 0x" << std::hex
335 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr;
336 str <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x" << std::hex;
337 str << std::setfill(
'0');
338 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
339 str << std::setw(2) << static_cast<unsigned>(*it);
348 std::vector<uint8_t> data;
362 Addr physAddr, uint64_t size, std::vector<uint8_t> wData,
bool posted =
false, flags_t flags = 0,
363 Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
378 virtual bool needsResponse()
override {
return !posted; }
382 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
384 std::string getString()
override 386 std::ostringstream str;
387 str <<
"ID: " <<
id <<
", Type: Write, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
389 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", Posted: " << (posted ?
"T" :
"F");
390 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x" 392 str << std::setfill(
'0');
393 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
394 str << std::setw(2) << static_cast<unsigned>(*it);
403 std::vector<uint8_t> data;
415 id_t
id,
Addr physAddr, uint64_t size, flags_t flags = 0,
Addr virtAddr = 0,
Addr instPtr = 0,
426 Request(wr->getID(), wr->getAllFlags()),
436 virtual Request* makeResponse()
override {
return nullptr; }
438 virtual bool needsResponse()
override {
return false; }
440 SST::Event* convert(RequestConverter* converter)
override {
return converter->convert(
this); }
442 void handle(RequestHandler* handler)
override {
return handler->handle(
this); }
444 std::string getString()
override 446 std::ostringstream str;
447 str <<
"ID: " <<
id <<
", Type: WriteResp, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
449 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr;
450 str <<
", ThreadID: " << std::dec << tid;
471 Addr physAddr, uint64_t size,
bool inv, uint32_t depth, flags_t flags = 0,
Addr virtAddr = 0,
472 Addr instPtr = 0, uint32_t tid = 0) :
486 virtual bool needsResponse()
override {
return true; }
490 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
492 std::string getString()
override 494 std::ostringstream str;
495 str <<
"ID: " <<
id <<
", Type: FlushAddr, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
497 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", Inv: " << (inv ?
"T" :
"F");
498 str <<
", Depth: " << depth <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
519 id_t
id,
Addr physAddr, uint64_t size, flags_t flags = 0,
Addr vAddr = 0,
Addr instPtr = 0,
529 Request(fl->getID(), fl->getAllFlags() | newFlags),
538 virtual Request* makeResponse()
override {
return nullptr; }
540 virtual bool needsResponse()
override {
return false; }
544 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
546 std::string getString()
override 548 std::ostringstream str;
549 str <<
"ID: " <<
id <<
", Type: FlushResp, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
551 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size;
552 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
575 Addr physAddr, uint64_t size, flags_t flags = 0,
Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
585 Request* makeResponse()
override 587 std::vector<uint8_t> datavec(size, 0);
589 return new ReadResp(
id, pAddr, size, datavec, flags, vAddr, iPtr, tid);
592 bool needsResponse()
override {
return true; }
596 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
598 std::string getString()
override 600 std::ostringstream str;
601 str <<
"ID: " <<
id <<
", Type: ReadLock, Flags: [" << getFlagString() <<
"] PhysAddr: 0x" << std::hex
602 << pAddr <<
", VirtAddr: 0x" << vAddr;
603 str <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec
624 Addr physAddr, uint64_t size, std::vector<uint8_t> wData,
bool posted =
false, flags_t flags = 0,
625 Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
638 virtual Request* makeResponse()
override {
return new WriteResp(
id, pAddr, size, flags, vAddr = 0, iPtr, tid); }
640 virtual bool needsResponse()
override {
return !posted; }
644 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
646 std::string getString()
override 648 std::ostringstream str;
649 str <<
"ID: " <<
id <<
", Type: WriteUnlock, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
651 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", Posted: " << (posted ?
"T" :
"F");
652 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x" 654 str << std::setfill(
'0');
655 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
656 str << std::setw(2) << static_cast<unsigned>(*it);
665 std::vector<uint8_t> data;
683 Addr physAddr, uint64_t size, flags_t flags = 0,
Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
693 Request* makeResponse()
override 695 std::vector<uint8_t> datavec(size, 0);
697 return new ReadResp(
id, pAddr, size, datavec, flags, vAddr, iPtr, tid);
700 bool needsResponse()
override {
return true; }
704 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
706 std::string getString()
override 708 std::ostringstream str;
709 str <<
"ID: " <<
id <<
", Type: LoadLink, Flags: [" << getFlagString() <<
"] PhysAddr: 0x" << std::hex
710 << pAddr <<
", VirtAddr: 0x" << vAddr;
711 str <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec
732 Addr physAddr, uint64_t size, std::vector<uint8_t> wData, flags_t flags = 0,
Addr virtAddr = 0,
733 Addr instPtr = 0, uint32_t tid = 0) :
746 virtual Request* makeResponse()
override {
return new WriteResp(
id, pAddr, size, flags, vAddr, iPtr, tid); }
748 virtual bool needsResponse()
override {
return true; }
752 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
754 std::string getString()
override 756 std::ostringstream str;
757 str <<
"ID: " <<
id <<
", Type: StoreConditional, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" 758 << std::hex << pAddr;
759 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size;
760 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x" 762 str << std::setfill(
'0');
763 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
764 str << std::setw(2) << static_cast<unsigned>(*it);
773 std::vector<uint8_t> data;
786 Addr pSrc,
Addr pDst, uint64_t size,
bool posted =
false, flags_t flags = 0,
Addr vSrc = 0,
Addr vDst = 0,
787 Addr iPtr = 0, uint32_t tid = 0) :
800 virtual Request* makeResponse()
override {
return new WriteResp(
id, pDst, size, flags, vDst, iPtr, tid); }
802 virtual bool needsResponse()
override {
return !posted; }
806 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
808 std::string getString()
override 810 std::ostringstream str;
811 str <<
"ID: " <<
id <<
", Type: MoveData, Flags: [" << getFlagString() <<
"], SrcPhysAddr: 0x" << std::hex
813 str <<
", SrcVirtAddr: 0x" << vSrc <<
", DstPhysAddr: 0x" << pDst <<
", DstVirtAddr: 0x" << vDst;
814 str <<
", Size: " << std::dec << size <<
", Posted: " << (posted ?
"T" :
"F");
815 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
835 InvNotify(
Addr pAddr, uint64_t size, flags_t flags = 0,
Addr vAddr = 0,
Addr iPtr = 0, uint32_t tid = 0) :
845 virtual Request* makeResponse()
override {
return nullptr; }
847 virtual bool needsResponse()
override {
return false; }
851 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
853 std::string getString()
override 855 std::ostringstream str;
856 str <<
"ID: " <<
id <<
", Type: InvNotify, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
858 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size;
859 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
878 virtual Addr getRoutingAddress() = 0;
879 virtual uint64_t getSize() = 0;
881 virtual bool needsResponse() = 0;
882 virtual std::string getString() = 0;
903 virtual bool needsResponse()
override {
return data->needsResponse(); }
907 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
909 std::string getString()
override 911 std::ostringstream str;
912 str <<
"ID: " <<
id <<
", Type: CustomReq, Flags: [" << getFlagString() <<
"], " << data->getString();
913 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
974 Request(req->getID(), req->getAllFlags()),
975 data(req->
getData().makeResponse()),
981 virtual Request* makeResponse()
override {
return nullptr; }
983 virtual bool needsResponse()
override {
return false; }
987 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
989 std::string getString()
override 991 std::ostringstream str;
992 str <<
"ID: " <<
id <<
", Type: CustomResp, Flags: [" << getFlagString() <<
"], " << data->getString();
993 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
1076 virtual void handle(
Read* UNUSED(request))
1078 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for Read requests is not implemented\n");
1080 virtual void handle(
ReadResp* UNUSED(request))
1082 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for ReadResp requests is not implemented\n");
1084 virtual void handle(
Write* UNUSED(request))
1086 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for Write requests is not implemented\n");
1088 virtual void handle(
WriteResp* UNUSED(request))
1090 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for WriteResp requests is not implemented\n");
1092 virtual void handle(
FlushAddr* UNUSED(request))
1094 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for FlushAddr requests is not implemented\n");
1096 virtual void handle(
FlushResp* UNUSED(request))
1098 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for FlushResp requests is not implemented\n");
1100 virtual void handle(
ReadLock* UNUSED(request))
1102 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for ReadLock requests is not implemented\n");
1106 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for WriteUnlock requests is not implemented\n");
1108 virtual void handle(
LoadLink* UNUSED(request))
1110 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for LoadLink requests is not implemented\n");
1114 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for StoreConditional requests is not implemented\n");
1116 virtual void handle(
MoveData* UNUSED(request))
1118 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for MoveData requests is not implemented\n");
1120 virtual void handle(
CustomReq* UNUSED(request))
1122 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for CustomReq requests is not implemented\n");
1124 virtual void handle(
CustomResp* UNUSED(request))
1126 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for CustomResp requests is not implemented\n");
1128 virtual void handle(
InvNotify* UNUSED(request))
1130 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for InvNotify requests is not implemented\n");
1172 virtual void send(Request* req) = 0;
1184 virtual Request*
poll(
void) = 0;
1220 #endif // SST_CORE_INTERFACES_STANDARDMEM_H Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:53
void setData(CustomData *d)
Set the CustomData object associated with this response to a new value.
Definition: stdMem.h:1016
Definition: stdMem.h:1069
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:43
CustomData * releaseData()
Obtain the CustomData object associated with this response.
Definition: stdMem.h:1037
Handlers with 1 handler defined argument to callback from caller.
Definition: ssthandler.h:210
void fatal(uint32_t line, const char *file, const char *func, int exit_code, const char *format,...) const
Output the fatal message with formatting as specified by the format parameter.
Definition: output.cc:163
Request * makeResponse() override
Create read response.
Definition: stdMem.h:262
Response to a Write.
Definition: stdMem.h:410
virtual Request * poll(void)=0
Receive a Request response from the side of the link.
Definition: stdMem.h:1045
Conditional atomic update.
Definition: stdMem.h:679
Handler class with user-data argument.
Definition: ssthandler.h:284
A class to convert between a component's view of time and the core's view of time.
Definition: timeConverter.h:27
CustomData & getData()
Get the CustomData object associated with this response.
Definition: stdMem.h:1001
const CustomData & getData() const
Get the CustomData object associated with this response.
Definition: stdMem.h:1008
const CustomData & getData() const
Get the CustomData object associated with this request.
Definition: stdMem.h:928
Base class for StandardMem commands.
Definition: stdMem.h:112
Response to a Read.
Definition: stdMem.h:295
virtual ~WriteResp()
Destructor.
Definition: stdMem.h:434
Move: move data from one address to another Returns a WriteResp.
Definition: stdMem.h:782
Generic interface to Memory models.
Definition: stdMem.h:70
Definition: serializable.h:24
CustomData & getData()
Get the CustomData object associated with this request.
Definition: stdMem.h:921
CustomData * resetData(CustomData *d=nullptr)
Reset the CustomData object associated with this response to a new value.
Definition: stdMem.h:1030
virtual void setMemoryMappedAddressRegion(Addr start, Addr size)=0
Sets the physical memory address(es), if any, that are mapped to this endpoint.
StandardMem()
Default constructor, used for serialization ONLY.
Definition: stdMem.h:1149
Locked atomic update -> guaranteed success A ReadLock must be followed by a WriteUnlock.
Definition: stdMem.h:571
virtual Request * recvUntimedData()=0
Receive any data during the init()/complete() phases.
Response to a flush request.
Definition: stdMem.h:515
Flag
Flags that modify requests.
Definition: stdMem.h:123
Read request.
Definition: stdMem.h:245
CustomData * resetData(CustomData *d=nullptr)
Reset the CustomData object associated with this request to a new value.
Definition: stdMem.h:950
Notifies endpoint that an address has been invalidated from the L1.
Definition: stdMem.h:832
uint64_t Addr
All Addresses can be 64-bit.
Definition: stdMem.h:101
WriteResp(id_t id, Addr physAddr, uint64_t size, flags_t flags=0, Addr virtAddr=0, Addr instPtr=0, uint32_t tid=0)
Manually construct a write response.
Definition: stdMem.h:414
Parameter store.
Definition: params.h:55
void setData(CustomData *d)
Set the CustomData object associated with this request to a new value.
Definition: stdMem.h:936
virtual Addr getLineSize()=0
Get cache/memory line size (in bytes) from the memory system.
virtual void serialize_order(SST::Core::Serialization::serializer &ser)
Serialization function.
Definition: stdMem.h:1214
virtual void send(Request *req)=0
Send a Request through the interface.
virtual void sendUntimedData(Request *req)=0
Sends a memory-based request during the init()/complete() phases.
StandardMem(SST::ComponentId_t id, Params &UNUSED(params), TimeConverter *&UNUSED(time), HandlerBase *&UNUSED(handler))
Constructor, designed to be used via 'loadUserSubComponent' and 'loadAnonymousSubComponent'.
Definition: stdMem.h:1143
CustomData * releaseData()
Obtain the CustomData object associated with this request.
Definition: stdMem.h:957
Base class for Events - Items sent across links to communicate between components.
Definition: event.h:34
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:28
Request to write data.
Definition: stdMem.h:357
WriteResp(Write *wr)
Automatically construct a write response from a Write.
Definition: stdMem.h:425