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"
34 namespace Interfaces {
96 template <
typename classT,
typename dataT =
void>
105 typedef uint64_t
Addr;
113 typedef uint64_t id_t;
114 typedef uint32_t flags_t;
122 F_NONCACHEABLE = 1 << 1,
125 F_RESERVED = 1 << 16,
128 Request(flags_t fl = 0)
133 Request(id_t rid, flags_t flags = 0) :
137 virtual ~Request() {}
139 id_t getID() {
return id; }
143 virtual bool needsResponse() = 0;
146 virtual SST::Event* convert(RequestConverter* converter) = 0;
148 virtual void handle(RequestHandler* handler) = 0;
151 virtual std::string getString() = 0;
154 void setNoncacheable() { flags |=
static_cast<int>(Flag::F_NONCACHEABLE); }
155 void unsetNoncacheable() { flags &= ~(
static_cast<int>(Flag::F_NONCACHEABLE)); }
156 bool getNoncacheable() {
return flags &
static_cast<int>(Flag::F_NONCACHEABLE); }
158 void setSuccess() { unsetFail(); }
159 void unsetSuccess() { setFail(); }
160 bool getSuccess() {
return ~(flags &
static_cast<int>(Flag::F_FAIL)); }
161 bool getFail() {
return flags &
static_cast<int>(Flag::F_FAIL); }
162 void setFail() { flags |=
static_cast<int>(Flag::F_FAIL); }
163 void unsetFail() { flags &= ~(
static_cast<int>(Flag::F_FAIL)); }
165 void setTrace() { flags |=
static_cast<int>(Flag::F_TRACE); }
166 void unsetTrace() { flags &= (~static_cast<
int>(Flag::F_TRACE)); }
167 bool getTrace() {
return flags &
static_cast<int>(Flag::F_TRACE); }
169 void setFlag(flags_t flag) { flags |= flag; }
170 void setFlag(Flag flag) { flags |=
static_cast<flags_t
>(flag); }
171 void unsetFlag(flags_t flag) { flags &= (~flag); }
172 void unsetFlag(Flag flag) { flags &= ~(
static_cast<flags_t
>(flag)); }
173 bool getFlag(flags_t flag) {
return flags & flag; }
174 bool getFlag(Flag flag) {
return flags &
static_cast<flags_t
>(flag); }
176 void clearAllFlags() { flags = 0; }
177 flags_t getAllFlags() {
return flags; }
179 std::string getFlagString()
182 std::ostringstream str;
184 if ( getNoncacheable() ) {
185 str <<
"F_NONCACHEABLE";
189 if ( comma ) { str <<
","; }
196 if ( comma ) { str <<
","; }
202 for (
unsigned int i = 4; i <
sizeof(flags_t); i++ ) {
203 flags_t shift = 1 << i;
204 if ( getFlag(shift) ) {
205 if ( comma ) { str <<
","; }
220 static std::atomic<id_t> main_id;
233 class StoreConditional;
246 Read(Addr physAddr, uint64_t size, flags_t flags = 0, Addr virtAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
262 std::vector<uint8_t> datavec(
268 bool needsResponse()
override {
return true; }
270 SST::Event* convert(RequestConverter* converter)
override {
return converter->convert(
this); }
272 void handle(RequestHandler* handler)
override {
return handler->handle(
this); }
274 std::string getString()
override
276 std::ostringstream str;
277 str <<
"ID: " <<
id <<
", Type: Read, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex << pAddr
278 <<
", VirtAddr: 0x" << vAddr;
279 str <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec
297 id_t rid, Addr physAddr, uint64_t size, std::vector<uint8_t> respData, flags_t flags = 0, Addr virtAddr = 0,
298 Addr instPtr = 0, uint32_t tid = 0) :
309 Request(readEv->getID(), readEv->getAllFlags()),
310 pAddr(readEv->pAddr),
311 vAddr(readEv->vAddr),
320 Request* makeResponse()
override {
return nullptr; }
322 bool needsResponse()
override {
return false; }
326 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
328 std::string getString()
override
330 std::ostringstream str;
331 str <<
"ID: " <<
id <<
", Type: ReadResp, Flags: [" << getFlagString() <<
"] PhysAddr: 0x" << std::hex
333 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr;
334 str <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x" << std::hex;
335 str << std::setfill(
'0');
336 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
337 str << std::setw(2) << static_cast<unsigned>(*it);
346 std::vector<uint8_t> data;
360 Addr physAddr, uint64_t size, std::vector<uint8_t> wData,
bool posted =
false, flags_t flags = 0,
361 Addr virtAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
374 virtual Request* makeResponse()
override {
return new WriteResp(
this); }
376 virtual bool needsResponse()
override {
return !posted; }
380 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
382 std::string getString()
override
384 std::ostringstream str;
385 str <<
"ID: " <<
id <<
", Type: Write, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
387 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", Posted: " << (posted ?
"T" :
"F");
388 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x"
390 str << std::setfill(
'0');
391 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
392 str << std::setw(2) << static_cast<unsigned>(*it);
401 std::vector<uint8_t> data;
413 id_t
id, Addr physAddr, uint64_t size, flags_t flags = 0, Addr virtAddr = 0, Addr instPtr = 0,
424 Request(wr->getID(), wr->getAllFlags()),
434 virtual Request* makeResponse()
override {
return nullptr; }
436 virtual bool needsResponse()
override {
return false; }
438 SST::Event* convert(RequestConverter* converter)
override {
return converter->convert(
this); }
440 void handle(RequestHandler* handler)
override {
return handler->handle(
this); }
442 std::string getString()
override
444 std::ostringstream str;
445 str <<
"ID:" <<
id <<
", Type: WriteResp, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
447 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr;
448 str <<
", ThreadID: " << std::dec << tid;
469 Addr physAddr, uint64_t size,
bool inv, uint32_t depth, flags_t flags = 0, Addr virtAddr = 0,
470 Addr instPtr = 0, uint32_t tid = 0) :
482 virtual Request* makeResponse()
override {
return new FlushResp(
this); }
484 virtual bool needsResponse()
override {
return true; }
488 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
490 std::string getString()
override
492 std::ostringstream str;
493 str <<
"ID:" <<
id <<
", Type: FlushAddr, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
495 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", Inv: " << (inv ?
"T" :
"F");
496 str <<
", Depth: " << depth <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
517 id_t
id, Addr physAddr, uint64_t size, flags_t flags = 0, Addr vAddr = 0, Addr instPtr = 0,
527 Request(fl->getID(), fl->getAllFlags() | newFlags),
536 virtual Request* makeResponse()
override {
return nullptr; }
538 virtual bool needsResponse()
override {
return false; }
542 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
544 std::string getString()
override
546 std::ostringstream str;
547 str <<
"ID:" <<
id <<
", Type: FlushResp, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
549 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size;
550 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
573 Addr physAddr, uint64_t size, flags_t flags = 0, Addr virtAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
583 Request* makeResponse()
override
585 std::vector<uint8_t> datavec(size, 0);
587 return new ReadResp(
id, pAddr, size, datavec, flags, vAddr, iPtr, tid);
590 bool needsResponse()
override {
return true; }
594 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
596 std::string getString()
override
598 std::ostringstream str;
599 str <<
"ID: " <<
id <<
", Type: ReadLock, Flags: [" << getFlagString() <<
"] PhysAddr: 0x" << std::hex
600 << pAddr <<
", VirtAddr: 0x" << vAddr;
601 str <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec
622 Addr physAddr, uint64_t size, std::vector<uint8_t> wData,
bool posted =
false, flags_t flags = 0,
623 Addr virtAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
636 virtual Request* makeResponse()
override {
return new WriteResp(
id, pAddr, size, flags, vAddr = 0, iPtr, tid); }
638 virtual bool needsResponse()
override {
return !posted; }
642 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
644 std::string getString()
override
646 std::ostringstream str;
647 str <<
"ID: " <<
id <<
", Type: WriteUnlock, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
649 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", Posted: " << (posted ?
"T" :
"F");
650 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x"
652 str << std::setfill(
'0');
653 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
654 str << std::setw(2) << static_cast<unsigned>(*it);
663 std::vector<uint8_t> data;
681 Addr physAddr, uint64_t size, flags_t flags = 0, Addr virtAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
691 Request* makeResponse()
override
693 std::vector<uint8_t> datavec(size, 0);
695 return new ReadResp(
id, pAddr, size, datavec, flags, vAddr, iPtr, tid);
698 bool needsResponse()
override {
return true; }
702 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
704 std::string getString()
override
706 std::ostringstream str;
707 str <<
"ID: " <<
id <<
", Type: LoadLink, Flags: [" << getFlagString() <<
"] PhysAddr: 0x" << std::hex
708 << pAddr <<
", VirtAddr: 0x" << vAddr;
709 str <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec
730 Addr physAddr, uint64_t size, std::vector<uint8_t> wData, flags_t flags = 0, Addr virtAddr = 0,
731 Addr instPtr = 0, uint32_t tid = 0) :
744 virtual Request* makeResponse()
override {
return new WriteResp(
id, pAddr, size, flags, vAddr, iPtr, tid); }
746 virtual bool needsResponse()
override {
return true; }
750 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
752 std::string getString()
override
754 std::ostringstream str;
755 str <<
"ID: " <<
id <<
", Type: StoreConditional, Flags: [" << getFlagString() <<
"], PhysAddr: 0x"
756 << std::hex << pAddr;
757 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size;
758 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x"
760 str << std::setfill(
'0');
761 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
762 str << std::setw(2) << static_cast<unsigned>(*it);
771 std::vector<uint8_t> data;
784 Addr pSrc, Addr pDst, uint64_t size,
bool posted =
false, flags_t flags = 0, Addr vSrc = 0, Addr vDst = 0,
785 Addr iPtr = 0, uint32_t tid = 0) :
798 virtual Request* makeResponse()
override {
return new WriteResp(
id, pDst, size, flags, vDst, iPtr, tid); }
800 virtual bool needsResponse()
override {
return !posted; }
804 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
806 std::string getString()
override
808 std::ostringstream str;
809 str <<
"ID: " <<
id <<
", Type: MoveData, Flags: [" << getFlagString() <<
"], SrcPhysAddr: 0x" << std::hex
811 str <<
", SrcVirtAddr: 0x" << vSrc <<
", DstPhysAddr: 0x" << pDst <<
", DstVirtAddr: 0x" << vDst;
812 str <<
", Size: " << std::dec << size <<
", Posted: " << (posted ?
"T" :
"F");
813 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
833 InvNotify(Addr pAddr, uint64_t size, flags_t flags = 0, Addr vAddr = 0, Addr iPtr = 0, uint32_t tid = 0) :
843 virtual Request* makeResponse()
override {
return nullptr; }
845 virtual bool needsResponse()
override {
return false; }
849 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
851 std::string getString()
override
853 std::ostringstream str;
854 str <<
"ID: " <<
id <<
", Type: InvNotify, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
856 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size;
857 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
876 virtual Addr getRoutingAddress() = 0;
877 virtual uint64_t getSize() = 0;
879 virtual bool needsResponse() = 0;
880 virtual std::string getString() = 0;
899 virtual Request* makeResponse()
override {
return new CustomResp(
this); }
901 virtual bool needsResponse()
override {
return data->needsResponse(); }
905 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
907 std::string getString()
override
909 std::ostringstream str;
910 str <<
"ID: " <<
id <<
", Type: CustomReq, Flags: [" << getFlagString() <<
"], " << data->getString();
911 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
930 Request(req->getID(), req->getAllFlags()),
931 data(req->data->makeResponse()),
937 virtual Request* makeResponse()
override {
return nullptr; }
939 virtual bool needsResponse()
override {
return false; }
943 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
945 std::string getString()
override
947 std::ostringstream str;
948 str <<
"ID: " <<
id <<
", Type: CustomResp, Flags: [" << getFlagString() <<
"], " << data->getString();
949 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
990 virtual void handle(
Read* UNUSED(request))
992 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for Read requests is not implemented\n");
994 virtual void handle(
ReadResp* UNUSED(request))
996 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for ReadResp requests is not implemented\n");
998 virtual void handle(
Write* UNUSED(request))
1000 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for Write requests is not implemented\n");
1002 virtual void handle(
WriteResp* UNUSED(request))
1004 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for WriteResp requests is not implemented\n");
1006 virtual void handle(
FlushAddr* UNUSED(request))
1008 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for FlushAddr requests is not implemented\n");
1010 virtual void handle(
FlushResp* UNUSED(request))
1012 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for FlushResp requests is not implemented\n");
1014 virtual void handle(
ReadLock* UNUSED(request))
1016 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for ReadLock requests is not implemented\n");
1020 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for WriteUnlock requests is not implemented\n");
1022 virtual void handle(
LoadLink* UNUSED(request))
1024 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for LoadLink requests is not implemented\n");
1028 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for StoreConditional requests is not implemented\n");
1030 virtual void handle(
MoveData* UNUSED(request))
1032 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for MoveData requests is not implemented\n");
1034 virtual void handle(
CustomReq* UNUSED(request))
1036 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for CustomReq requests is not implemented\n");
1038 virtual void handle(
CustomResp* UNUSED(request))
1040 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for CustomResp requests is not implemented\n");
1042 virtual void handle(
InvNotify* UNUSED(request))
1044 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for InvNotify requests is not implemented\n");
1083 virtual void send(Request* req) = 0;
1095 virtual Request*
poll(
void) = 0;
1126 #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:51
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:34
Definition: ssthandler.h:100
Request * makeResponse() override
Create read response.
Definition: stdMem.h:260
Response to a Write.
Definition: stdMem.h:408
virtual Request * poll(void)=0
Receive a Request response from the side of the link.
Conditional atomic update.
Definition: stdMem.h:677
Event Handler class with user-data argument.
Definition: ssthandler.h:115
A class to convert between a component's view of time and the core's view of time.
Definition: timeConverter.h:26
Base class for StandardMem commands.
Definition: stdMem.h:110
Response to a Read.
Definition: stdMem.h:293
virtual ~WriteResp()
Destructor.
Definition: stdMem.h:432
Move: move data from one address to another Returns a WriteResp.
Definition: stdMem.h:780
Generic interface to Memory models.
Definition: stdMem.h:69
Definition: serializable.h:118
virtual void setMemoryMappedAddressRegion(Addr start, Addr size)=0
Sets the physical memory address(es), if any, that are mapped to this endpoint.
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:155
Locked atomic update -> guaranteed success A ReadLock must be followed by a WriteUnlock.
Definition: stdMem.h:569
virtual Request * recvUntimedData()=0
Receive any data during the init()/complete() phases.
Response to a flush request.
Definition: stdMem.h:513
Flag
Flags that modify requests.
Definition: stdMem.h:121
Read request.
Definition: stdMem.h:243
Notifies endpoint that an address has been invalidated from the L1.
Definition: stdMem.h:830
uint64_t Addr
All Addresses can be 64-bit.
Definition: stdMem.h:100
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:412
Parameter store.
Definition: params.h:55
virtual Addr getLineSize()=0
Get cache/memory line size (in bytes) from the memory system.
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:1057
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:355
WriteResp(Write *wr)
Automatically construct a write response from a Write.
Definition: stdMem.h:423