gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: John Kalamatianos,
34  * Sooraj Puthoor
35  */
36 
38 
40 #include "gpu-compute/wavefront.hh"
41 
42 ExecStage::ExecStage(const ComputeUnitParams *p) : numSIMDs(p->num_SIMDs),
43  numMemUnits(p->num_global_mem_pipes + p->num_shared_mem_pipes),
44  vectorAluInstAvail(nullptr), glbMemInstAvail(nullptr),
45  shrMemInstAvail(nullptr), lastTimeInstExecuted(false),
46  thisTimeInstExecuted(false), instrExecuted (false),
47  executionResourcesUsed(0)
48 {
50  idle_dur = 0;
51 }
52 
53 void
55 {
56  computeUnit = cu;
57  _name = computeUnit->name() + ".ExecStage";
62  idle_dur = 0;
63 }
64 
65 void
66 ExecStage::collectStatistics(enum STAT_STATUS stage, int unitId) {
67  if (stage == IdleExec) {
68  // count cycles of no vector ALU instruction executed
69  // even if one was the oldest in a WV of that vector SIMD unit
70  if (computeUnit->isVecAlu(unitId) && vectorAluInstAvail->at(unitId)) {
72  }
73 
74  // count cycles of no global memory (vector) instruction executed
75  // even if one was the oldest in a WV of that vector SIMD unit
76  if (computeUnit->isGlbMem(unitId) && *glbMemInstAvail > 0) {
78  (*glbMemInstAvail)--;
79  }
80 
81  // count cycles of no shared memory (vector) instruction executed
82  // even if one was the oldest in a WV of that vector SIMD unit
83  if (computeUnit->isShrMem(unitId) && *shrMemInstAvail > 0) {
85  (*shrMemInstAvail)--;
86  }
87  } else if (stage == BusyExec) {
88  // count the number of cycles an instruction to a specific unit
89  // was issued
91  thisTimeInstExecuted = true;
92  instrExecuted = true;
94  } else if (stage == PostExec) {
95  // count the number of transitions from active to idle
98  }
99 
102  idle_dur = 0;
103  } else if (!thisTimeInstExecuted) {
104  idle_dur++;
105  }
106 
108  // track the number of cycles we either issued one vector instruction
109  // or issued no instructions at all
110  if (instrExecuted) {
112  } else {
114  }
115 
117  }
118 }
119 
120 void
122 {
123  instrExecuted = false;
125  thisTimeInstExecuted = false;
126 }
127 
128 void
130 {
131  initStatistics();
132 
133  for (int unitId = 0; unitId < (numSIMDs + numMemUnits); ++unitId) {
134  // if dispatch list for this execution resource is empty,
135  // skip this execution resource this cycle
136  if (dispatchList->at(unitId).second == EMPTY) {
137  collectStatistics(IdleExec, unitId);
138  continue;
139  }
140 
141  collectStatistics(BusyExec, unitId);
142  // execute an instruction for the WF
143  dispatchList->at(unitId).first->exec();
144  // clear the dispatch list entry
145  dispatchList->at(unitId).second = EMPTY;
146  dispatchList->at(unitId).first = (Wavefront*)nullptr;
147  }
148 
150 }
151 
152 void
154 {
156  .name(name() + ".num_transitions_active_to_idle")
157  .desc("number of CU transitions from active to idle")
158  ;
159 
161  .name(name() + ".num_cycles_with_no_issue")
162  .desc("number of cycles the CU issues nothing")
163  ;
164 
166  .name(name() + ".num_cycles_with_instr_issued")
167  .desc("number of cycles the CU issued at least one instruction")
168  ;
169 
170  spc
171  .init(0, numSIMDs + numMemUnits, 1)
172  .name(name() + ".spc")
173  .desc("Execution units active per cycle (Exec unit=SIMD,MemPipe)")
174  ;
175 
176  idleDur
177  .init(0,75,5)
178  .name(name() + ".idle_duration_in_cycles")
179  .desc("duration of idle periods in cycles")
180  ;
181 
184  .name(name() + ".num_cycles_with_instrtype_issue")
185  .desc("Number of cycles at least one instruction of specific type "
186  "issued")
187  ;
188 
191  .name(name() + ".num_cycles_with_instr_type_no_issue")
192  .desc("Number of cycles no instruction of specific type issued")
193  ;
194 
195  for (int i = 0; i < numSIMDs; ++i) {
198  }
199 
202  numCyclesWithInstrTypeIssued.subname(numSIMDs + 1, csprintf("LM"));
203  numCyclesWithNoInstrTypeIssued.subname(numSIMDs + 1, csprintf("LM"));
204 }
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:379
Bitfield< 7 > i
uint32_t executionResourcesUsed
Definition: exec_stage.hh:125
uint32_t numSIMDs
Definition: exec_stage.hh:98
std::string _name
Definition: exec_stage.hh:127
Stats::Distribution idleDur
Definition: exec_stage.hh:124
Stats::Vector numCyclesWithInstrTypeIssued
Definition: exec_stage.hh:86
Stats::Scalar numCyclesWithInstrIssued
Definition: exec_stage.hh:83
std::string name()
Definition: exec_stage.hh:78
Stats::Distribution spc
Definition: exec_stage.hh:92
ExecStage(const ComputeUnitParams *params)
Definition: exec_stage.cc:42
void collectStatistics(enum STAT_STATUS stage, int unitId)
Definition: exec_stage.cc:66
Derived & init(size_type size)
Set this vector to have the given size.
Definition: statistics.hh:1152
ComputeUnit * computeUnit
Definition: exec_stage.hh:97
bool isShrMem(int unitId)
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:162
uint64_t idle_dur
Definition: exec_stage.hh:126
bool lastTimeInstExecuted
Definition: exec_stage.hh:120
Stats::Scalar numCyclesWithNoIssue
Definition: exec_stage.hh:81
void exec()
Definition: exec_stage.cc:129
bool instrExecuted
Definition: exec_stage.hh:122
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
Definition: statistics.hh:2609
void init(ComputeUnit *cu)
Definition: exec_stage.cc:54
Stats::Vector numCyclesWithNoInstrTypeIssued
Definition: exec_stage.hh:90
bool isGlbMem(int unitId)
virtual const std::string name() const
Definition: sim_object.hh:120
int * glbMemInstAvail
Definition: exec_stage.hh:118
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:279
STAT_STATUS
Definition: exec_stage.hh:50
std::vector< std::pair< Wavefront *, DISPATCH_STATUS > > * dispatchList
Definition: exec_stage.hh:113
void initStatistics()
Definition: exec_stage.cc:121
Stats::Scalar numTransActiveIdle
Definition: exec_stage.hh:123
std::vector< bool > * vectorAluInstAvail
Definition: exec_stage.hh:117
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
Definition: statistics.hh:312
int * shrMemInstAvail
Definition: exec_stage.hh:119
uint32_t numMemUnits
Definition: exec_stage.hh:102
void regStats()
Definition: exec_stage.cc:153
Bitfield< 0 > p
bool thisTimeInstExecuted
Definition: exec_stage.hh:121
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
Definition: statistics.hh:1899
bool isVecAlu(int unitId)

Generated on Fri Feb 28 2020 16:27:01 for gem5 by doxygen 1.8.13