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

Generated on Fri Jun 9 2017 13:03:47 for gem5 by doxygen 1.8.6