gem5  v20.1.0.0
exec_stage.cc
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 
35 
36 #include <sstream>
37 
38 #include "base/trace.hh"
39 #include "debug/GPUSched.hh"
42 #include "gpu-compute/wavefront.hh"
43 
44 ExecStage::ExecStage(const ComputeUnitParams *p, ComputeUnit &cu,
45  ScheduleToExecute &from_schedule)
46  : computeUnit(cu), fromSchedule(from_schedule),
47  lastTimeInstExecuted(false),
48  thisTimeInstExecuted(false), instrExecuted (false),
49  executionResourcesUsed(0), _name(cu.name() + ".ExecStage")
50 
51 {
53  idle_dur = 0;
54 }
55 
56 void
58 {
59  idle_dur = 0;
60 }
61 
62 void
63 ExecStage::collectStatistics(enum STAT_STATUS stage, int unitId) {
64  if (stage == IdleExec) {
65  // count cycles when no instruction to a specific execution resource
66  // is executed
68  } else if (stage == BusyExec) {
69  // count the number of cycles an instruction to a specific execution
70  // resource type was issued
72  thisTimeInstExecuted = true;
73  instrExecuted = true;
75  } else if (stage == PostExec) {
76  // count the number of transitions from active to idle
79  }
80 
83  idle_dur = 0;
84  } else if (!thisTimeInstExecuted) {
85  idle_dur++;
86  }
87 
89  // track the number of cycles we either issued at least
90  // instruction or issued no instructions at all
91  if (instrExecuted) {
93  } else {
95  }
97  }
98 }
99 
100 void
102 {
103  instrExecuted = false;
105  thisTimeInstExecuted = false;
106 }
107 
108 std::string
110 {
111  std::string s("INVALID");
112  switch (i) {
113  case EMPTY:
114  s = "EMPTY";
115  break;
116  case SKIP:
117  s = "SKIP";
118  break;
119  case EXREADY:
120  s = "EXREADY";
121  break;
122  }
123  return s;
124 }
125 
126 void
128 {
129  std::stringstream ss;
130  bool empty = true;
131  for (int i = 0; i < computeUnit.numExeUnits(); i++) {
133  ss << i << ": " << dispStatusToStr(s);
134  if (s != EMPTY) {
135  empty = false;
136  GPUDynInstPtr &gpu_dyn_inst = fromSchedule.readyInst(i);
137  Wavefront *wf = gpu_dyn_inst->wavefront();
138  ss << " SIMD[" << wf->simdId << "] WV[" << wf->wfDynId << "]: ";
139  ss << (wf->instructionBuffer.front())->seqNum() << ": ";
140  ss << (wf->instructionBuffer.front())->disassemble();
141  }
142  ss << "\n";
143  }
144  if (!empty) {
145  DPRINTF(GPUSched, "Dispatch List:\n%s", ss.str());
146  }
147 }
148 
149 void
151 {
152  initStatistics();
153  if (Debug::GPUSched) {
154  dumpDispList();
155  }
156  for (int unitId = 0; unitId < computeUnit.numExeUnits(); ++unitId) {
158  switch (s) {
159  case EMPTY:
160  // Do not execute if empty, waiting for VRF reads,
161  // or LM tied to GM waiting for VRF reads
162  collectStatistics(IdleExec, unitId);
163  break;
164  case EXREADY:
165  {
166  collectStatistics(BusyExec, unitId);
167  GPUDynInstPtr &gpu_dyn_inst = fromSchedule.readyInst(unitId);
168  assert(gpu_dyn_inst);
169  Wavefront *wf = gpu_dyn_inst->wavefront();
170  DPRINTF(GPUSched, "Exec[%d]: SIMD[%d] WV[%d]: %s\n",
171  unitId, wf->simdId, wf->wfDynId,
172  gpu_dyn_inst->disassemble());
173  DPRINTF(GPUSched, "dispatchList[%d] EXREADY->EMPTY\n", unitId);
174  wf->exec();
175  (computeUnit.scheduleStage).deleteFromSch(wf);
177  wf->freeResources();
178  break;
179  }
180  case SKIP:
181  {
182  collectStatistics(BusyExec, unitId);
183  GPUDynInstPtr &gpu_dyn_inst = fromSchedule.readyInst(unitId);
184  assert(gpu_dyn_inst);
185  Wavefront *wf = gpu_dyn_inst->wavefront();
186  DPRINTF(GPUSched, "dispatchList[%d] SKIP->EMPTY\n", unitId);
188  wf->freeResources();
189  break;
190  }
191  default:
192  panic("Unknown dispatch status in exec()\n");
193  }
194  }
195 
197 }
198 
199 void
201 {
203  .name(name() + ".num_transitions_active_to_idle")
204  .desc("number of CU transitions from active to idle")
205  ;
206 
208  .name(name() + ".num_cycles_with_no_issue")
209  .desc("number of cycles the CU issues nothing")
210  ;
211 
213  .name(name() + ".num_cycles_with_instr_issued")
214  .desc("number of cycles the CU issued at least one instruction")
215  ;
216 
217  spc
218  .init(0, computeUnit.numExeUnits(), 1)
219  .name(name() + ".spc")
220  .desc("Execution units active per cycle (Exec unit=SIMD,MemPipe)")
221  ;
222 
223  idleDur
224  .init(0,75,5)
225  .name(name() + ".idle_duration_in_cycles")
226  .desc("duration of idle periods in cycles")
227  ;
228 
231  .name(name() + ".num_cycles_issue_exec_rsrc")
232  .desc("Number of cycles at least one instruction issued to "
233  "execution resource type")
234  ;
235 
238  .name(name() + ".num_cycles_no_issue_exec_rsrc")
239  .desc("Number of clks no instructions issued to execution "
240  "resource type")
241  ;
242 
243  int c = 0;
244  for (int i = 0; i < computeUnit.numVectorALUs; i++,c++) {
245  std::string s = "VectorALU" + std::to_string(i);
248  }
249  for (int i = 0; i < computeUnit.numScalarALUs; i++,c++) {
250  std::string s = "ScalarALU" + std::to_string(i);
253  }
254  numCyclesWithNoInstrTypeIssued.subname(c, "VectorMemPipe");
255  numCyclesWithInstrTypeIssued.subname(c++, "VectorMemPipe");
256 
257  numCyclesWithNoInstrTypeIssued.subname(c, "SharedMemPipe");
258  numCyclesWithInstrTypeIssued.subname(c++, "SharedMemPipe");
259 
260  numCyclesWithNoInstrTypeIssued.subname(c, "ScalarMemPipe");
261  numCyclesWithInstrTypeIssued.subname(c++, "ScalarMemPipe");
262 }
STAT_STATUS
STAT_STATUS
Definition: exec_stage.hh:50
ExecStage::thisTimeInstExecuted
bool thisTimeInstExecuted
Definition: exec_stage.hh:106
ExecStage::collectStatistics
void collectStatistics(enum STAT_STATUS stage, int unitId)
Definition: exec_stage.cc:63
EMPTY
@ EMPTY
Definition: exec_stage.hh:59
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
ExecStage::idle_dur
uint64_t idle_dur
Definition: exec_stage.hh:111
ExecStage::numCyclesWithInstrIssued
Stats::Scalar numCyclesWithInstrIssued
Definition: exec_stage.hh:88
ScheduleToExecute::readyInst
GPUDynInstPtr & readyInst(int func_unit_id)
Definition: comm.cc:128
compute_unit.hh
ExecStage::dispStatusToStr
std::string dispStatusToStr(int j)
Definition: exec_stage.cc:109
sc_dt::to_string
const std::string to_string(sc_enc enc)
Definition: sc_fxdefs.cc:91
ExecStage::init
void init()
Definition: exec_stage.cc:57
ExecStage::exec
void exec()
Definition: exec_stage.cc:150
ExecStage::idleDur
Stats::Distribution idleDur
Definition: exec_stage.hh:109
ExecStage::initStatistics
void initStatistics()
Definition: exec_stage.cc:101
ComputeUnit::numExeUnits
int numExeUnits() const
Definition: compute_unit.cc:228
ScheduleToExecute::dispatchStatus
DISPATCH_STATUS dispatchStatus(int func_unit_id) const
Definition: comm.cc:151
ComputeUnit::scheduleStage
ScheduleStage scheduleStage
Definition: compute_unit.hh:279
wavefront.hh
ExecStage::lastTimeInstExecuted
bool lastTimeInstExecuted
Definition: exec_stage.hh:105
SKIP
@ SKIP
Definition: exec_stage.hh:61
ComputeUnit
Definition: compute_unit.hh:198
vector_register_file.hh
ScheduleToExecute::dispatchTransition
void dispatchTransition(const GPUDynInstPtr &gpu_dyn_inst, int func_unit_id, DISPATCH_STATUS disp_status)
Once the scheduler has chosen a winning WF for execution, and after the WF's oldest instruction's ope...
Definition: comm.cc:134
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
Wavefront::exec
void exec()
Definition: wavefront.cc:921
ScheduleToExecute
Communication interface between Schedule and Execute stages.
Definition: comm.hh:99
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
Wavefront::freeResources
void freeResources()
Definition: wavefront.cc:800
ExecStage::numCyclesWithInstrTypeIssued
Stats::Vector numCyclesWithInstrTypeIssued
Definition: exec_stage.hh:91
BusyExec
@ BusyExec
Definition: exec_stage.hh:53
Wavefront::simdId
const int simdId
Definition: wavefront.hh:92
ExecStage::ExecStage
ExecStage(const ComputeUnitParams *p, ComputeUnit &cu, ScheduleToExecute &from_schedule)
Definition: exec_stage.cc:44
ExecStage::fromSchedule
ScheduleToExecute & fromSchedule
Definition: exec_stage.hh:103
Stats::DataWrap::name
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Definition: statistics.hh:274
EXREADY
@ EXREADY
Definition: exec_stage.hh:60
name
const std::string & name()
Definition: trace.cc:50
Stats::VectorBase::init
Derived & init(size_type size)
Set this vector to have the given size.
Definition: statistics.hh:1177
ExecStage::numCyclesWithNoInstrTypeIssued
Stats::Vector numCyclesWithNoInstrTypeIssued
Definition: exec_stage.hh:95
ExecStage::numCyclesWithNoIssue
Stats::Scalar numCyclesWithNoIssue
Definition: exec_stage.hh:86
ExecStage::executionResourcesUsed
int executionResourcesUsed
Definition: exec_stage.hh:110
IdleExec
@ IdleExec
Definition: exec_stage.hh:52
ExecStage::spc
Stats::Distribution spc
Definition: exec_stage.hh:97
Stats::Distribution::init
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
Definition: statistics.hh:2634
Wavefront
Definition: wavefront.hh:57
PostExec
@ PostExec
Definition: exec_stage.hh:54
GPUDynInstPtr
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:48
Stats::DistBase::sample
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Definition: statistics.hh:1924
ExecStage::name
const std::string & name() const
Definition: exec_stage.hh:83
Wavefront::instructionBuffer
std::deque< GPUDynInstPtr > instructionBuffer
Definition: wavefront.hh:102
Stats::DataWrapVec::subname
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation.
Definition: statistics.hh:374
ExecStage::instrExecuted
bool instrExecuted
Definition: exec_stage.hh:107
ArmISA::c
Bitfield< 29 > c
Definition: miscregs_types.hh:50
trace.hh
ExecStage::dumpDispList
void dumpDispList()
Definition: exec_stage.cc:127
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
ArmISA::s
Bitfield< 4 > s
Definition: miscregs_types.hh:556
DISPATCH_STATUS
DISPATCH_STATUS
Definition: exec_stage.hh:57
ExecStage::computeUnit
ComputeUnit & computeUnit
Definition: exec_stage.hh:102
Stats::DataWrap::desc
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
Definition: statistics.hh:307
exec_stage.hh
ExecStage::numTransActiveIdle
Stats::Scalar numTransActiveIdle
Definition: exec_stage.hh:108
ExecStage::regStats
void regStats()
Definition: exec_stage.cc:200
Wavefront::wfDynId
uint64_t wfDynId
Definition: wavefront.hh:218
ComputeUnit::numScalarALUs
int numScalarALUs
Definition: compute_unit.hh:245
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
ComputeUnit::numVectorALUs
int numVectorALUs
Definition: compute_unit.hh:241

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