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 Experimental {
44 namespace Interfaces {
106 template <
typename classT,
typename dataT =
void>
115 typedef uint64_t
Addr;
123 typedef uint64_t id_t;
124 typedef uint32_t flags_t;
132 F_NONCACHEABLE = 1 << 1,
135 F_RESERVED = 1 << 16,
138 Request(flags_t fl = 0)
143 Request(id_t rid, flags_t flags = 0) :
147 virtual ~Request() {}
149 id_t getID() {
return id; }
153 virtual bool needsResponse() = 0;
156 virtual SST::Event* convert(RequestConverter* converter) = 0;
158 virtual void handle(RequestHandler* handler) = 0;
161 virtual std::string getString() = 0;
164 void setNoncacheable() { flags |=
static_cast<int>(Flag::F_NONCACHEABLE); }
165 void unsetNoncacheable() { flags &= ~(
static_cast<int>(Flag::F_NONCACHEABLE)); }
166 bool getNoncacheable() {
return flags &
static_cast<int>(Flag::F_NONCACHEABLE); }
168 void setSuccess() { flags |=
static_cast<int>(Flag::F_SUCCESS); }
169 void unsetSuccess() { flags &= ~(
static_cast<int>(Flag::F_SUCCESS)); }
170 bool getSuccess() {
return flags &
static_cast<int>(Flag::F_SUCCESS); }
172 void setTrace() { flags |=
static_cast<int>(Flag::F_TRACE); }
173 void unsetTrace() { flags &= (~static_cast<
int>(Flag::F_TRACE)); }
174 bool getTrace() {
return flags &
static_cast<int>(Flag::F_TRACE); }
176 void setFlag(flags_t flag) { flags |= flag; }
177 void setFlag(Flag flag) { flags |=
static_cast<flags_t
>(flag); }
178 void unsetFlag(flags_t flag) { flags &= (~flag); }
179 void unsetFlag(Flag flag) { flags &= ~(
static_cast<flags_t
>(flag)); }
180 bool getFlag(flags_t flag) {
return flags & flag; }
181 bool getFlag(Flag flag) {
return flags &
static_cast<flags_t
>(flag); }
183 void clearAllFlags() { flags = 0; }
184 flags_t getAllFlags() {
return flags; }
186 std::string getFlagString()
189 std::ostringstream str;
191 if ( getNoncacheable() ) {
192 str <<
"F_NONCACHEABLE";
195 if ( getSuccess() ) {
196 if ( comma ) { str <<
","; }
203 if ( comma ) { str <<
","; }
209 for (
unsigned int i = 4; i <
sizeof(flags_t); i++ ) {
210 flags_t shift = 1 << i;
211 if ( getFlag(shift) ) {
212 if ( comma ) { str <<
","; }
227 static std::atomic<id_t> main_id;
240 class StoreConditional;
253 Read(Addr physAddr, uint64_t size, flags_t flags = 0, Addr virtAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
269 std::vector<uint8_t> datavec(
275 bool needsResponse()
override {
return true; }
277 SST::Event* convert(RequestConverter* converter)
override {
return converter->convert(
this); }
279 void handle(RequestHandler* handler)
override {
return handler->handle(
this); }
281 std::string getString()
override
283 std::ostringstream str;
284 str <<
"ID: " <<
id <<
", Type: Read, Flags: [" << getFlagString() <<
"] PhysAddr: 0x" << std::hex << pAddr
285 <<
", VirtAddr: 0x" << vAddr;
286 str <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec
304 id_t rid, Addr physAddr, uint64_t size, std::vector<uint8_t> respData, flags_t flags = 0, Addr virtAddr = 0,
305 Addr instPtr = 0, uint32_t tid = 0) :
316 Request(readEv->getID(), readEv->getAllFlags()),
317 pAddr(readEv->pAddr),
318 vAddr(readEv->vAddr),
327 Request* makeResponse()
override {
return nullptr; }
329 bool needsResponse()
override {
return false; }
333 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
335 std::string getString()
override
337 std::ostringstream str;
338 str <<
"ID: " <<
id <<
", Type: ReadResp, Flags: [" << getFlagString() <<
"] PhysAddr: 0x" << std::hex
340 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr;
341 str <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x" << std::hex;
342 str << std::setfill(
'0');
343 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
344 str << std::setw(2) << static_cast<unsigned>(*it);
353 std::vector<uint8_t> data;
367 Addr physAddr, uint64_t size, std::vector<uint8_t> wData,
bool posted =
false, flags_t flags = 0,
368 Addr virtAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
381 virtual Request* makeResponse()
override {
return new WriteResp(
this); }
383 virtual bool needsResponse()
override {
return !posted; }
387 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
389 std::string getString()
override
391 std::ostringstream str;
392 str <<
"ID: " <<
id <<
", Type: Write, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
394 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", Posted: " << (posted ?
"T" :
"F");
395 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x"
397 str << std::setfill(
'0');
398 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
399 str << std::setw(2) << static_cast<unsigned>(*it);
408 std::vector<uint8_t> data;
420 id_t
id, Addr physAddr, uint64_t size, flags_t flags = 0, Addr virtAddr = 0, Addr instPtr = 0,
431 Request(wr->getID(), wr->getAllFlags()),
441 virtual Request* makeResponse()
override {
return nullptr; }
443 virtual bool needsResponse()
override {
return false; }
445 SST::Event* convert(RequestConverter* converter)
override {
return converter->convert(
this); }
447 void handle(RequestHandler* handler)
override {
return handler->handle(
this); }
449 std::string getString()
override
451 std::ostringstream str;
452 str <<
"ID:" <<
id <<
", Type: WriteResp, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
454 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr;
455 str <<
", ThreadID: " << std::dec << tid;
476 Addr physAddr, uint64_t size,
bool inv, uint32_t depth, flags_t flags = 0, Addr virtAddr = 0,
477 Addr instPtr = 0, uint32_t tid = 0) :
489 virtual Request* makeResponse()
override {
return new FlushResp(
this); }
491 virtual bool needsResponse()
override {
return true; }
495 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
497 std::string getString()
override
499 std::ostringstream str;
500 str <<
"ID:" <<
id <<
", Type: FlushAddr, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
502 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", Inv: " << (inv ?
"T" :
"F");
503 str <<
", Depth: " << depth <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
524 id_t
id, Addr physAddr, uint64_t size, flags_t flags = static_cast<int>(Request::Flag::F_SUCCESS),
525 Addr vAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
533 FlushResp(
FlushAddr* fl, flags_t newFlags = static_cast<int>(Request::Flag::F_SUCCESS)) :
534 Request(fl->getID(), fl->getAllFlags() | newFlags),
543 virtual Request* makeResponse()
override {
return nullptr; }
545 virtual bool needsResponse()
override {
return false; }
549 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
551 std::string getString()
override
553 std::ostringstream str;
554 str <<
"ID:" <<
id <<
", Type: FlushResp, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
556 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size;
557 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
580 Addr physAddr, uint64_t size, flags_t flags = 0, Addr virtAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
590 Request* makeResponse()
override
592 std::vector<uint8_t> datavec(size, 0);
594 return new ReadResp(
id, pAddr, size, datavec, flags, vAddr, iPtr, tid);
597 bool needsResponse()
override {
return true; }
601 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
603 std::string getString()
override
605 std::ostringstream str;
606 str <<
"ID: " <<
id <<
", Type: ReadLock, Flags: [" << getFlagString() <<
"] PhysAddr: 0x" << std::hex
607 << pAddr <<
", VirtAddr: 0x" << vAddr;
608 str <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec
629 Addr physAddr, uint64_t size, std::vector<uint8_t> wData,
bool posted =
false, flags_t flags = 0,
630 Addr virtAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
643 virtual Request* makeResponse()
override {
return new WriteResp(
id, pAddr, size, flags, vAddr = 0, iPtr, tid); }
645 virtual bool needsResponse()
override {
return !posted; }
649 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
651 std::string getString()
override
653 std::ostringstream str;
654 str <<
"ID: " <<
id <<
", Type: WriteUnlock, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
656 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size <<
", Posted: " << (posted ?
"T" :
"F");
657 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x"
659 str << std::setfill(
'0');
660 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
661 str << std::setw(2) << static_cast<unsigned>(*it);
670 std::vector<uint8_t> data;
688 Addr physAddr, uint64_t size, flags_t flags = 0, Addr virtAddr = 0, Addr instPtr = 0, uint32_t tid = 0) :
698 Request* makeResponse()
override
700 std::vector<uint8_t> datavec(size, 0);
702 return new ReadResp(
id, pAddr, size, datavec, flags, vAddr, iPtr, tid);
705 bool needsResponse()
override {
return true; }
709 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
711 std::string getString()
override
713 std::ostringstream str;
714 str <<
"ID: " <<
id <<
", Type: LoadLink, Flags: [" << getFlagString() <<
"] PhysAddr: 0x" << std::hex
715 << pAddr <<
", VirtAddr: 0x" << vAddr;
716 str <<
", Size: " << std::dec << size <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec
737 Addr physAddr, uint64_t size, std::vector<uint8_t> wData, flags_t flags = 0, Addr virtAddr = 0,
738 Addr instPtr = 0, uint32_t tid = 0) :
751 virtual Request* makeResponse()
override {
return new WriteResp(
id, pAddr, size, flags, vAddr, iPtr, tid); }
753 virtual bool needsResponse()
override {
return true; }
757 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
759 std::string getString()
override
761 std::ostringstream str;
762 str <<
"ID: " <<
id <<
", Type: StoreConditional, Flags: [" << getFlagString() <<
"], PhysAddr: 0x"
763 << std::hex << pAddr;
764 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size;
765 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid <<
", Payload: 0x"
767 str << std::setfill(
'0');
768 for ( std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); it++ ) {
769 str << std::setw(2) << static_cast<unsigned>(*it);
778 std::vector<uint8_t> data;
791 Addr pSrc, Addr pDst, uint64_t size,
bool posted =
false, flags_t flags = 0, Addr vSrc = 0, Addr vDst = 0,
792 Addr iPtr = 0, uint32_t tid = 0) :
805 virtual Request* makeResponse()
override {
return new WriteResp(
id, pDst, size, flags, vDst, iPtr, tid); }
807 virtual bool needsResponse()
override {
return posted; }
811 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
813 std::string getString()
override
815 std::ostringstream str;
816 str <<
"ID: " <<
id <<
", Type: MoveData, Flags: [" << getFlagString() <<
"], SrcPhysAddr: 0x" << std::hex
818 str <<
", SrcVirtAddr: 0x" << vSrc <<
", DstPhysAddr: 0x" << pDst <<
", DstVirtAddr: 0x" << vDst;
819 str <<
", Size: " << std::dec << size <<
", Posted: " << (posted ?
"T" :
"F");
820 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
840 InvNotify(Addr pAddr, uint64_t size, flags_t flags = 0, Addr vAddr = 0, Addr iPtr = 0, uint32_t tid = 0) :
850 virtual Request* makeResponse()
override {
return nullptr; }
852 virtual bool needsResponse()
override {
return false; }
856 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
858 std::string getString()
override
860 std::ostringstream str;
861 str <<
"ID: " <<
id <<
", Type: InvNotify, Flags: [" << getFlagString() <<
"], PhysAddr: 0x" << std::hex
863 str <<
", VirtAddr: 0x" << vAddr <<
", Size: " << std::dec << size;
864 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
883 virtual Addr getRoutingAddress() = 0;
884 virtual uint64_t getSize() = 0;
886 virtual bool needsResponse() = 0;
887 virtual std::string getString() = 0;
906 virtual Request* makeResponse()
override {
return new CustomResp(
this); }
908 virtual bool needsResponse()
override {
return data->needsResponse(); }
912 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
914 std::string getString()
override
916 std::ostringstream str;
917 str <<
"ID: " <<
id <<
", Type: CustomReq, Flags: [" << getFlagString() <<
"], " << data->getString();
918 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
937 Request(req->getID(), req->getAllFlags()),
938 data(req->data->makeResponse()),
944 virtual Request* makeResponse()
override {
return nullptr; }
946 virtual bool needsResponse()
override {
return false; }
950 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
952 std::string getString()
override
954 std::ostringstream str;
955 str <<
"ID: " <<
id <<
", Type: CustomResp, Flags: [" << getFlagString() <<
"], " << data->getString();
956 str <<
", InstPtr: 0x" << std::hex << iPtr <<
", ThreadID: " << std::dec << tid;
997 virtual void handle(
Read* UNUSED(request))
999 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for Read requests is not implemented\n");
1001 virtual void handle(
ReadResp* UNUSED(request))
1003 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for ReadResp requests is not implemented\n");
1005 virtual void handle(
Write* UNUSED(request))
1007 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for Write requests is not implemented\n");
1009 virtual void handle(
WriteResp* UNUSED(request))
1011 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for WriteResp requests is not implemented\n");
1013 virtual void handle(
FlushAddr* UNUSED(request))
1015 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for FlushAddr requests is not implemented\n");
1017 virtual void handle(
FlushResp* UNUSED(request))
1019 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for FlushResp requests is not implemented\n");
1021 virtual void handle(
ReadLock* UNUSED(request))
1023 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for ReadLock requests is not implemented\n");
1027 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for WriteUnlock requests is not implemented\n");
1029 virtual void handle(
LoadLink* UNUSED(request))
1031 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for LoadLink requests is not implemented\n");
1035 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for StoreConditional requests is not implemented\n");
1037 virtual void handle(
MoveData* UNUSED(request))
1039 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for MoveData requests is not implemented\n");
1041 virtual void handle(
CustomReq* UNUSED(request))
1043 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for CustomReq requests is not implemented\n");
1045 virtual void handle(
CustomResp* UNUSED(request))
1047 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for CustomResp requests is not implemented\n");
1049 virtual void handle(
InvNotify* UNUSED(request))
1051 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for InvNotify requests is not implemented\n");
1090 virtual void send(Request* req) = 0;
1102 virtual Request*
poll(
void) = 0;
1134 #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
Base class for StandardMem commands.
Definition: stdMem.h:120
Definition: ssthandler.h:100
WriteResp(Write *wr)
Automatically construct a write response from a Write.
Definition: stdMem.h:430
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
virtual void sendUntimedData(Request *req)=0
Sends a memory-based request during the init()/complete() phases.
uint64_t Addr
All Addresses can be 64-bit.
Definition: stdMem.h:110
Move: move data from one address to another Returns a WriteResp.
Definition: stdMem.h:787
Flag
Flags that modify requests.
Definition: stdMem.h:131
Definition: serializable.h:118
virtual void send(Request *req)=0
Send a Request through the interface.
Generic interface to Memory models.
Definition: stdMem.h:79
virtual Request * recvUntimedData()=0
Receive any data during the init()/complete() phases.
virtual Addr getLineSize()=0
Get cache/memory line size from the memory system.
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
Notifies endpoint that an address has been invalidated from the L1.
Definition: stdMem.h:837
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:1064
Request * makeResponse() override
Create read response.
Definition: stdMem.h:267
Locked atomic update -> guaranteed success A ReadLock must be followed by a WriteUnlock.
Definition: stdMem.h:576
Response to a flush request.
Definition: stdMem.h:520
Conditional atomic update.
Definition: stdMem.h:684
Parameter store.
Definition: params.h:43
virtual ~WriteResp()
Destructor.
Definition: stdMem.h:439
Base class for Events - Items sent across links to communicate between components.
Definition: event.h:31
Response to a Read.
Definition: stdMem.h:300
Response to a Write.
Definition: stdMem.h:415
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:28
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:419
Request to write data.
Definition: stdMem.h:362
virtual Request * poll(void)=0
Receive a Request response from the side of the link.
Read request.
Definition: stdMem.h:250