gem5  v20.0.0.3
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 
37 #include "gpu-compute/wavefront.hh"
38 
39 ExecStage::ExecStage(const ComputeUnitParams *p) : numSIMDs(p->num_SIMDs),
40  numMemUnits(p->num_global_mem_pipes + p->num_shared_mem_pipes),
41  vectorAluInstAvail(nullptr), glbMemInstAvail(nullptr),
42  shrMemInstAvail(nullptr), lastTimeInstExecuted(false),
43  thisTimeInstExecuted(false), instrExecuted (false),
44  executionResourcesUsed(0)
45 {
47  idle_dur = 0;
48 }
49 
50 void
52 {
53  computeUnit = cu;
54  _name = computeUnit->name() + ".ExecStage";
59  idle_dur = 0;
60 }
61 
62 void
63 ExecStage::collectStatistics(enum STAT_STATUS stage, int unitId) {
64  if (stage == IdleExec) {
65  // count cycles of no vector ALU instruction executed
66  // even if one was the oldest in a WV of that vector SIMD unit
67  if (computeUnit->isVecAlu(unitId) && vectorAluInstAvail->at(unitId)) {
69  }
70 
71  // count cycles of no global memory (vector) instruction executed
72  // even if one was the oldest in a WV of that vector SIMD unit
73  if (computeUnit->isGlbMem(unitId) && *glbMemInstAvail > 0) {
75  (*glbMemInstAvail)--;
76  }
77 
78  // count cycles of no shared memory (vector) instruction executed
79  // even if one was the oldest in a WV of that vector SIMD unit
80  if (computeUnit->isShrMem(unitId) && *shrMemInstAvail > 0) {
82  (*shrMemInstAvail)--;
83  }
84  } else if (stage == BusyExec) {
85  // count the number of cycles an instruction to a specific unit
86  // was issued
88  thisTimeInstExecuted = true;
89  instrExecuted = true;
91  } else if (stage == PostExec) {
92  // count the number of transitions from active to idle
95  }
96 
99  idle_dur = 0;
100  } else if (!thisTimeInstExecuted) {
101  idle_dur++;
102  }
103 
105  // track the number of cycles we either issued one vector instruction
106  // or issued no instructions at all
107  if (instrExecuted) {
109  } else {
111  }
112 
114  }
115 }
116 
117 void
119 {
120  instrExecuted = false;
122  thisTimeInstExecuted = false;
123 }
124 
125 void
127 {
128  initStatistics();
129 
130  for (int unitId = 0; unitId < (numSIMDs + numMemUnits); ++unitId) {
131  // if dispatch list for this execution resource is empty,
132  // skip this execution resource this cycle
133  if (dispatchList->at(unitId).second == EMPTY) {
134  collectStatistics(IdleExec, unitId);
135  continue;
136  }
137 
138  collectStatistics(BusyExec, unitId);
139  // execute an instruction for the WF
140  dispatchList->at(unitId).first->exec();
141  // clear the dispatch list entry
142  dispatchList->at(unitId).second = EMPTY;
143  dispatchList->at(unitId).first = (Wavefront*)nullptr;
144  }
145 
147 }
148 
149 void
151 {
153  .name(name() + ".num_transitions_active_to_idle")
154  .desc("number of CU transitions from active to idle")
155  ;
156 
158  .name(name() + ".num_cycles_with_no_issue")
159  .desc("number of cycles the CU issues nothing")
160  ;
161 
163  .name(name() + ".num_cycles_with_instr_issued")
164  .desc("number of cycles the CU issued at least one instruction")
165  ;
166 
167  spc
168  .init(0, numSIMDs + numMemUnits, 1)
169  .name(name() + ".spc")
170  .desc("Execution units active per cycle (Exec unit=SIMD,MemPipe)")
171  ;
172 
173  idleDur
174  .init(0,75,5)
175  .name(name() + ".idle_duration_in_cycles")
176  .desc("duration of idle periods in cycles")
177  ;
178 
181  .name(name() + ".num_cycles_with_instrtype_issue")
182  .desc("Number of cycles at least one instruction of specific type "
183  "issued")
184  ;
185 
188  .name(name() + ".num_cycles_with_instr_type_no_issue")
189  .desc("Number of cycles no instruction of specific type issued")
190  ;
191 
192  for (int i = 0; i < numSIMDs; ++i) {
195  }
196 
199  numCyclesWithInstrTypeIssued.subname(numSIMDs + 1, csprintf("LM"));
200  numCyclesWithNoInstrTypeIssued.subname(numSIMDs + 1, csprintf("LM"));
201 }
std::vector< bool > vectorAluInstAvail
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:376
Bitfield< 7 > i
uint32_t executionResourcesUsed
Definition: exec_stage.hh:122
uint32_t numSIMDs
Definition: exec_stage.hh:95
std::string _name
Definition: exec_stage.hh:124
Stats::Distribution idleDur
Definition: exec_stage.hh:121
Stats::Vector numCyclesWithInstrTypeIssued
Definition: exec_stage.hh:83
Stats::Scalar numCyclesWithInstrIssued
Definition: exec_stage.hh:80
std::string name()
Definition: exec_stage.hh:75
Stats::Distribution spc
Definition: exec_stage.hh:89
ExecStage(const ComputeUnitParams *params)
Definition: exec_stage.cc:39
void collectStatistics(enum STAT_STATUS stage, int unitId)
Definition: exec_stage.cc:63
Derived & init(size_type size)
Set this vector to have the given size.
Definition: statistics.hh:1149
ComputeUnit * computeUnit
Definition: exec_stage.hh:94
bool isShrMem(int unitId)
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158
uint64_t idle_dur
Definition: exec_stage.hh:123
bool lastTimeInstExecuted
Definition: exec_stage.hh:117
Stats::Scalar numCyclesWithNoIssue
Definition: exec_stage.hh:78
void exec()
Definition: exec_stage.cc:126
bool instrExecuted
Definition: exec_stage.hh:119
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
Definition: statistics.hh:2606
void init(ComputeUnit *cu)
Definition: exec_stage.cc:51
Stats::Vector numCyclesWithNoInstrTypeIssued
Definition: exec_stage.hh:87
bool isGlbMem(int unitId)
int * glbMemInstAvail
Definition: exec_stage.hh:115
std::vector< std::pair< Wavefront *, DISPATCH_STATUS > > dispatchList
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Definition: statistics.hh:276
virtual const std::string name() const
Definition: sim_object.hh:129
STAT_STATUS
Definition: exec_stage.hh:47
std::vector< std::pair< Wavefront *, DISPATCH_STATUS > > * dispatchList
Definition: exec_stage.hh:110
void initStatistics()
Definition: exec_stage.cc:118
Stats::Scalar numTransActiveIdle
Definition: exec_stage.hh:120
std::vector< bool > * vectorAluInstAvail
Definition: exec_stage.hh:114
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
Definition: statistics.hh:309
int * shrMemInstAvail
Definition: exec_stage.hh:116
uint32_t numMemUnits
Definition: exec_stage.hh:99
void regStats()
Definition: exec_stage.cc:150
Bitfield< 0 > p
bool thisTimeInstExecuted
Definition: exec_stage.hh:118
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Definition: statistics.hh:1896
bool isVecAlu(int unitId)

Generated on Fri Jul 3 2020 15:53:02 for gem5 by doxygen 1.8.13