37#include "debug/ProtocolTest.hh"
44 threadEvent(this,
"TesterThread tick"),
45 deadlockCheckEvent(this),
46 threadId(
p.thread_id),
47 numLanes(
p.num_lanes),
48 tester(nullptr), addrManager(nullptr), port(nullptr),
49 scalarPort(nullptr), sqcPort(nullptr), curEpisode(nullptr),
50 curAction(nullptr), pendingLdStCount(0), pendingFenceCount(0),
51 pendingAtomicCount(0), lastActiveCycle(
Cycles(0)),
52 deadlockThreshold(
p.deadlock_threshold)
59 assert(
ep !=
nullptr);
148 int num_reg_loads = \
164 int tokens_needed = 0;
173 for (
int lane = 0; lane <
numLanes; ++lane) {
185 return tokens_needed;
198 bool haveTokens =
true;
251 for (
int lane = 0; lane <
numLanes; ++lane) {
284 panic(
"The tester got an invalid action\n");
318 panic(
"The tester got an invalid action\n");
336 OutstandingReqTable::iterator it = req_table.find(address);
339 if (it == req_table.end()) {
345 (it->second).push_back(req);
352 OutstandingReqTable::iterator it = req_table.find(
addr);
355 assert(it != req_table.end());
359 assert(!req_list.empty());
368 if (req_list.empty()) {
379 std::stringstream
ss;
383 ss <<
threadName <<
": Atomic Op returned unexpected value\n"
385 <<
"\tLane ID " << lane <<
"\n"
387 <<
"\tAtomic Op's return value " << ret_val <<
"\n";
403 std::stringstream
ss;
407 ss <<
threadName <<
": Loaded value is not consistent with "
408 <<
"the last stored value\n"
409 <<
"\tTesterThread " <<
threadId <<
"\n"
411 <<
"\tLane ID " << lane <<
"\n"
413 <<
"\tLoaded value " << ret_val <<
"\n"
442 std::stringstream
ss;
446 <<
"\tCurrent cycle: " <<
curCycle() <<
"\n"
464 std::stringstream&
ss)
const
468 for (
const auto&
m : table) {
469 for (
const auto& req :
m.second) {
471 <<
": delta (curCycle - issueCycle) = "
472 << (cur_cycle - req.issueCycle) << std::endl;
481 ss <<
"\t\tOutstanding Loads:\n";
483 ss <<
"\t\tOutstanding Stores:\n";
485 ss <<
"\t\tOutstanding Atomics:\n";
487 ss <<
"\t\tNumber of outstanding acquires & releases: "
Addr getAddress(Location loc)
Value getLoggedValue(Location loc) const
std::string printLastWriter(Location loc) const
static const int INVALID_LOCATION
bool validateAtomicResp(Location loc, Value ret_val)
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Tick nextCycle() const
Based on the clock of the object, determine the start tick of the first cycle that is at least one cy...
Cycles is a wrapper class for representing cycle counts, i.e.
Location getLocation(int lane) const
bool checkDRF(Location atomic_loc, Location loc, bool isStore, int max_lane) const
bool hasMoreActions() const
const Action * peekCurAction() const
int getEpisodeLength() const
AddressManager * getAddressManager() const
void dumpErrorLog(std::stringstream &ss)
TesterThread(const Params &p)
AddressManager * addrManager
AddressManager::Value Value
void attachTesterThreadToPorts(ProtocolTester *_tester, ProtocolTester::SeqPort *_port, ProtocolTester::GMTokenPort *_tokenPort=nullptr, ProtocolTester::SeqPort *_sqcPort=nullptr, ProtocolTester::SeqPort *_scalarPort=nullptr)
virtual void issueReleaseOp()=0
OutstandingReqTable outstandingAtomics
AddressManager::Location Location
void scheduleDeadlockCheckEvent()
void validateAtomicResp(Location loc, int lane, Value ret_val)
ProtocolTester::SeqPort * port
bool checkDRF(Location atomic_loc, Location loc, bool isStore) const
void printAllOutstandingReqs(std::stringstream &ss) const
DeadlockCheckEvent deadlockCheckEvent
virtual void issueAcquireOp()=0
ProtocolTester::SeqPort * scalarPort
OutstandingReqTable outstandingStores
void addOutstandingReqs(OutstandingReqTable &req_table, Addr addr, int lane, Location loc, Value stored_val=AddressManager::INVALID_VALUE)
virtual void issueStoreOps()=0
OutstandingReqTable outstandingLoads
ProtocolTester::GMTokenPort * tokenPort
EpisodeHistory episodeHistory
OutstandingReq popOutstandingReq(OutstandingReqTable &req_table, Addr address)
const Episode::Action * curAction
virtual void issueAtomicOps()=0
ProtocolTester::SeqPort * sqcPort
void printOutstandingReqs(const OutstandingReqTable &table, std::stringstream &ss) const
TesterThreadParams Params
virtual void issueLoadOps()=0
std::unordered_map< Addr, OutstandingReqList > OutstandingReqTable
TesterThreadEvent threadEvent
std::vector< OutstandingReq > OutstandingReqList
void validateLoadResp(Location loc, int lane, Value ret_val)
void acquireTokens(int num_tokens)
Acquire tokens by decrementing the number of available tokens across the port.
bool haveTokens(int num_tokens)
Query if there are at least num_tokens tokens available to acquire.
std::enable_if_t< std::is_integral_v< T >, T > random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
bool scheduled() const
Determine if the current event is scheduled.
void schedule(Event &event, Tick when)
#define panic(...)
This implements a cprintf based panic() function.
std::string printAddress(Addr addr)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Tick curTick()
The universal simulation clock.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.