Go to the documentation of this file.
37 #include "debug/GPUExec.hh"
38 #include "debug/GPUInitAbi.hh"
39 #include "debug/WavefrontStack.hh"
48 :
SimObject(
p), wfSlotId(
p.wf_slot_id), simdId(
p.simdId),
49 maxIbSize(
p.max_ib_size), _gpuISA(*this),
50 vmWaitCnt(-1), expWaitCnt(-1), lgkmWaitCnt(-1),
51 vmemInstsIssued(0), expInstsIssued(0), lgkmInstsIssued(0),
52 sleepCnt(0), barId(
WFBarrier::InvalidID), stats(this)
90 for (
int i = 0;
i < 3; ++
i) {
126 uint32_t wiCount = 0;
127 uint32_t firstWave = 0;
128 int orderedAppendTerm = 0;
130 uint32_t finalValue = 0;
133 Addr hidden_priv_base(0);
142 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
143 "Setting PrivateSegBuffer: s[%d] = %x\n",
153 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
154 "Setting PrivateSegBuffer: s[%d] = %x\n",
164 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
165 "Setting PrivateSegBuffer: s[%d] = %x\n",
176 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
177 "Setting PrivateSegBuffer: s[%d] = %x\n",
186 bits(host_disp_pkt_addr, 31, 0));
188 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
189 "Setting DispatchPtr: s[%d] = %x\n",
192 bits(host_disp_pkt_addr, 31, 0));
197 bits(host_disp_pkt_addr, 63, 32));
198 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
199 "Setting DispatchPtr: s[%d] = %x\n",
202 bits(host_disp_pkt_addr, 63, 32));
212 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
213 "Setting QueuePtr: s[%d] = %x\n",
222 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
223 "Setting QueuePtr: s[%d] = %x\n",
234 bits(kernarg_addr, 31, 0));
236 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
237 "Setting KernargSegPtr: s[%d] = %x\n",
240 bits(kernarg_addr, 31, 0));
245 bits(kernarg_addr, 63, 32));
246 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
247 "Setting KernargSegPtr: s[%d] = %x\n",
250 bits(kernarg_addr, 63, 32));
261 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
262 "Setting FlatScratch Addr: s[%d] = %x\n",
275 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
276 "Setting FlatScratch size: s[%d] = %x\n",
306 & 0x000000000000ffff) << 32);
320 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
321 "Setting num WG X: s[%d] = %x\n",
334 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
335 "Setting num WG Y: s[%d] = %x\n",
348 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
349 "Setting num WG Z: s[%d] = %x\n",
360 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
361 "Setting WG ID X: s[%d] = %x\n",
372 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
373 "Setting WG ID Y: s[%d] = %x\n",
384 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
385 "Setting WG ID Z: s[%d] = %x\n",
410 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
411 "Setting Private Seg Offset: s[%d] = %x\n",
418 firstWave = (
wfId == 0) ? 1 : 0;
419 numWfsInWg =
divCeil(wgSizeInWorkItems,
421 finalValue = firstWave << ((
sizeof(uint32_t) * 8) - 1);
422 finalValue |= (orderedAppendTerm << 6);
423 finalValue |= numWfsInWg;
427 write(physSgprIdx, finalValue);
430 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
431 "Setting WG Info: s[%d] = %x\n",
436 fatal(
"SGPR enable bit %i not supported\n", en_bit);
448 uint32_t physVgprIdx = 0;
459 for (
int lane = 0; lane <
workItemId[0].size(); ++lane) {
475 for (
int lane = 0; lane <
workItemId[1].size(); ++lane) {
487 mapVgpr(
this, regInitIdx);
491 for (
int lane = 0; lane <
workItemId[2].size(); ++lane) {
542 "CU%d has been idle for %d ticks at tick %d",
567 if (ii->isGlobalMem() ||
568 (ii->isFlat() && ii->executedAs() == Enums::SC_GLOBAL)) {
578 if (ii->isLocalMem() ||
579 (ii->isFlat() && ii->executedAs() == Enums::SC_GROUP)) {
608 if (ii->isWaitcnt()) {
610 assert(ii->isScalar());
623 if (
status !=
S_STOPPED && ii->isScalar() && (ii->isNop() || ii->isReturn()
624 || ii->isEndOfKernel() || ii->isBranch() || ii->isALU() ||
625 (ii->isKernArgSeg() && ii->isLoad()))) {
639 ii->isReturn() || ii->isBranch() || ii->isALU() || ii->isEndOfKernel()
640 || (ii->isKernArgSeg() && ii->isLoad()))) {
730 if (ii->isReturn() || ii->isBranch() ||
731 ii->isEndOfKernel()) {
750 "Negative requests in pipe for WF%d for slot%d"
751 " and SIMD%d: Rd GlobalMem Reqs=%d, Wr GlobalMem Reqs=%d,"
752 " Rd LocalMem Reqs=%d, Wr LocalMem Reqs=%d,"
753 " Outstanding Reqs=%d\n",
761 if (!ii->isScalar()) {
764 }
else if (ii->isStore()) {
766 }
else if (ii->isAtomic() || ii->isMemSync()) {
770 panic(
"Invalid memory operation!\n");
776 }
else if (ii->isStore()) {
778 }
else if (ii->isAtomic() || ii->isMemSync()) {
782 panic(
"Invalid memory operation!\n");
792 "Scalar instructions can not access Shared memory!!!");
795 }
else if (ii->isStore()) {
797 }
else if (ii->isAtomic() || ii->isMemSync()) {
801 panic(
"Invalid memory operation!\n");
818 if (ii->isALU() || ii->isSpecialOp() ||
819 ii->isBranch() || ii->isNop() ||
820 (ii->isKernArgSeg() && ii->isLoad()) || ii->isArgSeg() ||
821 ii->isReturn() || ii->isEndOfKernel()) {
822 if (!ii->isScalar()) {
828 }
else if (ii->isBarrier()) {
830 }
else if (ii->isFlat()) {
831 assert(!ii->isScalar());
841 }
else if (ii->isGlobalMem()) {
843 }
else if (ii->isLocalMem()) {
845 }
else if (ii->isPrivateSeg()) {
847 "Scalar instructions can not access Private memory!!!");
850 panic(
"reserveResources -> Couldn't process op!\n");
856 assert(execUnitIds.size());
890 DPRINTF(GPUExec,
"CU%d: WF[%d][%d]: wave[%d] Executing inst: %s "
892 wfDynId, ii->disassemble(), old_pc, ii->seqNum());
902 if (!ii->isScalar()) {
928 for (
int i = 0;
i < ii->getNumOperands();
i++) {
929 if (ii->isVectorRegister(
i)) {
930 int vgpr = ii->getRegisterIndex(
i, ii);
931 int nReg = ii->getOperandSize(
i) <= 4 ? 1 :
932 ii->getOperandSize(
i) / 4;
933 for (
int n = 0;
n < nReg;
n++) {
934 if (ii->isSrcOperand(
i)) {
942 }
else if (ii->isDstOperand(
i)) {
958 if (
pc() == old_pc) {
963 DPRINTF(GPUExec,
"CU%d: WF[%d][%d]: wave%d %s taken branch\n",
968 DPRINTF(GPUExec,
"CU%d: WF[%d][%d]: wave[%d] (pc: %#x)\n",
972 const int num_active_lanes =
execMask().count();
976 if (ii->isF16() && ii->isALU()) {
977 if (ii->isF32() || ii->isF64()) {
978 fatal(
"Instruction is tagged as both (1) F16, and (2)"
979 "either F32 or F64.");
987 else if (ii->isMAC()) {
992 else if (ii->isMAD()) {
998 if (ii->isF32() && ii->isALU()) {
999 if (ii->isF16() || ii->isF64()) {
1000 fatal(
"Instruction is tagged as both (1) F32, and (2)"
1001 "either F16 or F64.");
1007 += num_active_lanes;
1009 else if (ii->isMAC()) {
1012 += num_active_lanes;
1014 else if (ii->isMAD()) {
1017 += num_active_lanes;
1020 if (ii->isF64() && ii->isALU()) {
1021 if (ii->isF16() || ii->isF32()) {
1022 fatal(
"Instruction is tagged as both (1) F64, and (2)"
1023 "either F16 or F32.");
1029 += num_active_lanes;
1031 else if (ii->isMAC()) {
1034 += num_active_lanes;
1036 else if (ii->isMAD()) {
1039 += num_active_lanes;
1061 bool flat_as_gm =
false;
1062 bool flat_as_lm =
false;
1064 flat_as_gm = (ii->executedAs() == Enums::SC_GLOBAL) ||
1065 (ii->executedAs() == Enums::SC_PRIVATE);
1066 flat_as_lm = (ii->executedAs() == Enums::SC_GROUP);
1071 if (ii->isALU() || ii->isSpecialOp() ||
1072 ii->isBranch() || ii->isNop() ||
1073 (ii->isKernArgSeg() && ii->isLoad()) ||
1074 ii->isArgSeg() || ii->isEndOfKernel() || ii->isReturn()) {
1076 if (!ii->isScalar()) {
1084 }
else if (ii->isBarrier()) {
1088 }
else if (ii->isLoad() && (ii->isGlobalMem() || flat_as_gm)) {
1089 if (!ii->isScalar()) {
1105 }
else if (ii->isStore() && (ii->isGlobalMem() || flat_as_gm)) {
1106 if (!ii->isScalar()) {
1121 }
else if ((ii->isAtomic() || ii->isMemSync()) &&
1122 (ii->isGlobalMem() || flat_as_gm)) {
1123 if (!ii->isScalar()) {
1139 }
else if (ii->isLoad() && (ii->isLocalMem() || flat_as_lm)) {
1147 }
else if (ii->isStore() && (ii->isLocalMem() || flat_as_lm)) {
1155 }
else if ((ii->isAtomic() || ii->isMemSync()) &&
1156 (ii->isLocalMem() || flat_as_lm)) {
1164 panic(
"Bad instruction type!\n");
1279 assert(vm_wait_cnt >= 0);
1280 assert(exp_wait_cnt >= 0);
1281 assert(lgkm_wait_cnt >= 0);
1284 assert(vm_wait_cnt <= 0xf);
1285 assert(exp_wait_cnt <= 0x7);
1286 assert(lgkm_wait_cnt <= 0x1f);
1304 if (vm_wait_cnt != 0xf)
1307 if (exp_wait_cnt != 0x7)
1310 if (lgkm_wait_cnt != 0x1f)
1419 assert(bar_id < computeUnit->numBarrierSlots());
1442 :
Stats::Group(parent),
1444 "number of instructions executed by this WF slot"),
1445 ADD_STAT(schCycles,
"number of cycles spent in schedule stage"),
1446 ADD_STAT(schStalls,
"number of cycles WF is stalled in SCH stage"),
1447 ADD_STAT(schRfAccessStalls,
"number of cycles wave selected in SCH but "
1448 "RF denied adding instruction"),
1449 ADD_STAT(schResourceStalls,
"number of cycles stalled in sch by resource"
1451 ADD_STAT(schOpdNrdyStalls,
"number of cycles stalled in sch waiting for "
1452 "RF reads to complete"),
1454 "number of cycles wave stalled due to LDS-VRF arbitration"),
1456 ADD_STAT(numTimesBlockedDueWAXDependencies,
"number of times the wf's "
1457 "instructions are blocked due to WAW or WAR dependencies"),
1459 ADD_STAT(numTimesBlockedDueRAWDependencies,
"number of times the wf's "
1460 "instructions are blocked due to RAW dependencies"),
1462 "Count of RAW distance in dynamic instructions for this WF"),
1463 ADD_STAT(readsPerWrite,
"Count of Vector reads per write for this WF")
std::vector< WaitClass > vectorALUs
bool isOldestInstScalarALU()
uint32_t scratch_resource_descriptor[4]
#define fatal(...)
This implements a cprintf based fatal() function.
WaitClass vectorSharedMemUnit
bool isOldestInstFlatMem()
void recvTokens(int num_tokens)
Increment the number of available tokens by num_tokens.
void deleteFromPipeMap(Wavefront *w)
WaitClass vrfToGlobalMemPipeBus
int mapWaveToScalarAluGlobalIdx(Wavefront *w) const
Stats::Scalar numVecOpsExecutedMAC64
uint32_t scratch_workitem_byte_size
Addr hostDispPktAddr() const
void resizeRegFiles(int num_vregs, int num_sregs)
std::vector< int > vecReads
bool vgprBitEnabled(int bit) const
int mapWaveToGlobalMem(Wavefront *w) const
::VecRegT< VecElemU32, NumVecElemPerVecReg, false > VecRegU32
Cycles srf_scm_bus_latency
void initShHiddenPrivateBase(Addr queueBase, uint32_t offset)
Cycles vrf_gm_bus_latency
Stats::Scalar numVecOpsExecutedTwoOpFP
std::vector< uint32_t > oldVgpr
int mapWaveToScalarMem(Wavefront *w) const
int mapWaveToLocalMem(Wavefront *w) const
Stats::Scalar numVecOpsExecutedF64
void start(uint64_t _wfDynId, uint64_t _base_ptr)
int wgSize(int dim) const
Stats::Distribution vecRawDistance
std::vector< Addr > lastAddr
Stats::Scalar numVecOpsExecutedFMA64
void decVMemInstsIssued()
bool isOldestInstPrivMem()
Stats::Scalar numVecOpsExecutedMAD64
int mapSgpr(Wavefront *w, int sgprIndex)
bool isOldestInstScalarMem()
ComputeUnit::ComputeUnitStats stats
WaitClass vectorGlobalMemUnit
Stats::Scalar numInstrExecuted
RegisterManager * registerManager
void reserveGmResource(GPUDynInstPtr ii)
Cycles vrf_lm_bus_latency
Stats::Scalar numVecOpsExecutedF32
@ S_BARRIER
WF is stalled at a barrier.
std::vector< uint32_t > workItemId[3]
bool sgprBitEnabled(int bit) const
Wavefront::WavefrontStats stats
const FlagsType none
Nothing extra to print.
Stats::Scalar numVecOpsExecutedF16
int scalarOutstandingReqsWrGm
Stats::Vector instCyclesLdsPerSimd
std::vector< WaitClass > scalarALUs
int vmWaitCnt
the following are used for waitcnt instructions vmWaitCnt: once set, we wait for the oustanding numbe...
_amd_queue_t amdQueue
Keep a copy of the AMD HSA queue because we need info from some of its fields to initialize register ...
void setStatus(status_e newStatus)
void flushBuf(int wfSlotId)
ComputeUnit * computeUnit
T divCeil(const T &a, const U &b)
std::vector< ScalarRegisterFile * > srf
Tick cyclesToTicks(Cycles c) const
int scalarOutstandingReqsRdGm
Stats::Scalar totalCycles
Counter value() const
Return the current value of this stat as its base type.
bool isOldestInstVectorALU()
Addr hostAMDQueueAddr
Host-side addr of the amd_queue_t on which this task was queued.
bool isOldestInstWaitcnt()
void setWaitCnts(int vm_wait_cnt, int exp_wait_cnt, int lgkm_wait_cnt)
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
std::vector< PoolManager * > vrfPoolMgrs
std::vector< VectorRegisterFile * > vrf
std::vector< uint64_t > instExecPerSimd
@ S_WAITCNT
wavefront has unsatisfied wait counts
Stats::Scalar numVecOpsExecutedMAC16
void freeRegisterFile()
Freeing VRF space.
int gridSize(int dim) const
FetchUnit & fetchUnit(int simdId)
Stats::Distribution controlFlowDivergenceDist
void validateRequestCounters()
WaitClass vrfToLocalMemPipeBus
bool isLmInstruction(GPUDynInstPtr ii)
Stats::Vector instCyclesVMemPerSimd
std::vector< uint64_t > lastExecCycle
Stats::Scalar numVecOpsExecutedFMA16
Stats::Distribution activeLanesPerLMemInstrDist
WaitClass srfToScalarMemPipeBus
Stats::Scalar numVecOpsExecutedFMA32
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void computeActualWgSz(HSAQueueEntry *task)
GPUDynInstPtr nextInstr()
std::unordered_map< int, uint64_t > rawDist
void decLGKMInstsIssued()
void incVectorInstDstOperand(int num_operands)
TokenManager * getTokenManager()
Wavefront(const Params &p)
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
bool isGmInstruction(GPUDynInstPtr ii)
void reserveLmResource(GPUDynInstPtr ii)
uint64_t scratch_backing_memory_location
bool isOldestInstBarrier()
Stats::Distribution readsPerWrite
void updateInstStats(GPUDynInstPtr gpuDynInst)
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
void incVectorInstSrcOperand(int num_operands)
Stats::Distribution activeLanesPerGMemInstrDist
void initRegState(HSAQueueEntry *task, int wgSizeInWorkItems)
std::shared_ptr< GPUDynInst > GPUDynInstPtr
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Cycles is a wrapper class for representing cycle counts, i.e.
uint32_t compute_tmpring_size_wavesize
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
std::deque< GPUDynInstPtr > instructionBuffer
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
int mapVgpr(Wavefront *w, int vgprIndex)
Stats::Distribution execRateDist
void setSleepTime(int sleep_time)
Stats::Vector instCyclesScMemPerSimd
Tick curTick()
The universal simulation clock.
void incVMemInstsIssued()
TheGpuISA::GPUISA _gpuISA
VecRegU32::Container VecRegContainerU32
std::vector< uint32_t > workItemFlatId
Stats::Scalar numVecOpsExecutedMAD16
std::vector< uint64_t > oldDgpr
std::bitset< std::numeric_limits< unsigned long long >::digits > VectorMask
WavefrontStats(Stats::Group *parent)
Stats::Scalar numVecOpsExecutedMAC32
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Stats::Scalar numVecOpsExecuted
Stats::Scalar numVecOpsExecutedMAD32
std::unordered_set< uint64_t > pipeMap
Stats::Scalar numInstrExecuted
Stats::VectorDistribution instInterleave
int mapWaveToScalarAlu(Wavefront *w) const
static const int InvalidID
std::vector< int > reserveResources()
#define panic(...)
This implements a cprintf based panic() function.
void incLGKMInstsIssued()
Abstract superclass for simulation objects.
Generated on Tue Mar 23 2021 19:41:27 for gem5 by doxygen 1.8.17