gem5  v21.1.0.2
local_memory_pipeline.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 
35 
36 #include "debug/GPUMem.hh"
37 #include "debug/GPUPort.hh"
40 #include "gpu-compute/shader.hh"
42 #include "gpu-compute/wavefront.hh"
43 
44 namespace gem5
45 {
46 
47 LocalMemPipeline::LocalMemPipeline(const ComputeUnitParams &p, ComputeUnit &cu)
48  : computeUnit(cu), _name(cu.name() + ".LocalMemPipeline"),
49  lmQueueSize(p.local_mem_queue_size), stats(&cu)
50 {
51 }
52 
53 void
55 {
56  // apply any returned shared (LDS) memory operations
58  lmReturnedRequests.front() : nullptr;
59 
60  bool accessVrf = true;
61  Wavefront *w = nullptr;
62 
63  if ((m) && m->latency.rdy() && (m->isLoad() || m->isAtomicRet())) {
64  w = m->wavefront();
65 
66  accessVrf = w->computeUnit->vrf[w->simdId]->
67  canScheduleWriteOperandsFromLoad(w, m);
68 
69  }
70 
71  if (!lmReturnedRequests.empty() && m->latency.rdy() && accessVrf &&
75 
76  lmReturnedRequests.pop();
77  w = m->wavefront();
78 
79  if (m->isFlat() && !m->isMemSync() && !m->isEndOfKernel()
80  && m->allLanesZero()) {
82  }
83 
84  DPRINTF(GPUMem, "CU%d: WF[%d][%d]: Completing local mem instr %s\n",
85  m->cu_id, m->simdId, m->wfSlotId, m->disassemble());
86  m->completeAcc(m);
87  w->decLGKMInstsIssued();
88 
89  if (m->isLoad() || m->isAtomicRet()) {
90  w->computeUnit->vrf[w->simdId]->
91  scheduleWriteOperandsFromLoad(w, m);
92  }
93 
94  // Decrement outstanding request count
95  computeUnit.shader->ScheduleAdd(&w->outstandingReqs, m->time, -1);
96 
97  if (m->isStore() || m->isAtomic()) {
98  computeUnit.shader->ScheduleAdd(&w->outstandingReqsWrLm,
99  m->time, -1);
100  }
101 
102  if (m->isLoad() || m->isAtomic()) {
103  computeUnit.shader->ScheduleAdd(&w->outstandingReqsRdLm,
104  m->time, -1);
105  }
106 
107  // Mark write bus busy for appropriate amount of time
110  w->computeUnit->vectorSharedMemUnit.set(m->time);
111  }
112 
113  // If pipeline has executed a local memory instruction
114  // execute local memory packet and issue the packets
115  // to LDS
116  if (!lmIssuedRequests.empty() && lmReturnedRequests.size() < lmQueueSize) {
117 
118  GPUDynInstPtr m = lmIssuedRequests.front();
119 
120  bool returnVal = computeUnit.sendToLds(m);
121  if (!returnVal) {
122  DPRINTF(GPUPort, "packet was nack'd and put in retry queue");
123  }
124  lmIssuedRequests.pop();
125  }
126 }
127 
128 void
130 {
131  Wavefront *wf = gpuDynInst->wavefront();
132  if (gpuDynInst->isLoad()) {
133  wf->rdLmReqsInPipe--;
134  wf->outstandingReqsRdLm++;
135  } else if (gpuDynInst->isStore()) {
136  wf->wrLmReqsInPipe--;
137  wf->outstandingReqsWrLm++;
138  } else {
139  // Atomic, both read and write
140  wf->rdLmReqsInPipe--;
141  wf->outstandingReqsRdLm++;
142  wf->wrLmReqsInPipe--;
143  wf->outstandingReqsWrLm++;
144  }
145 
146  wf->outstandingReqs++;
148 
149  gpuDynInst->setAccessTime(curTick());
150  lmIssuedRequests.push(gpuDynInst);
151 }
152 
153 
156  : statistics::Group(parent, "LocalMemPipeline"),
157  ADD_STAT(loadVrfBankConflictCycles, "total number of cycles LDS data "
158  "are delayed before updating the VRF")
159 {
160 }
161 
162 } // namespace gem5
gem5::curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
gem5::MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:281
shader.hh
gem5::Wavefront
Definition: wavefront.hh:62
compute_unit.hh
gem5::LocalMemPipeline::lmQueueSize
int lmQueueSize
Definition: local_memory_pipeline.hh:92
gem5::LocalMemPipeline::issueRequest
void issueRequest(GPUDynInstPtr gpuDynInst)
Definition: local_memory_pipeline.cc:129
gem5::ComputeUnit::shader
Shader * shader
Definition: compute_unit.hh:355
wavefront.hh
gem5::ComputeUnit::locMemToVrfBus
WaitClass locMemToVrfBus
Definition: compute_unit.hh:231
gem5::Wavefront::wrLmReqsInPipe
int wrLmReqsInPipe
Definition: wavefront.hh:188
gem5::LocalMemPipeline::LocalMemPipelineStats::LocalMemPipelineStats
LocalMemPipelineStats(statistics::Group *parent)
Definition: local_memory_pipeline.cc:155
gem5::ComputeUnit
Definition: compute_unit.hh:203
gem5::Wavefront::validateRequestCounters
void validateRequestCounters()
Definition: wavefront.cc:748
vector_register_file.hh
gem5::LocalMemPipeline::exec
void exec()
Definition: local_memory_pipeline.cc:54
gem5::LocalMemPipeline::LocalMemPipeline
LocalMemPipeline(const ComputeUnitParams &p, ComputeUnit &cu)
Definition: local_memory_pipeline.cc:47
gem5::Wavefront::outstandingReqs
int outstandingReqs
Definition: wavefront.hh:173
gem5::ComputeUnit::vectorSharedMemUnit
WaitClass vectorSharedMemUnit
Definition: compute_unit.hh:235
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
ADD_STAT
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition: group.hh:75
gem5::Wavefront::rdLmReqsInPipe
int rdLmReqsInPipe
Definition: wavefront.hh:186
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gpu_dyn_inst.hh
gem5::LocalMemPipeline::lmReturnedRequests
std::queue< GPUDynInstPtr > lmReturnedRequests
Definition: local_memory_pipeline.hh:100
local_memory_pipeline.hh
gem5::ComputeUnit::getTokenManager
TokenManager * getTokenManager()
Definition: compute_unit.hh:839
name
const std::string & name()
Definition: trace.cc:49
gem5::GPUDynInstPtr
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:51
gem5::Wavefront::outstandingReqsWrLm
int outstandingReqsWrLm
Definition: wavefront.hh:177
gem5::Shader::coissue_return
int coissue_return
Definition: shader.hh:199
gem5::WaitClass::set
void set(uint64_t i)
Definition: misc.hh:84
gem5::ArmISA::m
Bitfield< 0 > m
Definition: misc_types.hh:394
gem5::Shader::ScheduleAdd
void ScheduleAdd(int *val, Tick when, int x)
Definition: shader.cc:359
gem5::Wavefront::outstandingReqsRdLm
int outstandingReqsRdLm
Definition: wavefront.hh:181
gem5::LocalMemPipeline::lmIssuedRequests
std::queue< GPUDynInstPtr > lmIssuedRequests
Definition: local_memory_pipeline.hh:96
gem5::TokenManager::recvTokens
void recvTokens(int num_tokens)
Increment the number of available tokens by num_tokens.
Definition: token_port.cc:157
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::LocalMemPipeline::computeUnit
ComputeUnit & computeUnit
Definition: local_memory_pipeline.hh:90
gem5::ComputeUnit::sendToLds
GEM5_NO_DISCARD bool sendToLds(GPUDynInstPtr gpuDynInst)
send a general request to the LDS make sure to look at the return value here as your request might be...
Definition: compute_unit.cc:1995
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::WaitClass::rdy
bool rdy(Cycles cycles=Cycles(0)) const
Definition: misc.hh:95

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