Go to the documentation of this file.
35 #include "debug/GPUExec.hh"
36 #include "debug/GPUInitAbi.hh"
37 #include "debug/WavefrontStack.hh"
49 :
SimObject(
p), wfSlotId(
p.wf_slot_id), simdId(
p.simdId),
50 maxIbSize(
p.max_ib_size), _gpuISA(*this),
51 vmWaitCnt(-1), expWaitCnt(-1), lgkmWaitCnt(-1),
52 vmemInstsIssued(0), expInstsIssued(0), lgkmInstsIssued(0),
53 sleepCnt(0), barId(
WFBarrier::InvalidID), stats(this)
91 for (
int i = 0;
i < 3; ++
i) {
127 uint32_t wiCount = 0;
128 uint32_t firstWave = 0;
129 int orderedAppendTerm = 0;
131 uint32_t finalValue = 0;
134 Addr hidden_priv_base(0);
143 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
144 "Setting PrivateSegBuffer: s[%d] = %x\n",
154 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
155 "Setting PrivateSegBuffer: s[%d] = %x\n",
165 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
166 "Setting PrivateSegBuffer: s[%d] = %x\n",
177 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
178 "Setting PrivateSegBuffer: s[%d] = %x\n",
187 bits(host_disp_pkt_addr, 31, 0));
189 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
190 "Setting DispatchPtr: s[%d] = %x\n",
193 bits(host_disp_pkt_addr, 31, 0));
198 bits(host_disp_pkt_addr, 63, 32));
199 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
200 "Setting DispatchPtr: s[%d] = %x\n",
203 bits(host_disp_pkt_addr, 63, 32));
213 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
214 "Setting QueuePtr: s[%d] = %x\n",
223 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
224 "Setting QueuePtr: s[%d] = %x\n",
235 bits(kernarg_addr, 31, 0));
237 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
238 "Setting KernargSegPtr: s[%d] = %x\n",
241 bits(kernarg_addr, 31, 0));
246 bits(kernarg_addr, 63, 32));
247 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
248 "Setting KernargSegPtr: s[%d] = %x\n",
251 bits(kernarg_addr, 63, 32));
262 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
263 "Setting FlatScratch Addr: s[%d] = %x\n",
276 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
277 "Setting FlatScratch size: s[%d] = %x\n",
307 & 0x000000000000ffff) << 32);
321 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
322 "Setting num WG X: s[%d] = %x\n",
335 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
336 "Setting num WG Y: s[%d] = %x\n",
349 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
350 "Setting num WG Z: s[%d] = %x\n",
361 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
362 "Setting WG ID X: s[%d] = %x\n",
373 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
374 "Setting WG ID Y: s[%d] = %x\n",
385 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
386 "Setting WG ID Z: s[%d] = %x\n",
411 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
412 "Setting Private Seg Offset: s[%d] = %x\n",
419 firstWave = (
wfId == 0) ? 1 : 0;
420 numWfsInWg =
divCeil(wgSizeInWorkItems,
422 finalValue = firstWave << ((
sizeof(uint32_t) * 8) - 1);
423 finalValue |= (orderedAppendTerm << 6);
424 finalValue |= numWfsInWg;
428 write(physSgprIdx, finalValue);
431 DPRINTF(GPUInitAbi,
"CU%d: WF[%d][%d]: wave[%d] "
432 "Setting WG Info: s[%d] = %x\n",
437 fatal(
"SGPR enable bit %i not supported\n", en_bit);
449 uint32_t physVgprIdx = 0;
460 for (
int lane = 0; lane <
workItemId[0].size(); ++lane) {
476 for (
int lane = 0; lane <
workItemId[1].size(); ++lane) {
488 mapVgpr(
this, regInitIdx);
492 for (
int lane = 0; lane <
workItemId[2].size(); ++lane) {
543 "CU%d has been idle for %d ticks at tick %d",
568 if (ii->isGlobalMem() ||
569 (ii->isFlat() && ii->executedAs() == enums::SC_GLOBAL)) {
579 if (ii->isLocalMem() ||
580 (ii->isFlat() && ii->executedAs() == enums::SC_GROUP)) {
609 if (ii->isWaitcnt()) {
611 assert(ii->isScalar());
624 if (
status !=
S_STOPPED && ii->isScalar() && (ii->isNop() || ii->isReturn()
625 || ii->isEndOfKernel() || ii->isBranch() || ii->isALU() ||
626 (ii->isKernArgSeg() && ii->isLoad()))) {
640 ii->isReturn() || ii->isBranch() || ii->isALU() || ii->isEndOfKernel()
641 || (ii->isKernArgSeg() && ii->isLoad()))) {
731 if (ii->isReturn() || ii->isBranch() ||
732 ii->isEndOfKernel()) {
751 "Negative requests in pipe for WF%d for slot%d"
752 " and SIMD%d: Rd GlobalMem Reqs=%d, Wr GlobalMem Reqs=%d,"
753 " Rd LocalMem Reqs=%d, Wr LocalMem Reqs=%d,"
754 " Outstanding Reqs=%d\n",
762 if (!ii->isScalar()) {
765 }
else if (ii->isStore()) {
767 }
else if (ii->isAtomic() || ii->isMemSync()) {
771 panic(
"Invalid memory operation!\n");
777 }
else if (ii->isStore()) {
779 }
else if (ii->isAtomic() || ii->isMemSync()) {
783 panic(
"Invalid memory operation!\n");
793 "Scalar instructions can not access Shared memory!!!");
796 }
else if (ii->isStore()) {
798 }
else if (ii->isAtomic() || ii->isMemSync()) {
802 panic(
"Invalid memory operation!\n");
819 if (ii->isALU() || ii->isSpecialOp() ||
820 ii->isBranch() || ii->isNop() ||
821 (ii->isKernArgSeg() && ii->isLoad()) || ii->isArgSeg() ||
822 ii->isReturn() || ii->isEndOfKernel()) {
823 if (!ii->isScalar()) {
829 }
else if (ii->isBarrier()) {
831 }
else if (ii->isFlat()) {
832 assert(!ii->isScalar());
842 }
else if (ii->isGlobalMem()) {
844 }
else if (ii->isLocalMem()) {
846 }
else if (ii->isPrivateSeg()) {
848 "Scalar instructions can not access Private memory!!!");
851 panic(
"reserveResources -> Couldn't process op!\n");
857 assert(execUnitIds.size());
891 DPRINTF(GPUExec,
"CU%d: WF[%d][%d]: wave[%d] Executing inst: %s "
893 wfDynId, ii->disassemble(), old_pc, ii->seqNum());
903 if (!ii->isScalar()) {
929 for (
const auto& srcVecOp : ii->srcVecRegOperands()) {
930 for (
const auto& virtIdx : srcVecOp.virtIndices()) {
941 for (
const auto& dstVecOp : ii->dstVecRegOperands()) {
942 for (
const auto& virtIdx : dstVecOp.virtIndices()) {
956 if (
pc() == old_pc) {
961 DPRINTF(GPUExec,
"CU%d: WF[%d][%d]: wave%d %s taken branch\n",
966 DPRINTF(GPUExec,
"CU%d: WF[%d][%d]: wave[%d] (pc: %#x)\n",
970 const int num_active_lanes =
execMask().count();
974 if (ii->isF16() && ii->isALU()) {
975 if (ii->isF32() || ii->isF64()) {
976 fatal(
"Instruction is tagged as both (1) F16, and (2)"
977 "either F32 or F64.");
985 else if (ii->isMAC()) {
990 else if (ii->isMAD()) {
996 if (ii->isF32() && ii->isALU()) {
997 if (ii->isF16() || ii->isF64()) {
998 fatal(
"Instruction is tagged as both (1) F32, and (2)"
999 "either F16 or F64.");
1005 += num_active_lanes;
1007 else if (ii->isMAC()) {
1010 += num_active_lanes;
1012 else if (ii->isMAD()) {
1015 += num_active_lanes;
1018 if (ii->isF64() && ii->isALU()) {
1019 if (ii->isF16() || ii->isF32()) {
1020 fatal(
"Instruction is tagged as both (1) F64, and (2)"
1021 "either F16 or F32.");
1027 += num_active_lanes;
1029 else if (ii->isMAC()) {
1032 += num_active_lanes;
1034 else if (ii->isMAD()) {
1037 += num_active_lanes;
1059 bool flat_as_gm =
false;
1060 bool flat_as_lm =
false;
1062 flat_as_gm = (ii->executedAs() == enums::SC_GLOBAL) ||
1063 (ii->executedAs() == enums::SC_PRIVATE);
1064 flat_as_lm = (ii->executedAs() == enums::SC_GROUP);
1069 if (ii->isALU() || ii->isSpecialOp() ||
1070 ii->isBranch() || ii->isNop() ||
1071 (ii->isKernArgSeg() && ii->isLoad()) ||
1072 ii->isArgSeg() || ii->isEndOfKernel() || ii->isReturn()) {
1074 if (!ii->isScalar()) {
1082 }
else if (ii->isBarrier()) {
1086 }
else if (ii->isLoad() && (ii->isGlobalMem() || flat_as_gm)) {
1087 if (!ii->isScalar()) {
1103 }
else if (ii->isStore() && (ii->isGlobalMem() || flat_as_gm)) {
1104 if (!ii->isScalar()) {
1119 }
else if ((ii->isAtomic() || ii->isMemSync()) &&
1120 (ii->isGlobalMem() || flat_as_gm)) {
1121 if (!ii->isScalar()) {
1137 }
else if (ii->isLoad() && (ii->isLocalMem() || flat_as_lm)) {
1145 }
else if (ii->isStore() && (ii->isLocalMem() || flat_as_lm)) {
1153 }
else if ((ii->isAtomic() || ii->isMemSync()) &&
1154 (ii->isLocalMem() || flat_as_lm)) {
1162 panic(
"Bad instruction type!\n");
1277 assert(vm_wait_cnt >= 0);
1278 assert(exp_wait_cnt >= 0);
1279 assert(lgkm_wait_cnt >= 0);
1282 assert(vm_wait_cnt <= 0xf);
1283 assert(exp_wait_cnt <= 0x7);
1284 assert(lgkm_wait_cnt <= 0x1f);
1302 if (vm_wait_cnt != 0xf)
1305 if (exp_wait_cnt != 0x7)
1308 if (lgkm_wait_cnt != 0x1f)
1417 assert(bar_id < computeUnit->numBarrierSlots());
1440 : statistics::
Group(parent),
1442 "number of instructions executed by this WF slot"),
1443 ADD_STAT(schCycles,
"number of cycles spent in schedule stage"),
1444 ADD_STAT(schStalls,
"number of cycles WF is stalled in SCH stage"),
1445 ADD_STAT(schRfAccessStalls,
"number of cycles wave selected in SCH but "
1446 "RF denied adding instruction"),
1447 ADD_STAT(schResourceStalls,
"number of cycles stalled in sch by resource"
1449 ADD_STAT(schOpdNrdyStalls,
"number of cycles stalled in sch waiting for "
1450 "RF reads to complete"),
1452 "number of cycles wave stalled due to LDS-VRF arbitration"),
1454 ADD_STAT(numTimesBlockedDueWAXDependencies,
"number of times the wf's "
1455 "instructions are blocked due to WAW or WAR dependencies"),
1457 ADD_STAT(numTimesBlockedDueRAWDependencies,
"number of times the wf's "
1458 "instructions are blocked due to RAW dependencies"),
1460 "Count of RAW distance in dynamic instructions for this WF"),
1461 ADD_STAT(readsPerWrite,
"Count of Vector reads per write for this WF")
std::vector< uint32_t > workItemFlatId
Tick curTick()
The universal simulation clock.
#define fatal(...)
This implements a cprintf based fatal() function.
std::vector< int > vecReads
std::vector< Addr > lastAddr
bool isOldestInstFlatMem()
void computeActualWgSz(HSAQueueEntry *task)
statistics::VectorDistribution instInterleave
statistics::Scalar numVecOpsExecutedTwoOpFP
std::vector< uint64_t > lastExecCycle
void flushBuf(int wfSlotId)
void setSleepTime(int sleep_time)
bool isOldestInstBarrier()
std::vector< ScalarRegisterFile * > srf
void incVectorInstDstOperand(int num_operands)
std::vector< uint32_t > oldVgpr
std::vector< uint64_t > oldDgpr
statistics::Scalar numVecOpsExecutedF64
std::bitset< std::numeric_limits< unsigned long long >::digits > VectorMask
gem5::ComputeUnit::ComputeUnitStats stats
bool isOldestInstVectorALU()
void setWaitCnts(int vm_wait_cnt, int exp_wait_cnt, int lgkm_wait_cnt)
WaitClass srfToScalarMemPipeBus
statistics::Vector instCyclesScMemPerSimd
void initShHiddenPrivateBase(Addr queueBase, uint32_t offset)
WavefrontStats(statistics::Group *parent)
void initRegState(HSAQueueEntry *task, int wgSizeInWorkItems)
statistics::Scalar numVecOpsExecutedFMA32
WaitClass vrfToGlobalMemPipeBus
std::vector< PoolManager * > vrfPoolMgrs
statistics::Distribution activeLanesPerLMemInstrDist
TheGpuISA::GPUISA _gpuISA
statistics::Scalar numVecOpsExecutedMAD64
const FlagsType none
Nothing extra to print.
std::unordered_map< int, uint64_t > rawDist
statistics::Scalar numVecOpsExecutedMAC32
statistics::Scalar numVecOpsExecutedMAD32
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
std::vector< VectorRegisterFile * > vrf
statistics::Vector instCyclesVMemPerSimd
_amd_queue_t amdQueue
Keep a copy of the AMD HSA queue because we need info from some of its fields to initialize register ...
std::vector< uint32_t > workItemId[3]
VecRegContainer< sizeof(VecElemU32) *NumVecElemPerVecReg > VecRegContainerU32
Cycles is a wrapper class for representing cycle counts, i.e.
bool isGmInstruction(GPUDynInstPtr ii)
void setStatus(status_e newStatus)
int mapSgpr(Wavefront *w, int sgprIndex)
void start(uint64_t _wfDynId, uint64_t _base_ptr)
void freeRegisterFile()
Freeing VRF space.
void validateRequestCounters()
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
statistics::Scalar numVecOpsExecuted
static const int InvalidID
Tick cyclesToTicks(Cycles c) const
WaitClass vectorSharedMemUnit
statistics::Distribution activeLanesPerGMemInstrDist
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
void resizeRegFiles(int num_vregs, int num_sregs)
void incLGKMInstsIssued()
bool vgprBitEnabled(int bit) const
statistics::Scalar numVecOpsExecutedMAC64
int scalarOutstandingReqsRdGm
RegisterManager * registerManager
statistics::Scalar numInstrExecuted
@ S_BARRIER
WF is stalled at a barrier.
Addr hostDispPktAddr() const
int scalarOutstandingReqsWrGm
Cycles vrf_lm_bus_latency
Wavefront(const Params &p)
int wgSize(int dim) const
uint32_t scratch_workitem_byte_size
uint32_t scratch_resource_descriptor[4]
bool isOldestInstWaitcnt()
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 mapWaveToScalarMem(Wavefront *w) const
int mapWaveToGlobalMem(Wavefront *w) const
void deleteFromPipeMap(Wavefront *w)
Abstract superclass for simulation objects.
void reserveLmResource(GPUDynInstPtr ii)
int gridSize(int dim) const
std::vector< WaitClass > scalarALUs
GPUDynInstPtr nextInstr()
std::vector< uint64_t > instExecPerSimd
Addr hostAMDQueueAddr
Host-side addr of the amd_queue_t on which this task was queued.
ComputeUnit * computeUnit
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
TokenManager * getTokenManager()
statistics::Scalar numVecOpsExecutedF16
statistics::Scalar numInstrExecuted
FetchUnit & fetchUnit(int simdId)
int mapVgpr(Wavefront *w, int vgprIndex)
int mapWaveToScalarAlu(Wavefront *w) const
std::shared_ptr< GPUDynInst > GPUDynInstPtr
void decVMemInstsIssued()
std::unordered_set< uint64_t > pipeMap
static constexpr T divCeil(const T &a, const U &b)
void updateInstStats(GPUDynInstPtr gpuDynInst)
statistics::Vector instCyclesLdsPerSimd
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
void decLGKMInstsIssued()
int vmWaitCnt
the following are used for waitcnt instructions vmWaitCnt: once set, we wait for the oustanding numbe...
statistics::Scalar numVecOpsExecutedMAD16
std::vector< int > reserveResources()
statistics::Scalar numVecOpsExecutedMAC16
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Cycles vrf_gm_bus_latency
statistics::Distribution controlFlowDivergenceDist
int mapWaveToLocalMem(Wavefront *w) const
statistics::Scalar numVecOpsExecutedFMA64
@ S_WAITCNT
wavefront has unsatisfied wait counts
bool sgprBitEnabled(int bit) const
void recvTokens(int num_tokens)
Increment the number of available tokens by num_tokens.
WaitClass vrfToLocalMemPipeBus
statistics::Distribution execRateDist
statistics::Scalar numVecOpsExecutedF32
std::vector< WaitClass > vectorALUs
bool isOldestInstScalarALU()
statistics::Distribution readsPerWrite
std::deque< GPUDynInstPtr > instructionBuffer
bool isLmInstruction(GPUDynInstPtr ii)
gem5::Wavefront::WavefrontStats stats
bool isOldestInstPrivMem()
void incVMemInstsIssued()
uint64_t scratch_backing_memory_location
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
uint32_t compute_tmpring_size_wavesize
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
WaitClass vectorGlobalMemUnit
statistics::Scalar totalCycles
int mapWaveToScalarAluGlobalIdx(Wavefront *w) const
statistics::Distribution vecRawDistance
void incVectorInstSrcOperand(int num_operands)
void reserveGmResource(GPUDynInstPtr ii)
Cycles srf_scm_bus_latency
bool isOldestInstScalarMem()
statistics::Scalar numVecOpsExecutedFMA16
#define panic(...)
This implements a cprintf based panic() function.
Counter value() const
Return the current value of this stat as its base type.
Generated on Thu Jun 16 2022 10:41:54 for gem5 by doxygen 1.8.17