Skip to content

Commit

Permalink
[AMDGPU] Fix amdgpu-waves-per-eu accounting in scheduler
Browse files Browse the repository at this point in the history
We cannot query this attribute from a subtarget given a machine function.
At this point attribute itself is already unavailable and can only be
obtained through MFI.

Differential Revision: https://reviews.llvm.org/D46781

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332166 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rampitec committed May 12, 2018
1 parent 7e911da commit cf1a1cb
Show file tree
Hide file tree
Showing 3 changed files with 598 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/Target/AMDGPU/GCNIterativeScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,9 @@ void GCNIterativeScheduler::scheduleMinReg(bool force) {
void GCNIterativeScheduler::scheduleILP(
bool TryMaximizeOccupancy) {
const auto &ST = MF.getSubtarget<SISubtarget>();
const SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
auto TgtOcc = std::min(ST.getOccupancyWithLocalMemSize(MF),
ST.getWavesPerEU(MF.getFunction()).second);
MFI->getMaxWavesPerEU());

sortRegionsByPressure(TgtOcc);
auto Occ = Regions.front()->MaxPressure.getOccupancy(ST);
Expand Down
7 changes: 5 additions & 2 deletions lib/Target/AMDGPU/GCNSchedStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,9 @@ GCNScheduleDAGMILive::GCNScheduleDAGMILive(MachineSchedContext *C,
ScheduleDAGMILive(C, std::move(S)),
ST(MF.getSubtarget<SISubtarget>()),
MFI(*MF.getInfo<SIMachineFunctionInfo>()),
StartingOccupancy(ST.getOccupancyWithLocalMemSize(MFI.getLDSSize(),
MF.getFunction())),
StartingOccupancy(std::min(ST.getOccupancyWithLocalMemSize(MFI.getLDSSize(),
MF.getFunction()),
MFI.getMaxWavesPerEU())),
MinOccupancy(StartingOccupancy), Stage(0), RegionIdx(0) {

DEBUG(dbgs() << "Starting occupancy is " << StartingOccupancy << ".\n");
Expand Down Expand Up @@ -368,6 +369,8 @@ void GCNScheduleDAGMILive::schedule() {
PressureAfter.getVGPRNum(), MF);
unsigned WavesBefore = getMaxWaves(PressureBefore.getSGPRNum(),
PressureBefore.getVGPRNum(), MF);
WavesAfter = std::min(WavesAfter, MFI.getMaxWavesPerEU());
WavesBefore = std::min(WavesBefore, MFI.getMaxWavesPerEU());
DEBUG(dbgs() << "Occupancy before scheduling: " << WavesBefore <<
", after " << WavesAfter << ".\n");

Expand Down
Loading

0 comments on commit cf1a1cb

Please sign in to comment.