40#include "debug/HtmMem.hh"
41#include "debug/RubyPort.hh"
53 const HtmFailedInCacheReason ruby_ret_code)
55 switch (ruby_ret_code) {
56 case HtmFailedInCacheReason_NO_FAIL:
58 case HtmFailedInCacheReason_FAIL_SELF:
60 case HtmFailedInCacheReason_FAIL_REMOTE:
62 case HtmFailedInCacheReason_FAIL_OTHER:
65 panic(
"Invalid htm return code\n");
71 ADD_STAT(m_htm_transaction_cycles,
"number of cycles spent in an outer "
73 ADD_STAT(m_htm_transaction_instructions,
"number of instructions spent "
74 "in an outer transaction"),
75 ADD_STAT(m_htm_transaction_abort_cause,
"cause of htm transaction abort")
98 for (
unsigned cause_idx = 0; cause_idx < num_causes; ++cause_idx) {
112 const HtmCallbackMode
mode,
113 const HtmFailedInCacheReason htm_return_code)
119 if (
mode == HtmCallbackMode_HTM_CMD) {
133 uint8_t* dataptr = pkt->
getPtr<uint8_t>();
134 memset(dataptr, 0, pkt->
getSize());
135 *dataptr = (uint8_t) htm_return_code;
138 if (htm_return_code == HtmFailedInCacheReason_NO_FAIL) {
139 if (pkt->
req->isHTMStart()) {
142 DPRINTF(HtmMem,
"htmStart - htmUid=%u\n",
144 }
else if (pkt->
req->isHTMCommit()) {
149 Counter transaction_instructions =
152 transaction_instructions);
154 DPRINTF(HtmMem,
"htmCommit - htmUid=%u\n",
156 }
else if (pkt->
req->isHTMAbort()) {
159 auto cause_idx =
static_cast<int>(cause);
161 DPRINTF(HtmMem,
"htmAbort - reason=%s - htmUid=%u\n",
166 DPRINTF(HtmMem,
"HTM_CMD: fail - htmUid=%u\n",
172 }
else if (
mode == HtmCallbackMode_LD_FAIL ||
173 mode == HtmCallbackMode_ST_FAIL) {
179 while (!seq_req_list.empty()) {
188 if (request.
m_type == RubyRequestType_Store_Conditional) {
189 pkt->
req->setExtraData(0);
192 DPRINTF(HtmMem,
"%s_FAIL: size=%d - "
193 "addr=0x%lx - htmUid=%d\n",
194 (
mode == HtmCallbackMode_LD_FAIL) ?
"LD" :
"ST",
201 seq_req_list.pop_front();
204 if (seq_req_list.empty()) {
208 panic(
"unrecognised HTM callback mode\n");
214 const HtmFailedInCacheReason htm_return_code)
226 assert(port !=
nullptr);
230 DPRINTF(HtmMem,
"HTM callback: start=%d, commit=%d, "
231 "cancel=%d, rc=%d\n",
232 pkt->
req->isHTMStart(), pkt->
req->isHTMCommit(),
233 pkt->
req->isHTMCancel(), htm_return_code);
262 for (; htm != htm_end; ++htm) {
267 panic(
"Possible Deadlock detected. Aborting!\n"
268 "version: %d m_htmCmdRequestTable: %d "
269 "current time: %u issue_time: %d difference: %d\n",
284template <
class VALUE>
288 auto i = queue.begin();
289 auto end = queue.end();
292 for (;
i != end; ++
i)
313 RubyRequestType secondary_type)
320 return RequestStatus_BufferFull;
328 return RequestStatus_Ready;
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Cycles ticksToCycles(Tick t) const
Cycles is a wrapper class for representing cycle counts, i.e.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
bool needsResponse() const
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
T * getPtr()
get a pointer to the data ptr.
uint64_t getHtmTransactionUid() const
If a packet/request originates in a CPU executing in transactional mode, i.e.
RequestPtr req
A pointer to the original request.
void makeHtmTransactionalReqResponse(const HtmCacheFailure ret_code)
Communicates to the core that a packet was processed by the memory subsystem while running in transac...
void schedTimingResp(PacketPtr pkt, Tick when)
Schedule the sending of a timing response.
bool isMemAddr(Addr addr) const
Check if a physical address is within a range of a memory that is part of the global address map.
bool isDeviceMemAddr(const PacketPtr &pkt) const
Similar to isMemAddr but for devices.
void rubyHtmCallback(PacketPtr pkt, const HtmFailedInCacheReason fail_r)
bool empty() const override
statistics::Vector m_htm_transaction_abort_cause
Causes for HTM transaction aborts.
HtmCacheFailure htmRetCodeConversion(const HtmFailedInCacheReason rc)
Htm return code conversion.
HTMSequencer(const RubyHTMSequencerParams &p)
Counter m_htmstart_instruction
RequestStatus insertRequest(PacketPtr pkt, RubyRequestType primary_type, RubyRequestType secondary_type) override
statistics::Histogram m_htm_transaction_cycles
Histogram of cycle latencies of HTM transactions.
statistics::Histogram m_htm_transaction_instructions
Histogram of instruction lengths of HTM transactions.
void htmCallback(Addr, const HtmCallbackMode, const HtmFailedInCacheReason)
std::deque< SequencerRequest * > m_htmCmdRequestTable
void print(std::ostream &out) const override
Cycles m_deadlock_threshold
std::unordered_map< Addr, std::list< SequencerRequest > > m_RequestTable
virtual bool empty() const
virtual RequestStatus insertRequest(PacketPtr pkt, RubyRequestType primary_type, RubyRequestType secondary_type)
virtual void print(std::ostream &out) const
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Histogram & init(size_type size)
Set the parameters of this histogram.
Derived & init(size_type size)
Set this vector to have the given size.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
#define panic(...)
This implements a cprintf based panic() function.
Addr makeLineAddress(Addr addr)
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
bool isHtmCmdRequest(RubyRequestType type)
const FlagsType pdf
Print the percent of the total that this entry represents.
const FlagsType nonan
Don't print if this is NAN.
const FlagsType nozero
Don't print if this is zero.
const FlagsType total
Print the total.
double Counter
All counters are of 64-bit values.
const FlagsType dist
Print the distribution.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
T safe_cast(U &&ref_or_ptr)
Tick curTick()
The universal simulation clock.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::string htmFailureToStr(HtmFailureFaultCause cause)
Convert enum into string to be used for debug purposes.
uint64_t Tick
Tick count type.