gem5  v22.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  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef __SCHEDULE_STAGE_HH__
33 #define __SCHEDULE_STAGE_HH__
34 
35 #include <deque>
36 #include <unordered_map>
37 #include <unordered_set>
38 #include <utility>
39 #include <vector>
40 
41 #include "base/statistics.hh"
42 #include "base/stats/group.hh"
44 #include "gpu-compute/misc.hh"
45 #include "gpu-compute/scheduler.hh"
46 
47 namespace gem5
48 {
49 
50 // Schedule or execution arbitration stage.
51 // From the pool of ready waves in the ready list,
52 // one wave is selected for each execution resource.
53 // The selection is made based on a scheduling policy
54 
55 class ComputeUnit;
56 class ScheduleToExecute;
57 class ScoreboardCheckToSchedule;
58 class Wavefront;
59 
60 struct ComputeUnitParams;
61 
63 {
64  public:
65  ScheduleStage(const ComputeUnitParams &p, ComputeUnit &cu,
66  ScoreboardCheckToSchedule &from_scoreboard_check,
67  ScheduleToExecute &to_execute);
69  void init();
70  void exec();
71 
72  // Stats related variables and methods
73  const std::string& name() const { return _name; }
75  {
96  };
98  {
103  };
105  {
112  };
113 
114  // Called by ExecStage to inform SCH of instruction execution
115  void deleteFromSch(Wavefront *w);
116 
117  // Schedule List status
119  {
120  RFBUSY = 0, // RF busy reading operands
121  RFREADY, // ready for exec
122  };
123 
124  private:
128 
129  // Each execution resource will have its own
130  // scheduler and a dispatch list
132 
133  const std::string _name;
134 
135  // called by exec() to add a wave to schList if the RFs can support it
136  bool addToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst);
137  // re-insert a wave to schList if wave lost arbitration
138  // wave is inserted such that age order (oldest to youngest) is preserved
139  void reinsertToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst);
140  // check waves in schList to see if RF reads complete
142  // check execution resources for readiness
151  // check status of memory pipes and RF to Mem buses
152  void checkMemResources();
153  // resource ready check called by fillDispatchList
154  bool dispatchReady(const GPUDynInstPtr &gpu_dyn_inst);
155  // pick waves from schList and populate dispatchList with one wave
156  // per EXE resource type
157  void fillDispatchList();
158  // arbitrate Shared Mem Pipe VRF/LDS bus for waves in dispatchList
159  void arbitrateVrfToLdsBus();
160  // schedule destination operand writes to register files for waves in
161  // dispatchList
162  void scheduleRfDestOperands();
163  // invoked by scheduleRfDestOperands to schedule RF writes for a wave
164  bool schedRfWrites(int exeType, const GPUDynInstPtr &gpu_dyn_inst);
165  // reserve resources for waves surviving arbitration in dispatchList
166  void reserveResources();
167 
168  void doDispatchListTransition(int unitId, DISPATCH_STATUS s,
169  const GPUDynInstPtr &gpu_dyn_inst);
170  void doDispatchListTransition(int unitId, DISPATCH_STATUS s);
171 
172  // Set tracking wfDynId for each wave present in schedule stage
173  // Used to allow only one instruction per wave in schedule
174  std::unordered_set<uint64_t> wavesInSch;
175 
176  // List of waves (one list per exe resource) that are in schedule
177  // stage. Waves are added to this list after selected by scheduler
178  // from readyList. Waves are removed from this list and placed on
179  // dispatchList when status reaches SCHREADY.
180  // Waves are kept ordered by age for each resource, always favoring
181  // forward progress for the oldest wave.
182  // The maximum number of waves per resource can be determined by either
183  // the VRF/SRF availability or limits imposed by paremeters (to be added)
184  // of the SCH stage or CU.
186 
187  protected:
189  {
190  ScheduleStageStats(statistics::Group *parent, int num_exec_units);
191 
192  // Number of cycles with empty (or not empty) readyList, per execution
193  // resource, when the CU is active (not sleeping)
196 
197  // Number of cycles, per execution resource, when at least one wave
198  // was on the readyList and picked by scheduler, but was unable to be
199  // added to the schList, when the CU is active (not sleeping)
201 
202  // Number of cycles, per execution resource, when a wave is selected
203  // as candidate for dispatchList from schList
204  // Note: may be arbitrated off dispatchList (e.g., LDS arbitration)
206 
207  // Per execution resource stat, incremented once per cycle if no wave
208  // was selected as candidate for dispatch and moved to dispatchList
210 
211  // Number of times a wave is selected by the scheduler but cannot
212  // be added to the schList due to register files not being able to
213  // support reads or writes of operands. RF_ACCESS_NRDY condition is
214  // always incremented if at least one read/write not supported, other
215  // conditions are incremented independently from each other.
217 
218  // Number of times a wave is executing FLAT instruction and
219  // forces another wave occupying its required local memory resource
220  // to be deselected for execution, and placed back on schList
222 
223  // Count of times VRF and/or SRF blocks waves on schList from
224  // performing RFBUSY->RFREADY transition
226 
227  // Count of times resource required for dispatch is not ready and
228  // blocks wave in RFREADY state on schList from potentially moving
229  // to dispatchList
231  } stats;
232 };
233 
234 } // namespace gem5
235 
236 #endif // __SCHEDULE_STAGE_HH__
void reinsertToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst)
void doDispatchListTransition(int unitId, DISPATCH_STATUS s, const GPUDynInstPtr &gpu_dyn_inst)
gem5::ScheduleStage::ScheduleStageStats stats
const std::string & name() const
ScheduleToExecute & toExecute
ScheduleStage(const ComputeUnitParams &p, ComputeUnit &cu, ScoreboardCheckToSchedule &from_scoreboard_check, ScheduleToExecute &to_execute)
const std::string _name
bool dispatchReady(const GPUDynInstPtr &gpu_dyn_inst)
std::vector< Scheduler > scheduler
std::vector< std::deque< std::pair< GPUDynInstPtr, SCH_STATUS > > > schList
ScoreboardCheckToSchedule & fromScoreboardCheck
std::unordered_set< uint64_t > wavesInSch
ComputeUnit & computeUnit
bool schedRfWrites(int exeType, const GPUDynInstPtr &gpu_dyn_inst)
void deleteFromSch(Wavefront *w)
bool addToSchList(int exeType, const GPUDynInstPtr &gpu_dyn_inst)
Communication interface between Schedule and Execute stages.
Definition: comm.hh:99
Communication interface between ScoreboardCheck and Schedule stages.
Definition: comm.hh:63
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
A vector of scalar stats.
Definition: statistics.hh:2007
STL vector class.
Definition: stl.hh:37
Bitfield< 1 > s
Definition: pagetable.hh:64
Bitfield< 6 > w
Definition: pagetable.hh:59
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:49
DISPATCH_STATUS
Definition: exec_stage.hh:60
Declaration of Statistics objects.
ScheduleStageStats(statistics::Group *parent, int num_exec_units)

Generated on Wed Dec 21 2022 10:22:35 for gem5 by doxygen 1.9.1