changeset 9d19bb965564 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=9d19bb965564
description:
ruby: make a RequestDesc class instead of std::pair
the RequestDesc was previously implemented as a std::pair, which made
the implementation overly complex and error prone. here we encapsulate
the
packet, primary, and secondary types all in a single data structure with
all members properly intialized in a ctor
diffstat:
src/mem/ruby/system/GPUCoalescer.cc | 28 ++++++++++++----------------
src/mem/ruby/system/GPUCoalescer.hh | 22 +++++++++++++++++++---
2 files changed, 31 insertions(+), 19 deletions(-)
diffs (129 lines):
diff -r 725fef71f376 -r 9d19bb965564 src/mem/ruby/system/GPUCoalescer.cc
--- a/src/mem/ruby/system/GPUCoalescer.cc Wed Oct 26 14:50:54 2016 -0400
+++ b/src/mem/ruby/system/GPUCoalescer.cc Wed Oct 26 22:46:58 2016 -0400
@@ -625,9 +625,8 @@
int len = reqCoalescer[request_line_address].size();
std::vector<PacketPtr> mylist;
for (int i = 0; i < len; ++i) {
- PacketPtr pkt = reqCoalescer[request_line_address][i].first;
- assert(type ==
- reqCoalescer[request_line_address][i].second[PrimaryType]);
+ PacketPtr pkt = reqCoalescer[request_line_address][i].pkt;
+ assert(type == reqCoalescer[request_line_address][i].primaryType);
request_address = pkt->getAddr();
request_line_address = makeLineAddress(pkt->getAddr());
if (pkt->getPtr<uint8_t>()) {
@@ -848,25 +847,22 @@
// let us see if we can coalesce this request with the previous
// requests from this cycle
} else if (primary_type !=
- reqCoalescer[line_addr][0].second[PrimaryType]) {
+ reqCoalescer[line_addr][0].primaryType) {
// can't coalesce loads, stores and atomics!
return RequestStatus_Aliased;
} else if (pkt->req->isLockedRMW() ||
- reqCoalescer[line_addr][0].first->req->isLockedRMW()) {
+ reqCoalescer[line_addr][0].pkt->req->isLockedRMW()) {
// can't coalesce locked accesses, but can coalesce atomics!
return RequestStatus_Aliased;
} else if (pkt->req->hasContextId() && pkt->req->isRelease() &&
pkt->req->contextId() !=
- reqCoalescer[line_addr][0].first->req->contextId()) {
+ reqCoalescer[line_addr][0].pkt->req->contextId()) {
// can't coalesce releases from different wavefronts
return RequestStatus_Aliased;
}
// in addition to the packet, we need to save both request types
- reqCoalescer[line_addr].push_back(
- RequestDesc(pkt, std::vector<RubyRequestType>()) );
- reqCoalescer[line_addr].back().second.push_back(primary_type);
- reqCoalescer[line_addr].back().second.push_back(secondary_type);
+ reqCoalescer[line_addr].emplace_back(pkt, primary_type, secondary_type);
if (!issueEvent.scheduled())
schedule(issueEvent, curTick());
// TODO: issue hardware prefetches here
@@ -910,7 +906,7 @@
std::vector< std::pair<int,AtomicOpFunctor*> > atomicOps;
uint32_t tableSize = reqCoalescer[line_addr].size();
for (int i = 0; i < tableSize; i++) {
- PacketPtr tmpPkt = reqCoalescer[line_addr][i].first;
+ PacketPtr tmpPkt = reqCoalescer[line_addr][i].pkt;
uint32_t tmpOffset = (tmpPkt->getAddr()) - line_addr;
uint32_t tmpSize = tmpPkt->getSize();
if (tmpPkt->isAtomicOp()) {
@@ -1020,12 +1016,12 @@
// can be coalesced with the first request. So, only
// one request is issued per cacheline.
RequestDesc info = reqCoalescer[newRequests[i]][0];
- PacketPtr pkt = info.first;
+ PacketPtr pkt = info.pkt;
DPRINTF(GPUCoalescer, "Completing for newReq %d: paddr %#x\n",
i, pkt->req->getPaddr());
// Insert this request to the read/writeRequestTables. These tables
// are used to track aliased requests in makeRequest subroutine
- bool found = insertRequest(pkt, info.second[PrimaryType]);
+ bool found = insertRequest(pkt, info.primaryType);
if (found) {
panic("GPUCoalescer::makeRequest should never be called if the "
@@ -1033,7 +1029,7 @@
}
// Issue request to ruby subsystem
- issueRequest(pkt, info.second[SecondaryType]);
+ issueRequest(pkt, info.secondaryType);
}
newRequests.clear();
@@ -1107,9 +1103,9 @@
int len = reqCoalescer[request_line_address].size();
std::vector<PacketPtr> mylist;
for (int i = 0; i < len; ++i) {
- PacketPtr pkt = reqCoalescer[request_line_address][i].first;
+ PacketPtr pkt = reqCoalescer[request_line_address][i].pkt;
assert(srequest->m_type ==
- reqCoalescer[request_line_address][i].second[PrimaryType]);
+ reqCoalescer[request_line_address][i].primaryType);
request_address = (pkt->getAddr());
request_line_address = makeLineAddress(request_address);
if (pkt->getPtr<uint8_t>() &&
diff -r 725fef71f376 -r 9d19bb965564 src/mem/ruby/system/GPUCoalescer.hh
--- a/src/mem/ruby/system/GPUCoalescer.hh Wed Oct 26 14:50:54 2016 -0400
+++ b/src/mem/ruby/system/GPUCoalescer.hh Wed Oct 26 22:46:58 2016 -0400
@@ -73,6 +73,24 @@
{}
};
+class RequestDesc
+{
+ public:
+ RequestDesc(PacketPtr pkt, RubyRequestType p_type, RubyRequestType s_type)
+ : pkt(pkt), primaryType(p_type), secondaryType(s_type)
+ {
+ }
+
+ RequestDesc() : pkt(nullptr), primaryType(RubyRequestType_NULL),
+ secondaryType(RubyRequestType_NULL)
+ {
+ }
+
+ PacketPtr pkt;
+ RubyRequestType primaryType;
+ RubyRequestType secondaryType;
+};
+
std::ostream& operator<<(std::ostream& out, const GPUCoalescerRequest& obj);
class GPUCoalescer : public RubyPort
@@ -271,9 +289,7 @@
// The secondary request type comprises a subset of RubyRequestTypes that
// are understood by the L1 Controller. A primary request type can be any
// RubyRequestType.
- enum {PrimaryType, SecondaryType};
- typedef std::pair<PacketPtr, std::vector<RubyRequestType> > RequestDesc;
- typedef std::unordered_map<Addr, std::vector<RequestDesc> >
CoalescingTable;
+ typedef std::unordered_map<Addr, std::vector<RequestDesc>> CoalescingTable;
CoalescingTable reqCoalescer;
std::vector<Addr> newRequests;
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev