gem5  v21.1.0.2
comm.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 
34 #include "gpu-compute/comm.hh"
35 
36 #include <cassert>
37 
38 #include "gpu-compute/wavefront.hh"
39 #include "params/ComputeUnit.hh"
40 
41 namespace gem5
42 {
43 
48  &p)
49 {
50  int num_func_units = p.num_SIMDs + p.num_scalar_cores
51  + p.num_global_mem_pipes + p.num_shared_mem_pipes
52  + p.num_scalar_mem_pipes;
53  _readyWFs.resize(num_func_units);
54 
55  for (auto &func_unit_wf_list : _readyWFs) {
56  func_unit_wf_list.reserve(p.n_wf);
57  }
58 }
59 
60 void
62 {
63  for (auto &func_unit_wf_list : _readyWFs) {
64  func_unit_wf_list.resize(0);
65  }
66 }
67 
68 void
70 {
71  _readyWFs[func_unit_id].push_back(wf);
72 }
73 
74 int
76 {
77  return _readyWFs.size();
78 }
79 
82 {
83  return _readyWFs[func_unit_id];
84 }
85 
90 void
92 {
93  std::vector<Wavefront*> &func_unit_wf_list = _readyWFs[func_unit_id];
94 
95  for (auto it = func_unit_wf_list.begin(); it != func_unit_wf_list.end();) {
96  if ((*it)->instructionBuffer.empty()) {
97  it = func_unit_wf_list.erase(it);
98  } else {
99  ++it;
100  }
101  }
102 }
103 
107 ScheduleToExecute::ScheduleToExecute(const ComputeUnitParams &p)
108 {
109  int num_func_units = p.num_SIMDs + p.num_scalar_cores
110  + p.num_global_mem_pipes + p.num_shared_mem_pipes
111  + p.num_scalar_mem_pipes;
112  _readyInsts.resize(num_func_units, nullptr);
113  _dispatchStatus.resize(num_func_units, EMPTY);
114 }
115 
116 void
118 {
119  for (auto &func_unit_ready_inst : _readyInsts) {
120  func_unit_ready_inst = nullptr;
121  }
122 
123  for (auto &func_unit_status : _dispatchStatus) {
124  func_unit_status = EMPTY;
125  }
126 }
127 
130 {
131  return _readyInsts[func_unit_id];
132 }
133 
134 void
136  int func_unit_id,
137  DISPATCH_STATUS disp_status)
138 {
139  _readyInsts[func_unit_id] = gpu_dyn_inst;
140  _dispatchStatus[func_unit_id] = disp_status;
141 }
142 
143 void
145  DISPATCH_STATUS disp_status)
146 {
147  _readyInsts[func_unit_id] = nullptr;
148  _dispatchStatus[func_unit_id] = disp_status;
149 }
150 
152 ScheduleToExecute::dispatchStatus(int func_unit_id) const
153 {
154  return _dispatchStatus[func_unit_id];
155 }
156 
157 } // namespace gem5
gem5::ScoreboardCheckToSchedule::markWFReady
void markWFReady(Wavefront *wf, int func_unit_id)
Mark the WF as ready for execution on a particular functional unit.
Definition: comm.cc:69
gem5::ScheduleToExecute::_readyInsts
std::vector< GPUDynInstPtr > _readyInsts
Definition: comm.hh:120
gem5::ScoreboardCheckToSchedule::updateReadyList
void updateReadyList(int func_unit_id)
Delete all wavefronts that have been marked as ready at scoreboard stage but are found to have empty ...
Definition: comm.cc:91
gem5::ScoreboardCheckToSchedule::ScoreboardCheckToSchedule
ScoreboardCheckToSchedule()=delete
comm.hh
gem5::Wavefront
Definition: wavefront.hh:62
gem5::ScheduleToExecute::dispatchStatus
DISPATCH_STATUS dispatchStatus(int func_unit_id) const
Definition: comm.cc:152
std::vector
STL vector class.
Definition: stl.hh:37
gem5::ScheduleToExecute::ScheduleToExecute
ScheduleToExecute()=delete
wavefront.hh
gem5::ScoreboardCheckToSchedule::reset
void reset() override
Reset the pipe stage interface.
Definition: comm.cc:61
gem5::ScheduleToExecute::readyInst
GPUDynInstPtr & readyInst(int func_unit_id)
Definition: comm.cc:129
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::EMPTY
@ EMPTY
Definition: exec_stage.hh:63
gem5::ScheduleToExecute::reset
void reset() override
Reset the pipe stage interface.
Definition: comm.cc:117
gem5::DISPATCH_STATUS
DISPATCH_STATUS
Definition: exec_stage.hh:61
gem5::ScheduleToExecute::_dispatchStatus
std::vector< DISPATCH_STATUS > _dispatchStatus
Definition: comm.hh:121
gem5::GPUDynInstPtr
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:51
gem5::ScoreboardCheckToSchedule::readyWFs
std::vector< Wavefront * > & readyWFs(int func_unit_id)
TODO: These methods expose this class' implementation too much by returning references to its interna...
Definition: comm.cc:81
gem5::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:135
gem5::ScoreboardCheckToSchedule::_readyWFs
std::vector< std::vector< Wavefront * > > _readyWFs
Definition: comm.hh:94
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ScoreboardCheckToSchedule::numReadyLists
int numReadyLists() const
Returns the number of ready lists (i.e., the number of functional units).
Definition: comm.cc:75

Generated on Tue Sep 21 2021 12:25:23 for gem5 by doxygen 1.8.17