gem5  v20.1.0.0
schedule_stage.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * For use for simulation and test purposes only
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef __SCHEDULE_STAGE_HH__
35 #define __SCHEDULE_STAGE_HH__
36 
37 #include <deque>
38 #include <unordered_map>
39 #include <unordered_set>
40 #include <utility>
41 #include <vector>
42 
44 #include "gpu-compute/misc.hh"
45 #include "gpu-compute/scheduler.hh"
46 
47 // Schedule or execution arbitration stage.
48 // From the pool of ready waves in the ready list,
49 // one wave is selected for each execution resource.
50 // The selection is made based on a scheduling policy
51 
52 class ComputeUnit;
53 class ScheduleToExecute;
55 class Wavefront;
56 
57 struct ComputeUnitParams;
58 
60 {
61  public:
62  ScheduleStage(const ComputeUnitParams *p, ComputeUnit &cu,
63  ScoreboardCheckToSchedule &from_scoreboard_check,
64  ScheduleToExecute &to_execute);
66  void init();
67  void exec();
68 
69  // Stats related variables and methods
70  const std::string& name() const { return _name; }
92  };
98  };
106  };
107 
108  void regStats();
109 
110  // Called by ExecStage to inform SCH of instruction execution
111  void deleteFromSch(Wavefront *w);
112 
113  // Schedule List status
115  {
116  RFBUSY = 0, // RF busy reading operands
117  RFREADY, // ready for exec
118  };
119 
120  private:
124 
125  // Each execution resource will have its own
126  // scheduler and a dispatch list
128 
129  // Stats
130 
131  // Number of cycles with empty (or not empty) readyList, per execution
132  // resource, when the CU is active (not sleeping)
135 
136  // Number of cycles, per execution resource, when at least one wave
137  // was on the readyList and picked by scheduler, but was unable to be
138  // added to the schList, when the CU is active (not sleeping)
140 
141  // Number of cycles, per execution resource, when a wave is selected
142  // as candidate for dispatchList from schList
143  // Note: may be arbitrated off dispatchList (e.g., LDS arbitration)
145 
146  // Per execution resource stat, incremented once per cycle if no wave
147  // was selected as candidate for dispatch and moved to dispatchList
149 
150  // Number of times a wave is selected by the scheduler but cannot
151  // be added to the schList due to register files not being able to
152  // support reads or writes of operands. RF_ACCESS_NRDY condition is always
153  // incremented if at least one read/write not supported, other
154  // conditions are incremented independently from each other.
156 
157  // Number of times a wave is executing FLAT instruction and
158  // forces another wave occupying its required local memory resource
159  // to be deselected for execution, and placed back on schList
161 
162  // Count of times VRF and/or SRF blocks waves on schList from
163  // performing RFBUSY->RFREADY transition
165 
166  // Count of times resource required for dispatch is not ready and
167  // blocks wave in RFREADY state on schList from potentially moving
168  // to dispatchList
170 
171  const std::string _name;
172 
173  // called by exec() to add a wave to schList if the RFs can support it
174  bool addToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst);
175  // re-insert a wave to schList if wave lost arbitration
176  // wave is inserted such that age order (oldest to youngest) is preserved
177  void reinsertToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst);
178  // check waves in schList to see if RF reads complete
180  // check execution resources for readiness
189  // check status of memory pipes and RF to Mem buses
190  void checkMemResources();
191  // resource ready check called by fillDispatchList
192  bool dispatchReady(const GPUDynInstPtr &gpu_dyn_inst);
193  // pick waves from schList and populate dispatchList with one wave
194  // per EXE resource type
195  void fillDispatchList();
196  // arbitrate Shared Mem Pipe VRF/LDS bus for waves in dispatchList
197  void arbitrateVrfToLdsBus();
198  // schedule destination operand writes to register files for waves in
199  // dispatchList
200  void scheduleRfDestOperands();
201  // invoked by scheduleRfDestOperands to schedule RF writes for a wave
202  bool schedRfWrites(int exeType, const GPUDynInstPtr &gpu_dyn_inst);
203  // reserve resources for waves surviving arbitration in dispatchList
204  void reserveResources();
205 
206  void doDispatchListTransition(int unitId, DISPATCH_STATUS s,
207  const GPUDynInstPtr &gpu_dyn_inst);
208  void doDispatchListTransition(int unitId, DISPATCH_STATUS s);
209 
210  // Set tracking wfDynId for each wave present in schedule stage
211  // Used to allow only one instruction per wave in schedule
212  std::unordered_set<uint64_t> wavesInSch;
213 
214  // List of waves (one list per exe resource) that are in schedule
215  // stage. Waves are added to this list after selected by scheduler
216  // from readyList. Waves are removed from this list and placed on
217  // dispatchList when status reaches SCHREADY.
218  // Waves are kept ordered by age for each resource, always favoring
219  // forward progress for the oldest wave.
220  // The maximum number of waves per resource can be determined by either
221  // the VRF/SRF availability or limits imposed by paremeters (to be added)
222  // of the SCH stage or CU.
224 };
225 
226 #endif // __SCHEDULE_STAGE_HH__
ScheduleStage::exec
void exec()
Definition: schedule_stage.cc:88
ScheduleStage::~ScheduleStage
~ScheduleStage()
Definition: schedule_stage.cc:66
ScheduleStage::schopdnonrdytype_e
schopdnonrdytype_e
Definition: schedule_stage.hh:93
ScheduleStage::SCH_VECTOR_MEM_COALESCER_NRDY
@ SCH_VECTOR_MEM_COALESCER_NRDY
Definition: schedule_stage.hh:76
ScheduleStage::regStats
void regStats()
Definition: schedule_stage.cc:778
ScheduleStage::SCH_SRF_WR_ACCESS_NRDY
@ SCH_SRF_WR_ACCESS_NRDY
Definition: schedule_stage.hh:103
ScheduleStage::SCH_VECTOR_MEM_ISSUE_NRDY
@ SCH_VECTOR_MEM_ISSUE_NRDY
Definition: schedule_stage.hh:74
ScheduleStage::ldsBusArbStalls
Stats::Scalar ldsBusArbStalls
Definition: schedule_stage.hh:160
ScheduleStage::ScheduleStage
ScheduleStage(const ComputeUnitParams *p, ComputeUnit &cu, ScoreboardCheckToSchedule &from_scoreboard_check, ScheduleToExecute &to_execute)
Definition: schedule_stage.cc:46
ScheduleStage::SCH_SRF_RD_ACCESS_NRDY
@ SCH_SRF_RD_ACCESS_NRDY
Definition: schedule_stage.hh:102
ScheduleStage::SCH_VRF_OPD_NRDY
@ SCH_VRF_OPD_NRDY
Definition: schedule_stage.hh:94
misc.hh
ScheduleStage::glbMemBusRdy
bool glbMemBusRdy
Definition: schedule_stage.hh:185
ScheduleStage::init
void init()
Definition: schedule_stage.cc:74
std::vector< Scheduler >
ScheduleStage::SCH_FLAT_MEM_COALESCER_NRDY
@ SCH_FLAT_MEM_COALESCER_NRDY
Definition: schedule_stage.hh:87
ScheduleStage::deleteFromSch
void deleteFromSch(Wavefront *w)
Definition: schedule_stage.cc:772
Stats::Vector
A vector of scalar stats.
Definition: statistics.hh:2575
ScheduleStage::locMemBusRdy
bool locMemBusRdy
Definition: schedule_stage.hh:187
ScheduleStage::scheduler
std::vector< Scheduler > scheduler
Definition: schedule_stage.hh:127
ScheduleStage::reserveResources
void reserveResources()
Definition: schedule_stage.cc:706
ScheduleStage::SCH_RF_ACCESS_NRDY_CONDITIONS
@ SCH_RF_ACCESS_NRDY_CONDITIONS
Definition: schedule_stage.hh:105
ScheduleStage::SCH_RF_OPD_NRDY_CONDITIONS
@ SCH_RF_OPD_NRDY_CONDITIONS
Definition: schedule_stage.hh:97
ScheduleStage::_name
const std::string _name
Definition: schedule_stage.hh:171
ScheduleStage::schList
std::vector< std::deque< std::pair< GPUDynInstPtr, SCH_STATUS > > > schList
Definition: schedule_stage.hh:223
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
ComputeUnit
Definition: compute_unit.hh:198
ScheduleStage::SCH_SCALAR_MEM_ISSUE_NRDY
@ SCH_SCALAR_MEM_ISSUE_NRDY
Definition: schedule_stage.hh:79
ScheduleStage::locMemIssueRdy
bool locMemIssueRdy
Definition: schedule_stage.hh:188
ScheduleStage::reinsertToSchList
void reinsertToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst)
Definition: schedule_stage.cc:351
ScheduleStage::schrfaccessnonrdytype_e
schrfaccessnonrdytype_e
Definition: schedule_stage.hh:99
ScheduleStage::SCH_LOCAL_MEM_FIFO_NRDY
@ SCH_LOCAL_MEM_FIFO_NRDY
Definition: schedule_stage.hh:84
ScheduleStage::SCH_VECTOR_MEM_BUS_BUSY_NRDY
@ SCH_VECTOR_MEM_BUS_BUSY_NRDY
Definition: schedule_stage.hh:75
ScheduleStage::SCH_SCALAR_MEM_BUS_BUSY_NRDY
@ SCH_SCALAR_MEM_BUS_BUSY_NRDY
Definition: schedule_stage.hh:80
ScheduleStage::SCH_RF_ACCESS_NRDY
@ SCH_RF_ACCESS_NRDY
Definition: schedule_stage.hh:104
ScheduleToExecute
Communication interface between Schedule and Execute stages.
Definition: comm.hh:99
ScheduleStage::SchNonRdyType
SchNonRdyType
Definition: schedule_stage.hh:71
ScheduleStage::rfAccessStalls
Stats::Vector rfAccessStalls
Definition: schedule_stage.hh:155
MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:278
ScheduleStage::SCH_CEDE_SIMD_NRDY
@ SCH_CEDE_SIMD_NRDY
Definition: schedule_stage.hh:78
ScheduleStage::SCH_LOCAL_MEM_BUS_BUSY_NRDY
@ SCH_LOCAL_MEM_BUS_BUSY_NRDY
Definition: schedule_stage.hh:83
ScheduleStage::rdyListNotEmpty
Stats::Vector rdyListNotEmpty
Definition: schedule_stage.hh:134
ScheduleStage::glbMemIssueRdy
bool glbMemIssueRdy
Definition: schedule_stage.hh:186
ScheduleStage::SCH_VECTOR_MEM_REQS_NRDY
@ SCH_VECTOR_MEM_REQS_NRDY
Definition: schedule_stage.hh:77
ScheduleStage::rdyListEmpty
Stats::Vector rdyListEmpty
Definition: schedule_stage.hh:133
ScheduleStage::SCH_FLAT_MEM_ISSUE_NRDY
@ SCH_FLAT_MEM_ISSUE_NRDY
Definition: schedule_stage.hh:85
ScheduleStage::scalarMemIssueRdy
bool scalarMemIssueRdy
Definition: schedule_stage.hh:184
ScheduleStage::SCH_FLAT_MEM_BUS_BUSY_NRDY
@ SCH_FLAT_MEM_BUS_BUSY_NRDY
Definition: schedule_stage.hh:86
ScheduleStage::SCH_RF_OPD_NRDY
@ SCH_RF_OPD_NRDY
Definition: schedule_stage.hh:96
ScheduleStage::SCH_FLAT_MEM_REQS_NRDY
@ SCH_FLAT_MEM_REQS_NRDY
Definition: schedule_stage.hh:88
ScheduleStage::SCH_NRDY_CONDITIONS
@ SCH_NRDY_CONDITIONS
Definition: schedule_stage.hh:91
ScheduleStage::computeUnit
ComputeUnit & computeUnit
Definition: schedule_stage.hh:121
ScheduleStage::name
const std::string & name() const
Definition: schedule_stage.hh:70
ScheduleStage::scheduleRfDestOperands
void scheduleRfDestOperands()
Definition: schedule_stage.cc:257
ScheduleStage::toExecute
ScheduleToExecute & toExecute
Definition: schedule_stage.hh:123
ScheduleStage::SCH_FLAT_MEM_FIFO_NRDY
@ SCH_FLAT_MEM_FIFO_NRDY
Definition: schedule_stage.hh:89
ScheduleStage::fromScoreboardCheck
ScoreboardCheckToSchedule & fromScoreboardCheck
Definition: schedule_stage.hh:122
ScheduleStage::vectorAluRdy
bool vectorAluRdy
Definition: schedule_stage.hh:181
scheduler.hh
ScheduleStage::scalarMemBusRdy
bool scalarMemBusRdy
Definition: schedule_stage.hh:183
ScheduleStage::scalarAluRdy
bool scalarAluRdy
Definition: schedule_stage.hh:182
ScheduleStage::SCH_VRF_WR_ACCESS_NRDY
@ SCH_VRF_WR_ACCESS_NRDY
Definition: schedule_stage.hh:101
ScheduleStage::addToSchListStalls
Stats::Vector addToSchListStalls
Definition: schedule_stage.hh:139
ScheduleStage::SCH_SCALAR_MEM_FIFO_NRDY
@ SCH_SCALAR_MEM_FIFO_NRDY
Definition: schedule_stage.hh:81
ScoreboardCheckToSchedule
Communication interface between ScoreboardCheck and Schedule stages.
Definition: comm.hh:63
ScheduleStage::RFREADY
@ RFREADY
Definition: schedule_stage.hh:117
ScheduleStage::dispatchReady
bool dispatchReady(const GPUDynInstPtr &gpu_dyn_inst)
Definition: schedule_stage.cc:405
ScheduleStage::SCH_SCALAR_ALU_NRDY
@ SCH_SCALAR_ALU_NRDY
Definition: schedule_stage.hh:72
ScheduleStage::dispNrdyStalls
Stats::Vector dispNrdyStalls
Definition: schedule_stage.hh:169
ScheduleStage::RFBUSY
@ RFBUSY
Definition: schedule_stage.hh:116
ScheduleStage::SCH_STATUS
SCH_STATUS
Definition: schedule_stage.hh:114
Wavefront
Definition: wavefront.hh:57
ScheduleStage::checkMemResources
void checkMemResources()
Definition: schedule_stage.cc:367
GPUDynInstPtr
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:48
ScheduleStage::addToSchList
bool addToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst)
Definition: schedule_stage.cc:289
ScheduleStage::SCH_LOCAL_MEM_ISSUE_NRDY
@ SCH_LOCAL_MEM_ISSUE_NRDY
Definition: schedule_stage.hh:82
ScheduleStage::wavesInSch
std::unordered_set< uint64_t > wavesInSch
Definition: schedule_stage.hh:212
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
ScheduleStage::schListToDispList
Stats::Vector schListToDispList
Definition: schedule_stage.hh:144
ArmISA::s
Bitfield< 4 > s
Definition: miscregs_types.hh:556
ScheduleStage::SCH_VRF_RD_ACCESS_NRDY
@ SCH_VRF_RD_ACCESS_NRDY
Definition: schedule_stage.hh:100
ScheduleStage::opdNrdyStalls
Stats::Vector opdNrdyStalls
Definition: schedule_stage.hh:164
ScheduleStage::checkRfOperandReadComplete
void checkRfOperandReadComplete()
Definition: schedule_stage.cc:650
ScheduleStage::schListToDispListStalls
Stats::Vector schListToDispListStalls
Definition: schedule_stage.hh:148
ScheduleStage
Definition: schedule_stage.hh:59
DISPATCH_STATUS
DISPATCH_STATUS
Definition: exec_stage.hh:57
ScheduleStage::fillDispatchList
void fillDispatchList()
Definition: schedule_stage.cc:545
ScheduleStage::schedRfWrites
bool schedRfWrites(int exeType, const GPUDynInstPtr &gpu_dyn_inst)
Definition: schedule_stage.cc:221
exec_stage.hh
ScheduleStage::arbitrateVrfToLdsBus
void arbitrateVrfToLdsBus()
Definition: schedule_stage.cc:609
ScheduleStage::doDispatchListTransition
void doDispatchListTransition(int unitId, DISPATCH_STATUS s, const GPUDynInstPtr &gpu_dyn_inst)
Definition: schedule_stage.cc:208
ScheduleStage::SCH_VECTOR_ALU_NRDY
@ SCH_VECTOR_ALU_NRDY
Definition: schedule_stage.hh:73
ScheduleStage::SCH_RDY
@ SCH_RDY
Definition: schedule_stage.hh:90
ScheduleStage::SCH_SRF_OPD_NRDY
@ SCH_SRF_OPD_NRDY
Definition: schedule_stage.hh:95

Generated on Wed Sep 30 2020 14:02:12 for gem5 by doxygen 1.8.17