gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
43 #include "base/statistics.hh"
44 #include "base/stats/group.hh"
46 #include "gpu-compute/misc.hh"
47 #include "gpu-compute/scheduler.hh"
48 
49 // Schedule or execution arbitration stage.
50 // From the pool of ready waves in the ready list,
51 // one wave is selected for each execution resource.
52 // The selection is made based on a scheduling policy
53 
54 class ComputeUnit;
55 class ScheduleToExecute;
57 class Wavefront;
58 
59 struct ComputeUnitParams;
60 
62 {
63  public:
64  ScheduleStage(const ComputeUnitParams &p, ComputeUnit &cu,
65  ScoreboardCheckToSchedule &from_scoreboard_check,
66  ScheduleToExecute &to_execute);
68  void init();
69  void exec();
70 
71  // Stats related variables and methods
72  const std::string& name() const { return _name; }
94  };
100  };
108  };
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  const std::string _name;
130 
131  // called by exec() to add a wave to schList if the RFs can support it
132  bool addToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst);
133  // re-insert a wave to schList if wave lost arbitration
134  // wave is inserted such that age order (oldest to youngest) is preserved
135  void reinsertToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst);
136  // check waves in schList to see if RF reads complete
138  // check execution resources for readiness
147  // check status of memory pipes and RF to Mem buses
148  void checkMemResources();
149  // resource ready check called by fillDispatchList
150  bool dispatchReady(const GPUDynInstPtr &gpu_dyn_inst);
151  // pick waves from schList and populate dispatchList with one wave
152  // per EXE resource type
153  void fillDispatchList();
154  // arbitrate Shared Mem Pipe VRF/LDS bus for waves in dispatchList
155  void arbitrateVrfToLdsBus();
156  // schedule destination operand writes to register files for waves in
157  // dispatchList
158  void scheduleRfDestOperands();
159  // invoked by scheduleRfDestOperands to schedule RF writes for a wave
160  bool schedRfWrites(int exeType, const GPUDynInstPtr &gpu_dyn_inst);
161  // reserve resources for waves surviving arbitration in dispatchList
162  void reserveResources();
163 
164  void doDispatchListTransition(int unitId, DISPATCH_STATUS s,
165  const GPUDynInstPtr &gpu_dyn_inst);
166  void doDispatchListTransition(int unitId, DISPATCH_STATUS s);
167 
168  // Set tracking wfDynId for each wave present in schedule stage
169  // Used to allow only one instruction per wave in schedule
170  std::unordered_set<uint64_t> wavesInSch;
171 
172  // List of waves (one list per exe resource) that are in schedule
173  // stage. Waves are added to this list after selected by scheduler
174  // from readyList. Waves are removed from this list and placed on
175  // dispatchList when status reaches SCHREADY.
176  // Waves are kept ordered by age for each resource, always favoring
177  // forward progress for the oldest wave.
178  // The maximum number of waves per resource can be determined by either
179  // the VRF/SRF availability or limits imposed by paremeters (to be added)
180  // of the SCH stage or CU.
182 
183  protected:
185  {
186  ScheduleStageStats(Stats::Group *parent, int num_exec_units);
187 
188  // Number of cycles with empty (or not empty) readyList, per execution
189  // resource, when the CU is active (not sleeping)
192 
193  // Number of cycles, per execution resource, when at least one wave
194  // was on the readyList and picked by scheduler, but was unable to be
195  // added to the schList, when the CU is active (not sleeping)
197 
198  // Number of cycles, per execution resource, when a wave is selected
199  // as candidate for dispatchList from schList
200  // Note: may be arbitrated off dispatchList (e.g., LDS arbitration)
202 
203  // Per execution resource stat, incremented once per cycle if no wave
204  // was selected as candidate for dispatch and moved to dispatchList
206 
207  // Number of times a wave is selected by the scheduler but cannot
208  // be added to the schList due to register files not being able to
209  // support reads or writes of operands. RF_ACCESS_NRDY condition is
210  // always incremented if at least one read/write not supported, other
211  // conditions are incremented independently from each other.
213 
214  // Number of times a wave is executing FLAT instruction and
215  // forces another wave occupying its required local memory resource
216  // to be deselected for execution, and placed back on schList
218 
219  // Count of times VRF and/or SRF blocks waves on schList from
220  // performing RFBUSY->RFREADY transition
222 
223  // Count of times resource required for dispatch is not ready and
224  // blocks wave in RFREADY state on schList from potentially moving
225  // to dispatchList
227  } stats;
228 };
229 
230 #endif // __SCHEDULE_STAGE_HH__
ScheduleStage::exec
void exec()
Definition: schedule_stage.cc:88
ScheduleStage::ScheduleStageStats::ScheduleStageStats
ScheduleStageStats(Stats::Group *parent, int num_exec_units)
Definition: schedule_stage.cc:786
ScheduleStage::ScheduleStageStats::rfAccessStalls
Stats::Vector rfAccessStalls
Definition: schedule_stage.hh:212
ScheduleStage::~ScheduleStage
~ScheduleStage()
Definition: schedule_stage.cc:66
ScheduleStage::schopdnonrdytype_e
schopdnonrdytype_e
Definition: schedule_stage.hh:95
ScheduleStage::SCH_VECTOR_MEM_COALESCER_NRDY
@ SCH_VECTOR_MEM_COALESCER_NRDY
Definition: schedule_stage.hh:78
group.hh
ScheduleStage::SCH_SRF_WR_ACCESS_NRDY
@ SCH_SRF_WR_ACCESS_NRDY
Definition: schedule_stage.hh:105
ScheduleStage::SCH_VECTOR_MEM_ISSUE_NRDY
@ SCH_VECTOR_MEM_ISSUE_NRDY
Definition: schedule_stage.hh:76
ScheduleStage::SCH_SRF_RD_ACCESS_NRDY
@ SCH_SRF_RD_ACCESS_NRDY
Definition: schedule_stage.hh:104
ScheduleStage::SCH_VRF_OPD_NRDY
@ SCH_VRF_OPD_NRDY
Definition: schedule_stage.hh:96
misc.hh
ScheduleStage::ScheduleStageStats
Definition: schedule_stage.hh:184
ScheduleStage::glbMemBusRdy
bool glbMemBusRdy
Definition: schedule_stage.hh:143
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:89
ScheduleStage::deleteFromSch
void deleteFromSch(Wavefront *w)
Definition: schedule_stage.cc:781
Stats::Vector
A vector of scalar stats.
Definition: statistics.hh:2007
ScheduleStage::locMemBusRdy
bool locMemBusRdy
Definition: schedule_stage.hh:145
ScheduleStage::scheduler
std::vector< Scheduler > scheduler
Definition: schedule_stage.hh:127
ScheduleStage::reserveResources
void reserveResources()
Definition: schedule_stage.cc:715
ScheduleStage::SCH_RF_ACCESS_NRDY_CONDITIONS
@ SCH_RF_ACCESS_NRDY_CONDITIONS
Definition: schedule_stage.hh:107
ScheduleStage::SCH_RF_OPD_NRDY_CONDITIONS
@ SCH_RF_OPD_NRDY_CONDITIONS
Definition: schedule_stage.hh:99
ScheduleStage::_name
const std::string _name
Definition: schedule_stage.hh:129
ScheduleStage::schList
std::vector< std::deque< std::pair< GPUDynInstPtr, SCH_STATUS > > > schList
Definition: schedule_stage.hh:181
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1933
ComputeUnit
Definition: compute_unit.hh:200
ScheduleStage::SCH_SCALAR_MEM_ISSUE_NRDY
@ SCH_SCALAR_MEM_ISSUE_NRDY
Definition: schedule_stage.hh:81
ScheduleStage::locMemIssueRdy
bool locMemIssueRdy
Definition: schedule_stage.hh:146
ScheduleStage::reinsertToSchList
void reinsertToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst)
Definition: schedule_stage.cc:360
ScheduleStage::schrfaccessnonrdytype_e
schrfaccessnonrdytype_e
Definition: schedule_stage.hh:101
ScheduleStage::SCH_LOCAL_MEM_FIFO_NRDY
@ SCH_LOCAL_MEM_FIFO_NRDY
Definition: schedule_stage.hh:86
ScheduleStage::ScheduleStageStats::ldsBusArbStalls
Stats::Scalar ldsBusArbStalls
Definition: schedule_stage.hh:217
ScheduleStage::SCH_VECTOR_MEM_BUS_BUSY_NRDY
@ SCH_VECTOR_MEM_BUS_BUSY_NRDY
Definition: schedule_stage.hh:77
ScheduleStage::SCH_SCALAR_MEM_BUS_BUSY_NRDY
@ SCH_SCALAR_MEM_BUS_BUSY_NRDY
Definition: schedule_stage.hh:82
ScheduleStage::SCH_RF_ACCESS_NRDY
@ SCH_RF_ACCESS_NRDY
Definition: schedule_stage.hh:106
ScheduleToExecute
Communication interface between Schedule and Execute stages.
Definition: comm.hh:97
ScheduleStage::SchNonRdyType
SchNonRdyType
Definition: schedule_stage.hh:73
MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:278
statistics.hh
ScheduleStage::SCH_CEDE_SIMD_NRDY
@ SCH_CEDE_SIMD_NRDY
Definition: schedule_stage.hh:80
ScheduleStage::SCH_LOCAL_MEM_BUS_BUSY_NRDY
@ SCH_LOCAL_MEM_BUS_BUSY_NRDY
Definition: schedule_stage.hh:85
ScheduleStage::glbMemIssueRdy
bool glbMemIssueRdy
Definition: schedule_stage.hh:144
ScheduleStage::ScheduleStage
ScheduleStage(const ComputeUnitParams &p, ComputeUnit &cu, ScoreboardCheckToSchedule &from_scoreboard_check, ScheduleToExecute &to_execute)
Definition: schedule_stage.cc:46
ScheduleStage::SCH_VECTOR_MEM_REQS_NRDY
@ SCH_VECTOR_MEM_REQS_NRDY
Definition: schedule_stage.hh:79
ScheduleStage::SCH_FLAT_MEM_ISSUE_NRDY
@ SCH_FLAT_MEM_ISSUE_NRDY
Definition: schedule_stage.hh:87
ScheduleStage::scalarMemIssueRdy
bool scalarMemIssueRdy
Definition: schedule_stage.hh:142
ScheduleStage::SCH_FLAT_MEM_BUS_BUSY_NRDY
@ SCH_FLAT_MEM_BUS_BUSY_NRDY
Definition: schedule_stage.hh:88
ScheduleStage::SCH_RF_OPD_NRDY
@ SCH_RF_OPD_NRDY
Definition: schedule_stage.hh:98
ScheduleStage::SCH_FLAT_MEM_REQS_NRDY
@ SCH_FLAT_MEM_REQS_NRDY
Definition: schedule_stage.hh:90
ScheduleStage::SCH_NRDY_CONDITIONS
@ SCH_NRDY_CONDITIONS
Definition: schedule_stage.hh:93
ScheduleStage::computeUnit
ComputeUnit & computeUnit
Definition: schedule_stage.hh:121
ScheduleStage::name
const std::string & name() const
Definition: schedule_stage.hh:72
ScheduleStage::scheduleRfDestOperands
void scheduleRfDestOperands()
Definition: schedule_stage.cc:260
ScheduleStage::toExecute
ScheduleToExecute & toExecute
Definition: schedule_stage.hh:123
ScheduleStage::SCH_FLAT_MEM_FIFO_NRDY
@ SCH_FLAT_MEM_FIFO_NRDY
Definition: schedule_stage.hh:91
ScheduleStage::ScheduleStageStats::rdyListNotEmpty
Stats::Vector rdyListNotEmpty
Definition: schedule_stage.hh:191
ScheduleStage::fromScoreboardCheck
ScoreboardCheckToSchedule & fromScoreboardCheck
Definition: schedule_stage.hh:122
ScheduleStage::vectorAluRdy
bool vectorAluRdy
Definition: schedule_stage.hh:139
scheduler.hh
ScheduleStage::scalarMemBusRdy
bool scalarMemBusRdy
Definition: schedule_stage.hh:141
ScheduleStage::scalarAluRdy
bool scalarAluRdy
Definition: schedule_stage.hh:140
ScheduleStage::SCH_VRF_WR_ACCESS_NRDY
@ SCH_VRF_WR_ACCESS_NRDY
Definition: schedule_stage.hh:103
ScheduleStage::SCH_SCALAR_MEM_FIFO_NRDY
@ SCH_SCALAR_MEM_FIFO_NRDY
Definition: schedule_stage.hh:83
ScoreboardCheckToSchedule
Communication interface between ScoreboardCheck and Schedule stages.
Definition: comm.hh:61
ScheduleStage::RFREADY
@ RFREADY
Definition: schedule_stage.hh:117
ScheduleStage::dispatchReady
bool dispatchReady(const GPUDynInstPtr &gpu_dyn_inst)
Definition: schedule_stage.cc:414
ScheduleStage::SCH_SCALAR_ALU_NRDY
@ SCH_SCALAR_ALU_NRDY
Definition: schedule_stage.hh:74
ScheduleStage::ScheduleStageStats::opdNrdyStalls
Stats::Vector opdNrdyStalls
Definition: schedule_stage.hh:221
ScheduleStage::RFBUSY
@ RFBUSY
Definition: schedule_stage.hh:116
ScheduleStage::SCH_STATUS
SCH_STATUS
Definition: schedule_stage.hh:114
Wavefront
Definition: wavefront.hh:59
ScheduleStage::checkMemResources
void checkMemResources()
Definition: schedule_stage.cc:376
ScheduleStage::ScheduleStageStats::schListToDispList
Stats::Vector schListToDispList
Definition: schedule_stage.hh:201
Stats::Group
Statistics container.
Definition: group.hh:87
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:292
ScheduleStage::ScheduleStageStats::schListToDispListStalls
Stats::Vector schListToDispListStalls
Definition: schedule_stage.hh:205
ScheduleStage::SCH_LOCAL_MEM_ISSUE_NRDY
@ SCH_LOCAL_MEM_ISSUE_NRDY
Definition: schedule_stage.hh:84
ScheduleStage::wavesInSch
std::unordered_set< uint64_t > wavesInSch
Definition: schedule_stage.hh:170
ScheduleStage::ScheduleStageStats::addToSchListStalls
Stats::Vector addToSchListStalls
Definition: schedule_stage.hh:196
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
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:102
ScheduleStage::checkRfOperandReadComplete
void checkRfOperandReadComplete()
Definition: schedule_stage.cc:659
ScheduleStage::ScheduleStageStats::rdyListEmpty
Stats::Vector rdyListEmpty
Definition: schedule_stage.hh:190
ScheduleStage
Definition: schedule_stage.hh:61
DISPATCH_STATUS
DISPATCH_STATUS
Definition: exec_stage.hh:58
ScheduleStage::fillDispatchList
void fillDispatchList()
Definition: schedule_stage.cc:554
ScheduleStage::schedRfWrites
bool schedRfWrites(int exeType, const GPUDynInstPtr &gpu_dyn_inst)
Definition: schedule_stage.cc:224
exec_stage.hh
ScheduleStage::stats
ScheduleStage::ScheduleStageStats stats
ScheduleStage::arbitrateVrfToLdsBus
void arbitrateVrfToLdsBus()
Definition: schedule_stage.cc:618
ScheduleStage::doDispatchListTransition
void doDispatchListTransition(int unitId, DISPATCH_STATUS s, const GPUDynInstPtr &gpu_dyn_inst)
Definition: schedule_stage.cc:211
ScheduleStage::SCH_VECTOR_ALU_NRDY
@ SCH_VECTOR_ALU_NRDY
Definition: schedule_stage.hh:75
ScheduleStage::SCH_RDY
@ SCH_RDY
Definition: schedule_stage.hh:92
ScheduleStage::ScheduleStageStats::dispNrdyStalls
Stats::Vector dispNrdyStalls
Definition: schedule_stage.hh:226
ScheduleStage::SCH_SRF_OPD_NRDY
@ SCH_SRF_OPD_NRDY
Definition: schedule_stage.hh:97

Generated on Tue Mar 23 2021 19:41:27 for gem5 by doxygen 1.8.17