gem5  v22.1.0.0
comm.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include "gpu-compute/comm.hh"
33 
34 #include <cassert>
35 
36 #include "gpu-compute/wavefront.hh"
37 #include "params/ComputeUnit.hh"
38 
39 namespace gem5
40 {
41 
46  &p)
47 {
48  int num_func_units = p.num_SIMDs + p.num_scalar_cores
49  + p.num_global_mem_pipes + p.num_shared_mem_pipes
50  + p.num_scalar_mem_pipes;
51  _readyWFs.resize(num_func_units);
52 
53  for (auto &func_unit_wf_list : _readyWFs) {
54  func_unit_wf_list.reserve(p.n_wf);
55  }
56 }
57 
58 void
60 {
61  for (auto &func_unit_wf_list : _readyWFs) {
62  func_unit_wf_list.resize(0);
63  }
64 }
65 
66 void
68 {
69  _readyWFs[func_unit_id].push_back(wf);
70 }
71 
72 int
74 {
75  return _readyWFs.size();
76 }
77 
80 {
81  return _readyWFs[func_unit_id];
82 }
83 
88 void
90 {
91  std::vector<Wavefront*> &func_unit_wf_list = _readyWFs[func_unit_id];
92 
93  for (auto it = func_unit_wf_list.begin(); it != func_unit_wf_list.end();) {
94  if ((*it)->instructionBuffer.empty()) {
95  it = func_unit_wf_list.erase(it);
96  } else {
97  ++it;
98  }
99  }
100 }
101 
105 ScheduleToExecute::ScheduleToExecute(const ComputeUnitParams &p)
106 {
107  int num_func_units = p.num_SIMDs + p.num_scalar_cores
108  + p.num_global_mem_pipes + p.num_shared_mem_pipes
109  + p.num_scalar_mem_pipes;
110  _readyInsts.resize(num_func_units, nullptr);
111  _dispatchStatus.resize(num_func_units, EMPTY);
112 }
113 
114 void
116 {
117  for (auto &func_unit_ready_inst : _readyInsts) {
118  func_unit_ready_inst = nullptr;
119  }
120 
121  for (auto &func_unit_status : _dispatchStatus) {
122  func_unit_status = EMPTY;
123  }
124 }
125 
128 {
129  return _readyInsts[func_unit_id];
130 }
131 
132 void
134  int func_unit_id,
135  DISPATCH_STATUS disp_status)
136 {
137  _readyInsts[func_unit_id] = gpu_dyn_inst;
138  _dispatchStatus[func_unit_id] = disp_status;
139 }
140 
141 void
143  DISPATCH_STATUS disp_status)
144 {
145  _readyInsts[func_unit_id] = nullptr;
146  _dispatchStatus[func_unit_id] = disp_status;
147 }
148 
150 ScheduleToExecute::dispatchStatus(int func_unit_id) const
151 {
152  return _dispatchStatus[func_unit_id];
153 }
154 
155 } // namespace gem5
DISPATCH_STATUS dispatchStatus(int func_unit_id) const
Definition: comm.cc:150
std::vector< GPUDynInstPtr > _readyInsts
Definition: comm.hh:118
void reset() override
Reset the pipe stage interface.
Definition: comm.cc:115
GPUDynInstPtr & readyInst(int func_unit_id)
Definition: comm.cc:127
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:133
std::vector< DISPATCH_STATUS > _dispatchStatus
Definition: comm.hh:119
int numReadyLists() const
Returns the number of ready lists (i.e., the number of functional units).
Definition: comm.cc:73
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:79
void reset() override
Reset the pipe stage interface.
Definition: comm.cc:59
void markWFReady(Wavefront *wf, int func_unit_id)
Mark the WF as ready for execution on a particular functional unit.
Definition: comm.cc:67
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:89
std::vector< std::vector< Wavefront * > > _readyWFs
Definition: comm.hh:92
STL vector class.
Definition: stl.hh:37
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:49
DISPATCH_STATUS
Definition: exec_stage.hh:60
@ EMPTY
Definition: exec_stage.hh:61

Generated on Wed Dec 21 2022 10:22:35 for gem5 by doxygen 1.9.1