Tom Stellard | 0d23ebe | 2016-08-29 19:42:52 +0000 | [diff] [blame] | 1 | //===-- GCNSchedStrategy.h - GCN Scheduler Strategy -*- C++ -*-------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | /// \file |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_LIB_TARGET_AMDGPU_GCNSCHEDSTRATEGY_H |
| 15 | #define LLVM_LIB_TARGET_AMDGPU_GCNSCHEDSTRATEGY_H |
| 16 | |
| 17 | #include "llvm/CodeGen/MachineScheduler.h" |
| 18 | |
| 19 | namespace llvm { |
| 20 | |
| 21 | class SIRegisterInfo; |
| 22 | |
| 23 | /// This is a minimal scheduler strategy. The main difference between this |
| 24 | /// and the GenericScheduler is that GCNSchedStrategy uses different |
| 25 | /// heuristics to determine excess/critical pressure sets. Its goal is to |
| 26 | /// maximize kernel occupancy (i.e. maximum number of waves per simd). |
| 27 | class GCNMaxOccupancySchedStrategy : public GenericScheduler { |
Stanislav Mekhanoshin | 582a523 | 2017-02-15 17:19:50 +0000 | [diff] [blame] | 28 | friend class GCNScheduleDAGMILive; |
Tom Stellard | 0d23ebe | 2016-08-29 19:42:52 +0000 | [diff] [blame] | 29 | |
| 30 | SUnit *pickNodeBidirectional(bool &IsTopNode); |
| 31 | |
| 32 | void pickNodeFromQueue(SchedBoundary &Zone, const CandPolicy &ZonePolicy, |
| 33 | const RegPressureTracker &RPTracker, |
| 34 | SchedCandidate &Cand); |
| 35 | |
| 36 | void initCandidate(SchedCandidate &Cand, SUnit *SU, |
| 37 | bool AtTop, const RegPressureTracker &RPTracker, |
| 38 | const SIRegisterInfo *SRI, |
Stanislav Mekhanoshin | 582a523 | 2017-02-15 17:19:50 +0000 | [diff] [blame] | 39 | unsigned SGPRPressure, unsigned VGPRPressure); |
Tom Stellard | 0d23ebe | 2016-08-29 19:42:52 +0000 | [diff] [blame] | 40 | |
Stanislav Mekhanoshin | 582a523 | 2017-02-15 17:19:50 +0000 | [diff] [blame] | 41 | unsigned SGPRExcessLimit; |
| 42 | unsigned VGPRExcessLimit; |
| 43 | unsigned SGPRCriticalLimit; |
| 44 | unsigned VGPRCriticalLimit; |
Tom Stellard | 0d23ebe | 2016-08-29 19:42:52 +0000 | [diff] [blame] | 45 | |
| 46 | public: |
| 47 | GCNMaxOccupancySchedStrategy(const MachineSchedContext *C); |
| 48 | |
| 49 | SUnit *pickNode(bool &IsTopNode) override; |
Stanislav Mekhanoshin | 582a523 | 2017-02-15 17:19:50 +0000 | [diff] [blame] | 50 | |
| 51 | void initialize(ScheduleDAGMI *DAG) override; |
| 52 | }; |
| 53 | |
| 54 | class GCNScheduleDAGMILive : public ScheduleDAGMILive { |
Stanislav Mekhanoshin | 282e8e4 | 2017-02-28 17:22:39 +0000 | [diff] [blame^] | 55 | |
| 56 | // Region live-ins. |
| 57 | DenseMap<unsigned, LaneBitmask> LiveIns; |
| 58 | |
| 59 | // Number of live-ins to the current region, first SGPR then VGPR. |
| 60 | std::pair<unsigned, unsigned> LiveInPressure; |
| 61 | |
| 62 | // Collect current region live-ins. |
| 63 | void discoverLiveIns(); |
| 64 | |
| 65 | // Return current region pressure. First value is SGPR number, second is VGPR. |
| 66 | std::pair<unsigned, unsigned> getRealRegPressure() const; |
| 67 | |
Stanislav Mekhanoshin | 582a523 | 2017-02-15 17:19:50 +0000 | [diff] [blame] | 68 | public: |
| 69 | GCNScheduleDAGMILive(MachineSchedContext *C, |
| 70 | std::unique_ptr<MachineSchedStrategy> S) : |
| 71 | ScheduleDAGMILive(C, std::move(S)) {} |
| 72 | |
| 73 | void schedule() override; |
Stanislav Mekhanoshin | 282e8e4 | 2017-02-28 17:22:39 +0000 | [diff] [blame^] | 74 | |
| 75 | void finalizeSchedule() override; |
Tom Stellard | 0d23ebe | 2016-08-29 19:42:52 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // End namespace llvm |
| 79 | |
| 80 | #endif // GCNSCHEDSTRATEGY_H |