14 #ifndef SST_CORE_INTERFACES_STANDARDMEM_H_
15 #define SST_CORE_INTERFACES_STANDARDMEM_H_
22 #include "sst/core/sst_types.h"
23 #include "sst/core/warnmacros.h"
24 #include "sst/core/subcomponent.h"
25 #include "sst/core/params.h"
26 #include "sst/core/link.h"
33 namespace Experimental {
43 namespace Interfaces {
87 typedef uint64_t
Addr;
94 typedef uint64_t id_t;
95 typedef uint32_t flags_t;
103 F_NONCACHEABLE = 1<<1,
106 F_RESERVED = 1 << 16,
109 Request(flags_t fl = 0) {
id = main_id++; flags = fl; }
110 Request(id_t rid, flags_t flags = 0) : id(rid), flags(flags) {}
112 virtual ~Request() {}
114 id_t getID() {
return id; }
116 virtual Request* makeResponse() = 0;
117 virtual bool needsResponse() = 0;
120 virtual SST::Event* convert(RequestConverter* converter) = 0;
122 virtual void handle(RequestHandler* handler) = 0;
125 void setNoncacheable() { flags |=
static_cast<int>(Flag::F_NONCACHEABLE); }
126 void unsetNoncacheable() { flags &= ~(
static_cast<int>(Flag::F_NONCACHEABLE)); }
127 bool getNoncacheable() {
return flags &
static_cast<int>(Flag::F_NONCACHEABLE); }
129 void setSuccess() { flags |=
static_cast<int>(Flag::F_SUCCESS); }
130 void unsetSuccess() { flags &= ~(
static_cast<int>(Flag::F_SUCCESS)); }
131 bool getSuccess() {
return flags &
static_cast<int>(Flag::F_SUCCESS); }
133 void setTrace() { flags |=
static_cast<int>(Flag::F_TRACE); }
134 void unsetTrace() { flags &= (~static_cast<
int>(Flag::F_TRACE)); }
135 bool getTrace() {
return flags &
static_cast<int>(Flag::F_TRACE); }
137 void setFlag(flags_t flag) { flags |= flag; }
138 void setFlag(Flag flag) { flags |=
static_cast<flags_t
>(flag); }
139 void unsetFlag(flags_t flag) { flags &= (~flag); }
140 void unsetFlag(Flag flag) { flags &= ~(
static_cast<flags_t
>(flag)); }
141 bool getFlag(flags_t flag) {
return flags & flag; }
142 bool getFlag(Flag flag) {
return flags &
static_cast<flags_t
>(flag); }
144 void clearAllFlags() { flags = 0; }
145 flags_t getAllFlags() {
return flags; }
152 static std::atomic<id_t> main_id;
165 class StoreConditional;
177 Read(
Addr physAddr, uint64_t size, flags_t flags = 0,
Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
178 Request(flags), pAddr(physAddr), vAddr(virtAddr), size(size), iPtr(instPtr), tid(tid) { }
186 std::vector<uint8_t> datavec(size, 0);
191 bool needsResponse()
override {
return true; }
193 SST::Event* convert(RequestConverter* converter)
override {
return converter->convert(
this); }
194 void handle(RequestHandler* handler)
override {
return handler->handle(
this); }
207 ReadResp(id_t rid,
Addr physAddr, uint64_t size, std::vector<uint8_t> respData, flags_t flags = 0,
Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
208 Request(rid, flags), pAddr(physAddr), vAddr(virtAddr), size(size), data(respData), iPtr(instPtr), tid(tid) { }
211 Request(readEv->getID(), readEv->getAllFlags()), pAddr(readEv->pAddr), vAddr(readEv->vAddr), size(readEv->size), data(respData),
212 iPtr(readEv->iPtr), tid(readEv->tid) { }
216 Request* makeResponse()
override {
return nullptr; }
217 bool needsResponse()
override {
return false; }
219 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
225 std::vector<uint8_t> data;
237 Write(
Addr physAddr, uint64_t size, std::vector<uint8_t> wData,
bool posted =
false, flags_t flags = 0,
238 Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
Request(flags), pAddr(physAddr), vAddr(virtAddr),
239 size(size), data(wData), posted(posted), iPtr(instPtr), tid(tid) {}
244 virtual bool needsResponse()
override {
return !posted; }
246 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
252 std::vector<uint8_t> data;
262 WriteResp(id_t
id,
Addr physAddr, uint64_t size, flags_t flags = 0,
Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
263 Request(id, flags), pAddr(physAddr), vAddr(virtAddr), size(size), iPtr(instPtr), tid(tid) {}
266 iPtr(wr->iPtr), tid(wr->tid) {}
270 virtual Request* makeResponse()
override {
return nullptr; }
271 virtual bool needsResponse()
override {
return false; }
272 SST::Event* convert(RequestConverter* converter)
override {
return converter->convert(
this); }
273 void handle(RequestHandler* handler)
override {
return handler->handle(
this); }
290 FlushAddr(
Addr physAddr, uint64_t size,
bool inv, uint32_t depth, flags_t flags = 0,
Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
291 Request(flags), pAddr(physAddr), vAddr(virtAddr), size(size), inv(inv), depth(depth), iPtr(instPtr), tid(tid) {}
295 virtual bool needsResponse()
override {
return true; }
297 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
313 FlushResp(id_t
id,
Addr physAddr, uint64_t size, flags_t flags = static_cast<int>(Request::Flag::F_SUCCESS),
314 Addr vAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
Request(
id, flags), pAddr(physAddr), vAddr(vAddr), size(size),
315 iPtr(instPtr), tid(tid) {}
316 FlushResp(
FlushAddr* fl, flags_t newFlags = static_cast<int>(Request::Flag::F_SUCCESS)) :
317 Request(fl->getID(), fl->getAllFlags() | newFlags), pAddr(fl->pAddr), vAddr(fl->vAddr), size(fl->size),
318 iPtr(fl->iPtr), tid(fl->tid) {}
321 virtual Request* makeResponse()
override {
return nullptr; }
322 virtual bool needsResponse()
override {
return false; }
324 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
343 ReadLock(
Addr physAddr, uint64_t size, flags_t flags = 0,
Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
344 Request(flags), pAddr(physAddr), vAddr(virtAddr), size(size), iPtr(instPtr), tid(tid) { }
347 Request* makeResponse()
override {
348 std::vector<uint8_t> datavec(size, 0);
349 return new ReadResp(
id, pAddr, size, datavec, flags, vAddr, iPtr, tid);
352 bool needsResponse()
override {
return true; }
354 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
370 WriteUnlock(
Addr physAddr, uint64_t size, std::vector<uint8_t> wData,
bool posted =
false, flags_t flags = 0,
371 Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
Request(flags), pAddr(physAddr), vAddr(virtAddr),
372 size(size), data(wData), posted(posted), iPtr(instPtr), tid(tid) {}
376 virtual Request* makeResponse()
override {
return new WriteResp(
id, pAddr, size, flags, vAddr = 0, iPtr, tid); }
377 virtual bool needsResponse()
override {
return !posted; }
379 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
385 std::vector<uint8_t> data;
401 LoadLink(
Addr physAddr, uint64_t size, flags_t flags = 0,
Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
402 Request(flags), pAddr(physAddr), vAddr(virtAddr), size(size), iPtr(instPtr), tid(tid) { }
405 Request* makeResponse()
override {
406 std::vector<uint8_t> datavec(size, 0);
407 return new ReadResp(
id, pAddr, size, datavec, flags, vAddr, iPtr, tid);
410 bool needsResponse()
override {
return true; }
412 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
429 Addr virtAddr = 0,
Addr instPtr = 0, uint32_t tid = 0) :
Request(flags), pAddr(physAddr), vAddr(virtAddr),
430 size(size), data(wData), iPtr(instPtr), tid(tid) {}
435 virtual Request* makeResponse()
override {
return new WriteResp(
id, pAddr, size, flags, vAddr, iPtr, tid); }
436 virtual bool needsResponse()
override {
return true; }
438 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
444 std::vector<uint8_t> data;
455 MoveData(
Addr pSrc,
Addr pDst, uint64_t size,
bool posted =
false, flags_t flags = 0,
Addr vSrc = 0,
Addr vDst = 0,
Addr iPtr = 0, uint32_t tid = 0) :
456 Request(flags), pSrc(pSrc), vSrc(vSrc), pDst(pDst), vDst(vDst), size(size), posted(posted), iPtr(iPtr), tid(tid) {}
459 virtual Request* makeResponse()
override {
return new WriteResp(
id, pDst, size, flags, vDst, iPtr, tid); }
460 virtual bool needsResponse()
override {
return posted; }
462 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
479 InvNotify(
Addr pAddr, uint64_t size, flags_t flags = 0,
Addr vAddr = 0,
Addr iPtr = 0, uint32_t tid = 0) :
480 Request(flags), pAddr(pAddr), vAddr(vAddr), size(size), iPtr(iPtr), tid(tid) {}
483 virtual Request* makeResponse()
override {
return nullptr; }
484 virtual bool needsResponse()
override {
return false; }
486 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
502 virtual Addr getRoutingAddress() = 0;
503 virtual uint64_t getSize() = 0;
505 virtual bool needsResponse() = 0;
517 Request(flags), data(data), iPtr(iPtr), tid(tid) {}
521 virtual bool needsResponse()
override {
return data->needsResponse(); }
523 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
533 Request(
id, flags), data(data), iPtr(iPtr), tid(tid) {}
535 iPtr(req->iPtr), tid(req->tid) {}
538 virtual Request* makeResponse()
override {
return nullptr; }
539 virtual bool needsResponse()
override {
return false; }
541 void handle(
RequestHandler* handler)
override {
return handler->handle(
this); }
578 virtual void handle(
Read* UNUSED(request)) {
579 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for Read requests is not implemented\n"); }
580 virtual void handle(
ReadResp* UNUSED(request)) {
581 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for ReadResp requests is not implemented\n"); }
582 virtual void handle(
Write* UNUSED(request)) {
583 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for Write requests is not implemented\n"); }
584 virtual void handle(
WriteResp* UNUSED(request)) {
585 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for WriteResp requests is not implemented\n"); }
586 virtual void handle(
FlushAddr* UNUSED(request)) {
587 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for FlushAddr requests is not implemented\n"); }
588 virtual void handle(
FlushResp* UNUSED(request)) {
589 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for FlushResp requests is not implemented\n"); }
590 virtual void handle(
ReadLock* UNUSED(request)) {
591 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for ReadLock requests is not implemented\n"); }
592 virtual void handle(
WriteUnlock* UNUSED(request)) {
593 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for WriteUnlock requests is not implemented\n"); }
594 virtual void handle(
LoadLink* UNUSED(request)) {
595 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for LoadLink requests is not implemented\n"); }
597 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for StoreConditional requests is not implemented\n"); }
598 virtual void handle(
MoveData* UNUSED(request)) {
599 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for MoveData requests is not implemented\n"); }
600 virtual void handle(
CustomReq* UNUSED(request)) {
601 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for CustomReq requests is not implemented\n"); }
602 virtual void handle(
CustomResp* UNUSED(request)) {
603 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for CustomResp requests is not implemented\n"); }
604 virtual void handle(
InvNotify* UNUSED(request)) {
605 out->
fatal(CALL_INFO, -1,
"Error: RequestHandler for InvNotify requests is not implemented\n"); }
623 template <
typename classT,
typename argT =
void>
626 typedef void (classT::*PtrMember)(
Request*, argT);
628 const PtrMember member;
637 Handler( classT*
const object, PtrMember member, argT data ) :
644 return (object->*member)(req,data);
651 template <
typename classT>
654 typedef void (classT::*PtrMember)(
Request*);
656 const PtrMember member;
663 Handler( classT*
const object, PtrMember member ) :
669 return (object->*member)(req);
705 virtual void send(Request *req) = 0;
717 virtual Request*
poll(
void) = 0;
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:54
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
Base class for StandardMem commands.
Definition: stdMem.h:92
WriteResp(Write *wr)
Automatically construct a write response from a Write.
Definition: stdMem.h:265
void operator()(Request *req)
Function called when Handler is invoked.
Definition: stdMem.h:668
A class to convert between a component's view of time and the core's view of time.
Definition: timeConverter.h:25
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:82
Move: move data from one address to another Returns a WriteResp.
Definition: stdMem.h:453
Flag
Flags that modify requests.
Definition: stdMem.h:102
void operator()(Request *req)
Function called when Handler is invoked.
Definition: stdMem.h:643
Definition: serializable.h:109
virtual void send(Request *req)=0
Send a Request through the interface.
Handler(classT *const object, PtrMember member, argT data)
Constructor.
Definition: stdMem.h:637
Generic interface to Memory models.
Definition: stdMem.h:78
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:477
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:680
Request * makeResponse() override
Create read response.
Definition: stdMem.h:185
Functor classes for Request handling.
Definition: stdMem.h:611
Locked atomic update -> guaranteed success A ReadLock must be followed by a WriteUnlock.
Definition: stdMem.h:341
Response to a flush request.
Definition: stdMem.h:311
Conditional atomic update.
Definition: stdMem.h:399
Handler(classT *const object, PtrMember member)
Constructor.
Definition: stdMem.h:663
Parameter store.
Definition: params.h:44
Event Handler class with user-data argument.
Definition: stdMem.h:624
virtual ~WriteResp()
Destructor.
Definition: stdMem.h:268
Base class for Events - Items sent across links to communicate between components.
Definition: event.h:31
Response to a Read.
Definition: stdMem.h:205
Response to a Write.
Definition: stdMem.h:259
virtual void operator()(Request *)=0
Function called when Handler is invoked.
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:29
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:262
Request to write data.
Definition: stdMem.h:234
virtual Request * poll(void)=0
Receive a Request response from the side of the link.
Read request.
Definition: stdMem.h:175