gem5  v20.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  * 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: Anthony Gutierrez
34  */
35 
36 #include "gpu-compute/comm.hh"
37 
38 #include <cassert>
39 
40 #include "gpu-compute/wavefront.hh"
41 #include "params/ComputeUnit.hh"
42 
47  *p)
48 {
49  int num_func_units = p->num_SIMDs + p->num_scalar_cores
50  + p->num_global_mem_pipes + p->num_shared_mem_pipes
51  + p->num_scalar_mem_pipes;
52  _readyWFs.resize(num_func_units);
53 
54  for (auto &func_unit_wf_list : _readyWFs) {
55  func_unit_wf_list.reserve(p->n_wf);
56  }
57 }
58 
59 void
61 {
62  for (auto &func_unit_wf_list : _readyWFs) {
63  func_unit_wf_list.resize(0);
64  }
65 }
66 
67 void
69 {
70  _readyWFs[func_unit_id].push_back(wf);
71 }
72 
73 int
75 {
76  return _readyWFs.size();
77 }
78 
81 {
82  return _readyWFs[func_unit_id];
83 }
84 
89 void
91 {
92  std::vector<Wavefront*> &func_unit_wf_list = _readyWFs[func_unit_id];
93 
94  for (auto it = func_unit_wf_list.begin(); it != func_unit_wf_list.end();) {
95  if ((*it)->instructionBuffer.empty()) {
96  it = func_unit_wf_list.erase(it);
97  } else {
98  ++it;
99  }
100  }
101 }
102 
106 ScheduleToExecute::ScheduleToExecute(const ComputeUnitParams *p)
107 {
108  int num_func_units = p->num_SIMDs + p->num_scalar_cores
109  + p->num_global_mem_pipes + p->num_shared_mem_pipes
110  + p->num_scalar_mem_pipes;
111  _readyInsts.resize(num_func_units, nullptr);
112  _dispatchStatus.resize(num_func_units, EMPTY);
113 }
114 
115 void
117 {
118  for (auto &func_unit_ready_inst : _readyInsts) {
119  func_unit_ready_inst = nullptr;
120  }
121 
122  for (auto &func_unit_status : _dispatchStatus) {
123  func_unit_status = EMPTY;
124  }
125 }
126 
129 {
130  return _readyInsts[func_unit_id];
131 }
132 
133 void
135  int func_unit_id,
136  DISPATCH_STATUS disp_status)
137 {
138  _readyInsts[func_unit_id] = gpu_dyn_inst;
139  _dispatchStatus[func_unit_id] = disp_status;
140 }
141 
142 void
144  DISPATCH_STATUS disp_status)
145 {
146  _readyInsts[func_unit_id] = nullptr;
147  _dispatchStatus[func_unit_id] = disp_status;
148 }
149 
151 ScheduleToExecute::dispatchStatus(int func_unit_id) const
152 {
153  return _dispatchStatus[func_unit_id];
154 }
ScoreboardCheckToSchedule::ScoreboardCheckToSchedule
ScoreboardCheckToSchedule()=delete
EMPTY
@ EMPTY
Definition: exec_stage.hh:59
comm.hh
ScheduleToExecute::reset
void reset() override
Reset the pipe stage interface.
Definition: comm.cc:116
ScheduleToExecute::readyInst
GPUDynInstPtr & readyInst(int func_unit_id)
Definition: comm.cc:128
ScoreboardCheckToSchedule::reset
void reset() override
Reset the pipe stage interface.
Definition: comm.cc:60
ScheduleToExecute::_readyInsts
std::vector< GPUDynInstPtr > _readyInsts
Definition: comm.hh:119
ScheduleToExecute::dispatchStatus
DISPATCH_STATUS dispatchStatus(int func_unit_id) const
Definition: comm.cc:151
std::vector< Wavefront * >
ScoreboardCheckToSchedule::_readyWFs
std::vector< std::vector< Wavefront * > > _readyWFs
Definition: comm.hh:93
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:68
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:90
wavefront.hh
ScheduleToExecute::_dispatchStatus
std::vector< DISPATCH_STATUS > _dispatchStatus
Definition: comm.hh:120
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:134
Wavefront
Definition: wavefront.hh:57
GPUDynInstPtr
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:48
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:80
ScheduleToExecute::ScheduleToExecute
ScheduleToExecute()=delete
ScoreboardCheckToSchedule::numReadyLists
int numReadyLists() const
Returns the number of ready lists (i.e., the number of functional units).
Definition: comm.cc:74
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
DISPATCH_STATUS
DISPATCH_STATUS
Definition: exec_stage.hh:57

Generated on Wed Sep 30 2020 14:02:12 for gem5 by doxygen 1.8.17