Tuan Ta has uploaded this change for review. (
https://gem5-review.googlesource.com/3161
Change subject: tests: refactor protocol-tester
......................................................................
tests: refactor protocol-tester
Change-Id: Ie8d20e8cc2aa0de8ac4b3e652da2c1cbc2c63a4a
---
M src/cpu/testers/protocol-tester/AddressManager.hh
M src/cpu/testers/protocol-tester/CpuThread.cc
M src/cpu/testers/protocol-tester/CpuThread.hh
M src/cpu/testers/protocol-tester/Episode.cc
M src/cpu/testers/protocol-tester/Episode.hh
M src/cpu/testers/protocol-tester/GpuWavefront.cc
M src/cpu/testers/protocol-tester/GpuWavefront.hh
R src/cpu/testers/protocol-tester/ProtocolTester.cc
R src/cpu/testers/protocol-tester/ProtocolTester.hh
R src/cpu/testers/protocol-tester/ProtocolTester.py
M src/cpu/testers/protocol-tester/SConscript
M src/cpu/testers/protocol-tester/Thread.cc
M src/cpu/testers/protocol-tester/Thread.hh
13 files changed, 84 insertions(+), 74 deletions(-)
diff --git a/src/cpu/testers/protocol-tester/AddressManager.hh
b/src/cpu/testers/protocol-tester/AddressManager.hh
index 78d94f2..a4e5095 100644
--- a/src/cpu/testers/protocol-tester/AddressManager.hh
+++ b/src/cpu/testers/protocol-tester/AddressManager.hh
@@ -37,6 +37,7 @@
#define CPU_TESTERS_PROTOCOL_TESTER_ADDRESSMANAGER_HH_
#include <map>
+#include <set>
#include <utility>
#include <vector>
diff --git a/src/cpu/testers/protocol-tester/CpuThread.cc
b/src/cpu/testers/protocol-tester/CpuThread.cc
index aed3017..2662776 100644
--- a/src/cpu/testers/protocol-tester/CpuThread.cc
+++ b/src/cpu/testers/protocol-tester/CpuThread.cc
@@ -35,7 +35,6 @@
#include "cpu/testers/protocol-tester/CpuThread.hh"
-#include "cpu/testers/protocol-tester/Episode.hh"
#include "debug/ProtocolTest.hh"
CpuThread::CpuThread(const Params *p)
diff --git a/src/cpu/testers/protocol-tester/CpuThread.hh
b/src/cpu/testers/protocol-tester/CpuThread.hh
index 8df7f03..f77997c 100644
--- a/src/cpu/testers/protocol-tester/CpuThread.hh
+++ b/src/cpu/testers/protocol-tester/CpuThread.hh
@@ -36,8 +36,6 @@
#ifndef CPU_TESTERS_PROTOCOL_TESTER_CPUTHREAD_HH_
#define CPU_TESTERS_PROTOCOL_TESTER_CPUTHREAD_HH_
-#include "cpu/testers/protocol-tester/Episode.hh"
-#include "cpu/testers/protocol-tester/Tester.hh"
#include "cpu/testers/protocol-tester/Thread.hh"
#include "params/CpuThread.hh"
#include "sim/clocked_object.hh"
diff --git a/src/cpu/testers/protocol-tester/Episode.cc
b/src/cpu/testers/protocol-tester/Episode.cc
index 2534544..c45a002 100644
--- a/src/cpu/testers/protocol-tester/Episode.cc
+++ b/src/cpu/testers/protocol-tester/Episode.cc
@@ -38,9 +38,10 @@
#include <fstream>
#include <set>
+#include "cpu/testers/protocol-tester/ProtocolTester.hh"
#include "cpu/testers/protocol-tester/Thread.hh"
-Episode::Episode(Tester* _tester, Thread* _thread, int num_loads,
+Episode::Episode(ProtocolTester* _tester, Thread* _thread, int num_loads,
int num_stores)
: m_tester(_tester),
m_thread(_thread),
@@ -392,12 +393,14 @@
}
bool
-Episode::Action::isAtomicAction() const {
+Episode::Action::isAtomicAction() const
+{
return (m_type == Type::ATOMIC_ACQUIRE || m_type ==
Type::ATOMIC_RELEASE);
}
const std::string
-Episode::Action::printType() const {
+Episode::Action::printType() const
+{
if (m_type == Type::ATOMIC_ACQUIRE)
return "ATOMIC_ACQUIRE";
else if (m_type == Type::ATOMIC_RELEASE)
diff --git a/src/cpu/testers/protocol-tester/Episode.hh
b/src/cpu/testers/protocol-tester/Episode.hh
index bb67b6b..dcc5487 100644
--- a/src/cpu/testers/protocol-tester/Episode.hh
+++ b/src/cpu/testers/protocol-tester/Episode.hh
@@ -39,8 +39,8 @@
#include <vector>
#include "cpu/testers/protocol-tester/AddressManager.hh"
-#include "cpu/testers/protocol-tester/Tester.hh"
+class ProtocolTester;
class Thread;
class Episode
@@ -71,7 +71,8 @@
LocationList m_locs;
};
- Episode(Tester *tester, Thread* thread, int num_loads, int num_stores);
+ Episode(ProtocolTester* tester, Thread* thread, int num_loads,
+ int num_stores);
~Episode();
// return episode id
@@ -100,7 +101,7 @@
private:
// pointers to tester, thread and address amanger structures
- Tester *m_tester;
+ ProtocolTester *m_tester;
Thread *m_thread;
AddressManager *m_addrManager;
diff --git a/src/cpu/testers/protocol-tester/GpuWavefront.cc
b/src/cpu/testers/protocol-tester/GpuWavefront.cc
index ddf4c2f..1b4fd6c 100644
--- a/src/cpu/testers/protocol-tester/GpuWavefront.cc
+++ b/src/cpu/testers/protocol-tester/GpuWavefront.cc
@@ -35,7 +35,6 @@
#include "cpu/testers/protocol-tester/GpuWavefront.hh"
-#include "cpu/testers/protocol-tester/Episode.hh"
#include "debug/ProtocolTest.hh"
GpuWavefront::GpuWavefront(const Params *p)
diff --git a/src/cpu/testers/protocol-tester/GpuWavefront.hh
b/src/cpu/testers/protocol-tester/GpuWavefront.hh
index 85386cb..0324cfe 100644
--- a/src/cpu/testers/protocol-tester/GpuWavefront.hh
+++ b/src/cpu/testers/protocol-tester/GpuWavefront.hh
@@ -36,8 +36,6 @@
#ifndef CPU_TESTERS_PROTOCOL_TESTER_GPUWAVEFRONT_HH_
#define CPU_TESTERS_PROTOCOL_TESTER_GPUWAVEFRONT_HH_
-#include "cpu/testers/protocol-tester/Episode.hh"
-#include "cpu/testers/protocol-tester/Tester.hh"
#include "cpu/testers/protocol-tester/Thread.hh"
#include "params/GpuWavefront.hh"
#include "sim/clocked_object.hh"
diff --git a/src/cpu/testers/protocol-tester/Tester.cc
b/src/cpu/testers/protocol-tester/ProtocolTester.cc
similarity index 87%
rename from src/cpu/testers/protocol-tester/Tester.cc
rename to src/cpu/testers/protocol-tester/ProtocolTester.cc
index 57fa7ac..d204b0e 100644
--- a/src/cpu/testers/protocol-tester/Tester.cc
+++ b/src/cpu/testers/protocol-tester/ProtocolTester.cc
@@ -33,22 +33,21 @@
* Authors: Tuan Ta
*/
-#include "cpu/testers/protocol-tester/Tester.hh"
+#include "cpu/testers/protocol-tester/ProtocolTester.hh"
#include <algorithm>
#include <fstream>
#include <random>
-#include "cpu/testers/protocol-tester/AddressManager.hh"
#include "cpu/testers/protocol-tester/CpuThread.hh"
-#include "cpu/testers/protocol-tester/Episode.hh"
#include "cpu/testers/protocol-tester/GpuWavefront.hh"
+#include "cpu/testers/protocol-tester/Thread.hh"
#include "debug/ProtocolTest.hh"
#include "mem/request.hh"
#include "sim/sim_exit.hh"
#include "sim/system.hh"
-Tester::Tester(const Params *p)
+ProtocolTester::ProtocolTester(const Params *p)
: MemObject(p),
_masterId(p->system->getMasterId(name())),
m_num_cpu_ports(p->port_cpu_ports_connection_count),
@@ -118,7 +117,7 @@
warn("Data race check is not enabled\n");
}
-Tester::~Tester()
+ProtocolTester::~ProtocolTester()
{
for (int i = 0; i < cpuPorts.size(); ++i)
delete cpuPorts[i];
@@ -132,7 +131,7 @@
}
void
-Tester::init()
+ProtocolTester::init()
{
DPRINTF(ProtocolTest, "Attach threads to ports\n");
@@ -167,7 +166,7 @@
}
BaseMasterPort &
-Tester::getMasterPort(const std::string & if_name, PortID idx)
+ProtocolTester::getMasterPort(const std::string & if_name, PortID idx)
{
if (if_name != "cpu_ports" && if_name != "cu_vector_ports" &&
if_name != "cu_sqc_ports" && if_name != "cu_scalar_ports") {
@@ -176,23 +175,23 @@
} else {
if (if_name == "cpu_ports") {
if (idx > m_num_cpu_ports)
- panic("Tester::getMasterPort: unknown cpu port %d\n", idx);
+ panic("ProtocolTester: unknown cpu port %d\n", idx);
return *cpuPorts[idx];
} else if (if_name == "cu_vector_ports") {
if (idx > m_num_vector_ports)
- panic("Tester::getMasterPort: unknown cu vect port %d\n",
idx);
+ panic("ProtocolTester: unknown cu vect port %d\n", idx);
return *cuVectorPorts[idx];
} else if (if_name == "cu_sqc_ports"){
if (idx > m_num_sqc_ports)
- panic("Tester::getMasterPort: unknown cu sqc port %d\n",
idx);
+ panic("ProtocolTester: unknown cu sqc port %d\n", idx);
return *cuSqcPorts[idx];
} else {
assert(if_name == "cu_scalar_ports");
if (idx > m_num_scalar_ports)
- panic("Tester::getMasterPort: unknown cu scal port %d\n",
idx);
+ panic("ProtocolTester: unknown cu scal port %d\n", idx);
return *cuScalarPorts[idx];
}
@@ -202,11 +201,12 @@
}
bool
-Tester::checkExit() const {
+ProtocolTester::checkExit() const
+{
if (m_next_episode_id > m_max_num_episodes) {
// all done
- inform(" Tester completed %i episodes\n", m_next_episode_id);
- exitSimLoop(" Tester completed!");
+ inform(" ProtocolTester completed %i episodes\n",
m_next_episode_id);
+ exitSimLoop(" ProtocolTester completed!");
return true;
}
@@ -214,7 +214,9 @@
}
bool
-Tester::checkDRF(Location atomic_loc, Location loc, bool isStore) const {
+ProtocolTester::checkDRF(Location atomic_loc,
+ Location loc, bool isStore) const
+{
if (m_debug_tester){
// go through all active episodes in all threads
for (const Thread* th : m_wfs) {
@@ -232,8 +234,8 @@
}
void
-Tester::dumpLogFile(int episode_id, int thread_id, int lane, Location loc,
- ErrorCode err) const
+ProtocolTester::dumpLogFile(int episode_id, int thread_id, int lane,
+ Location loc, ErrorCode err) const
{
// open a log file
std::ofstream outfile;
@@ -278,10 +280,10 @@
}
bool
-Tester::SeqPort::recvTimingResp(PacketPtr pkt)
+ProtocolTester::SeqPort::recvTimingResp(PacketPtr pkt)
{
- Tester::SenderState* senderState = safe_cast<Tester::SenderState*>
- (pkt->senderState);
+ ProtocolTester::SenderState* senderState =
+
safe_cast<ProtocolTester::SenderState*>(pkt->senderState);
Thread *th = senderState->th;
// pop the sender state from the packet
@@ -297,7 +299,8 @@
return true;
}
-Tester*
-TesterParams::create(){
- return new Tester(this);
+ProtocolTester*
+ProtocolTesterParams::create()
+{
+ return new ProtocolTester(this);
}
diff --git a/src/cpu/testers/protocol-tester/Tester.hh
b/src/cpu/testers/protocol-tester/ProtocolTester.hh
similarity index 90%
rename from src/cpu/testers/protocol-tester/Tester.hh
rename to src/cpu/testers/protocol-tester/ProtocolTester.hh
index 1dfd17f..b4653a8 100644
--- a/src/cpu/testers/protocol-tester/Tester.hh
+++ b/src/cpu/testers/protocol-tester/ProtocolTester.hh
@@ -33,11 +33,11 @@
* Authors: Tuan Ta
*/
-#ifndef CPU_TESTERS_PROTOCOL_TESTER_TESTER_HH_
-#define CPU_TESTERS_PROTOCOL_TESTER_TESTER_HH_
+#ifndef CPU_TESTERS_PROTOCOL_TESTER_PROTOCOLTESTER_HH_
+#define CPU_TESTERS_PROTOCOL_TESTER_PROTOCOLTESTER_HH_
/*
- * The tester includes the main Tester that manages all ports to the
+ * The tester includes the main ProtocolTester that manages all ports to
the
* memory system.
* Threads are mapped to certain data port(s)
*
@@ -57,23 +57,23 @@
#include <vector>
#include "base/types.hh"
+#include "cpu/testers/protocol-tester/AddressManager.hh"
#include "mem/mem_object.hh"
#include "mem/packet.hh"
#include "mem/ruby/system/RubyPort.hh"
-#include "params/Tester.hh"
+#include "params/ProtocolTester.hh"
-class Episode;
class Thread;
class CpuThread;
class GpuWavefront;
-class Tester : public MemObject
+class ProtocolTester : public MemObject
{
public:
class SeqPort : public MasterPort
{
public:
- SeqPort(const std::string &_name, Tester *_tester, PortID _id,
+ SeqPort(const std::string &_name, ProtocolTester *_tester, PortID
_id,
PortID _index)
: MasterPort(_name, _tester, _id)
{}
@@ -104,9 +104,9 @@
};
public:
- typedef TesterParams Params;
- Tester(const Params *p);
- ~Tester();
+ typedef ProtocolTesterParams Params;
+ ProtocolTester(const Params *p);
+ ~ProtocolTester();
void init();
MasterID masterId() { return _masterId; };
@@ -170,4 +170,4 @@
int m_next_episode_id;
};
-#endif /* CPU_TESTERS_PROTOCOL_TESTER_TESTER_HH_ */
+#endif /* CPU_TESTERS_PROTOCOL_TESTER_PROTOCOLTESTER_HH_ */
diff --git a/src/cpu/testers/protocol-tester/Tester.py
b/src/cpu/testers/protocol-tester/ProtocolTester.py
similarity index 95%
rename from src/cpu/testers/protocol-tester/Tester.py
rename to src/cpu/testers/protocol-tester/ProtocolTester.py
index d7330aa..1d0bb9d 100644
--- a/src/cpu/testers/protocol-tester/Tester.py
+++ b/src/cpu/testers/protocol-tester/ProtocolTester.py
@@ -37,9 +37,9 @@
from m5.params import *
from m5.proxy import *
-class Tester(MemObject):
- type = 'Tester'
- cxx_header = "cpu/testers/protocol-tester/Tester.hh"
+class ProtocolTester(MemObject):
+ type = 'ProtocolTester'
+ cxx_header = "cpu/testers/protocol-tester/ProtocolTester.hh"
cpu_ports = VectorMasterPort("Ports for CPUs")
cu_vector_ports = VectorMasterPort("Vector ports for GPUs")
diff --git a/src/cpu/testers/protocol-tester/SConscript
b/src/cpu/testers/protocol-tester/SConscript
index cbad6d0..6e7a815 100644
--- a/src/cpu/testers/protocol-tester/SConscript
+++ b/src/cpu/testers/protocol-tester/SConscript
@@ -38,14 +38,14 @@
if env['PROTOCOL'] == 'None':
Return()
-SimObject('Tester.py')
+SimObject('ProtocolTester.py')
SimObject('Thread.py')
SimObject('CpuThread.py')
SimObject('GpuWavefront.py')
Source('AddressManager.cc')
Source('Episode.cc')
-Source('Tester.cc')
+Source('ProtocolTester.cc')
Source('Thread.cc')
Source('CpuThread.cc')
Source('GpuWavefront.cc')
diff --git a/src/cpu/testers/protocol-tester/Thread.cc
b/src/cpu/testers/protocol-tester/Thread.cc
index 25fd0bb..32172f1 100644
--- a/src/cpu/testers/protocol-tester/Thread.cc
+++ b/src/cpu/testers/protocol-tester/Thread.cc
@@ -144,13 +144,15 @@
panic("The tester got into an invalid action type\n");
}
} else if (m_state == ThreadState::TH_STATE_ATOMIC_ACQ) {
- assert(m_curAction->getType() == Episode::Action::ATOMIC_ACQUIRE);
+ assert(m_curAction->getType() ==
+ Episode::Action::Type::ATOMIC_ACQUIRE);
issueAcquireOp();
assert(m_outstanding_reqs == 1);
m_state = ThreadState::TH_STATE_ACQ_IDLE;
} else if (m_state == ThreadState::TH_STATE_REL_ATOMIC) {
- assert(m_curAction->getType() == Episode::Action::ATOMIC_RELEASE);
+ assert(m_curAction->getType() ==
+ Episode::Action::Type::ATOMIC_RELEASE);
issueAtomicOps();
assert(m_outstanding_reqs == m_num_lanes);
@@ -169,10 +171,10 @@
}
void
-Thread::attachThreadToPorts(Tester *tester,
- Tester::SeqPort *port,
- Tester::SeqPort *scalar_port,
- Tester::SeqPort *sqc_port)
+Thread::attachThreadToPorts(ProtocolTester *tester,
+ ProtocolTester::SeqPort *port,
+ ProtocolTester::SeqPort *scalar_port,
+ ProtocolTester::SeqPort *sqc_port)
{
m_tester = tester;
m_port = port;
@@ -240,7 +242,8 @@
uint8_t* data = new uint8_t[load_size];
pkt->dataDynamic(data);
- pkt->senderState = new Tester::SenderState(this,
pkt->senderState);
+ pkt->senderState =
+ new ProtocolTester::SenderState(this,
pkt->senderState);
if (!m_port->sendTimingReq(pkt)) {
panic("Not expected failed sendTimingReq\n");
@@ -306,7 +309,8 @@
writeData[j] = ((uint8_t*)&new_value)[j];
}
pkt->dataDynamic(writeData);
- pkt->senderState = new Tester::SenderState(this,
pkt->senderState);
+ pkt->senderState =
+ new ProtocolTester::SenderState(this,
pkt->senderState);
if (!m_port->sendTimingReq(pkt)){
panic("Not expecting a failed sendTimingReq\n");
@@ -358,7 +362,8 @@
PacketPtr pkt = new Packet(req, MemCmd::SwapReq);
uint8_t* data = new uint8_t[sizeof(Value)];
pkt->dataDynamic(data);
- pkt->senderState = new Tester::SenderState(this, pkt->senderState);
+ pkt->senderState =
+ new ProtocolTester::SenderState(this,
pkt->senderState);
if (!m_port->sendTimingReq(pkt)){
panic("Not expecting failed sendTimingReq\n");
@@ -392,7 +397,7 @@
Request::SYSTEM_SCOPE);
PacketPtr pkt = new Packet(acq_req, MemCmd::MemFenceReq);
- pkt->senderState = new Tester::SenderState(this, pkt->senderState);
+ pkt->senderState = new ProtocolTester::SenderState(this,
pkt->senderState);
if (!m_port->sendTimingReq(pkt)) {
panic("Not expecting failed sendTimingReq\n");
@@ -424,7 +429,7 @@
Request::SYSTEM_SCOPE);
PacketPtr pkt = new Packet(rel_req, MemCmd::MemFenceReq);
- pkt->senderState = new Tester::SenderState(this, pkt->senderState);
+ pkt->senderState = new ProtocolTester::SenderState(this,
pkt->senderState);
if (!m_port->sendTimingReq(pkt)) {
panic("Not expecting failed sendTimingReq\n");
@@ -562,7 +567,8 @@
m_tester->dumpLogFile(m_curEpisode->getEpisodeId(),
m_thread_id,
resp.lane, resp.orig_loc,
- Tester::ErrorCode::INVALID_ATOMIC);
+ ProtocolTester::ErrorCode::
+
INVALID_ATOMIC);
}
}
resp_list.clear();
@@ -591,7 +597,8 @@
m_thread_id,
resp.lane,
resp.orig_loc,
- Tester::ErrorCode::INVALID_LD_ST);
+ ProtocolTester::ErrorCode::
+
INVALID_LD_ST);
} else if (last_st_value == INVALID_VALUE &&
resp.ret_value != m_addrManager->
@@ -601,7 +608,7 @@
m_thread_id,
resp.lane,
resp.orig_loc,
- Tester::ErrorCode::INVALID_LD);
+
ProtocolTester::ErrorCode::INVALID_LD);
}
}
resp_list.clear();
diff --git a/src/cpu/testers/protocol-tester/Thread.hh
b/src/cpu/testers/protocol-tester/Thread.hh
index c6156a6..e40fa71 100644
--- a/src/cpu/testers/protocol-tester/Thread.hh
+++ b/src/cpu/testers/protocol-tester/Thread.hh
@@ -40,8 +40,9 @@
#ifndef CPU_TESTERS_PROTOCOL_TESTER_THREAD_HH_
#define CPU_TESTERS_PROTOCOL_TESTER_THREAD_HH_
+#include "cpu/testers/protocol-tester/AddressManager.hh"
#include "cpu/testers/protocol-tester/Episode.hh"
-#include "cpu/testers/protocol-tester/Tester.hh"
+#include "cpu/testers/protocol-tester/ProtocolTester.hh"
#include "sim/clocked_object.hh"
class Thread : public ClockedObject
@@ -53,10 +54,10 @@
void wakeup();
void scheduleWakeup();
- void attachThreadToPorts(Tester *tester,
- Tester::SeqPort *port,
- Tester::SeqPort *sqc_port = nullptr,
- Tester::SeqPort *scalar_port = nullptr);
+ void attachThreadToPorts(ProtocolTester *tester,
+ ProtocolTester::SeqPort *port,
+ ProtocolTester::SeqPort *sqc_port = nullptr,
+ ProtocolTester::SeqPort *scalar_port =
nullptr);
void hitCallback(PacketPtr pkt);
int getThreadId() const { return m_thread_id; }
int getNumLanes() const { return m_num_lanes; }
@@ -134,15 +135,15 @@
// thread name
char* m_name;
// pointer to the main tester
- Tester *m_tester;
+ ProtocolTester *m_tester;
// pointer to the address manager
AddressManager* m_addrManager;
// current state of this thread
ThreadState m_state;
- Tester::SeqPort *m_port; // main data port (GPU - vector data)
- Tester::SeqPort *m_scalar_port;// nullptr for CPU
- Tester::SeqPort *m_sqc_port; // nullptr for CPU
+ ProtocolTester::SeqPort *m_port; // main data port (GPU-vector
data)
+ ProtocolTester::SeqPort *m_scalar_port;// nullptr for CPU
+ ProtocolTester::SeqPort *m_sqc_port; // nullptr for CPU
// a list of issued episodes sorted by time
// the last episode in the list is the current episode
--
To view, visit https://gem5-review.googlesource.com/3161
To unsubscribe, visit https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8d20e8cc2aa0de8ac4b3e652da2c1cbc2c63a4a
Gerrit-Change-Number: 3161
Gerrit-PatchSet: 1
Gerrit-Owner: Tuan Ta <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev