Skip to content

Commit 188e02f

Browse files
committed
[AMDGPU] Update comments.
1 parent afa551c commit 188e02f

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,22 +280,30 @@ void GCNHazardRecognizer::processBundle() {
280280
CurrCycleInstr = nullptr;
281281
}
282282

283-
void GCNHazardRecognizer::reverseProcessBundle() {
283+
void GCNHazardRecognizer::processBundleBottomUp() {
284+
// Step through each instruction in the bundle in bottom-up order.
284285
MachineBasicBlock::instr_iterator MI =
285286
std::next(CurrCycleInstr->getIterator());
286287
MachineBasicBlock::instr_iterator E =
287288
CurrCycleInstr->getParent()->instr_end();
288289

290+
// Evict stale entries to maintain a fixed lookahead window.
291+
// TODO: Hazard detection is not yet implemented. This scheduling
292+
// is intended for GFX11 and newer.
289293
for (; MI != E && MI->isInsideBundle(); ++MI) {
290294
CurrCycleInstr = &*MI;
291-
for (unsigned I = 0, E = MaxLookAhead - 1; I < E; ++I) {
292-
if (!EmittedInstrs.empty())
293-
EmittedInstrs.pop_back();
294-
}
295+
296+
// Remove up to (MaxLookAhead - 1) oldest entries.
297+
for (unsigned I = 0, E = MaxLookAhead - 1; I < E && !EmittedInstrs.empty();
298+
++I)
299+
EmittedInstrs.pop_back();
295300

296301
EmittedInstrs.push_back(CurrCycleInstr);
302+
303+
// Keep only the most recent MaxLookAhead entries
297304
EmittedInstrs.resize(MaxLookAhead);
298305
}
306+
299307
CurrCycleInstr = nullptr;
300308
}
301309

@@ -436,14 +444,16 @@ void GCNHazardRecognizer::AdvanceCycle() {
436444
}
437445

438446
void GCNHazardRecognizer::RecedeCycle() {
447+
// If no instruction was issued this cycle, pop the oldest placeholder.
439448
if (!CurrCycleInstr) {
440449
if (!EmittedInstrs.empty())
441450
EmittedInstrs.pop_back();
442451
return;
443452
}
444453

454+
// If this is a bundle header, handle the entire bundle here.
445455
if (CurrCycleInstr->isBundle()) {
446-
reverseProcessBundle();
456+
processBundleBottomUp();
447457
return;
448458
}
449459

@@ -453,14 +463,21 @@ void GCNHazardRecognizer::RecedeCycle() {
453463
return;
454464
}
455465

466+
// Add current instruction to the emitted list.
456467
EmittedInstrs.push_back(CurrCycleInstr);
457-
for (unsigned i = 1, e = std::min(NumWaitStates, getMaxLookAhead()); i < e;
458-
++i) {
468+
469+
// Model remaining wait states by removing older placeholders.
470+
for (unsigned I = 1, E = std::min(NumWaitStates, getMaxLookAhead()); I < E;
471+
++I) {
459472
if (!EmittedInstrs.empty())
460473
EmittedInstrs.pop_back();
461474
}
462475

476+
// getMaxLookahead() is the largest number of wait states we will ever need
477+
// to insert, so there is no point in keeping track of more than that many
478+
// wait states.
463479
EmittedInstrs.resize(getMaxLookAhead());
480+
464481
CurrCycleInstr = nullptr;
465482
}
466483

llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ class GCNHazardRecognizer final : public ScheduleHazardRecognizer {
6969
// Advance over a MachineInstr bundle. Look for hazards in the bundled
7070
// instructions.
7171
void processBundle();
72-
void reverseProcessBundle();
72+
// Recede over a MachineInstr bundle. Adds bundled instructions to the
73+
// EmittedInstrs queue in bottom-up scheduling mode.
74+
// TODO: Hazard detection is not yet implemented.
75+
void processBundleBottomUp();
7376

7477
// Run on an individual instruction in hazard recognizer mode. This can be
7578
// used on a newly inserted instruction before returning from PreEmitNoops.

0 commit comments

Comments
 (0)