gem5  v21.0.1.0
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 LocalMemPipeline::LocalMemPipeline(const ComputeUnitParams &p, ComputeUnit &cu)
45  : computeUnit(cu), _name(cu.name() + ".LocalMemPipeline"),
46  lmQueueSize(p.local_mem_queue_size), stats(&cu)
47 {
48 }
49 
50 void
52 {
53  // apply any returned shared (LDS) memory operations
55  lmReturnedRequests.front() : nullptr;
56 
57  bool accessVrf = true;
58  Wavefront *w = nullptr;
59 
60  if ((m) && m->latency.rdy() && (m->isLoad() || m->isAtomicRet())) {
61  w = m->wavefront();
62 
63  accessVrf = w->computeUnit->vrf[w->simdId]->
64  canScheduleWriteOperandsFromLoad(w, m);
65 
66  }
67 
68  if (!lmReturnedRequests.empty() && m->latency.rdy() && accessVrf &&
72 
73  lmReturnedRequests.pop();
74  w = m->wavefront();
75 
76  DPRINTF(GPUMem, "CU%d: WF[%d][%d]: Completing local mem instr %s\n",
77  m->cu_id, m->simdId, m->wfSlotId, m->disassemble());
78  m->completeAcc(m);
79  w->decLGKMInstsIssued();
80 
81  if (m->isLoad() || m->isAtomicRet()) {
82  w->computeUnit->vrf[w->simdId]->
83  scheduleWriteOperandsFromLoad(w, m);
84  }
85 
86  // Decrement outstanding request count
87  computeUnit.shader->ScheduleAdd(&w->outstandingReqs, m->time, -1);
88 
89  if (m->isStore() || m->isAtomic()) {
90  computeUnit.shader->ScheduleAdd(&w->outstandingReqsWrLm,
91  m->time, -1);
92  }
93 
94  if (m->isLoad() || m->isAtomic()) {
95  computeUnit.shader->ScheduleAdd(&w->outstandingReqsRdLm,
96  m->time, -1);
97  }
98 
99  // Mark write bus busy for appropriate amount of time
102  w->computeUnit->vectorSharedMemUnit.set(m->time);
103  }
104 
105  // If pipeline has executed a local memory instruction
106  // execute local memory packet and issue the packets
107  // to LDS
108  if (!lmIssuedRequests.empty() && lmReturnedRequests.size() < lmQueueSize) {
109 
110  GPUDynInstPtr m = lmIssuedRequests.front();
111 
112  bool returnVal = computeUnit.sendToLds(m);
113  if (!returnVal) {
114  DPRINTF(GPUPort, "packet was nack'd and put in retry queue");
115  }
116  lmIssuedRequests.pop();
117  }
118 }
119 
120 void
122 {
123  gpuDynInst->setAccessTime(curTick());
124  lmIssuedRequests.push(gpuDynInst);
125 }
126 
127 
130  : Stats::Group(parent, "LocalMemPipeline"),
131  ADD_STAT(loadVrfBankConflictCycles, "total number of cycles LDS data "
132  "are delayed before updating the VRF")
133 {
134 }
ComputeUnit::vectorSharedMemUnit
WaitClass vectorSharedMemUnit
Definition: compute_unit.hh:232
LocalMemPipeline::lmQueueSize
int lmQueueSize
Definition: local_memory_pipeline.hh:89
ComputeUnit::locMemToVrfBus
WaitClass locMemToVrfBus
Definition: compute_unit.hh:228
shader.hh
compute_unit.hh
Shader::coissue_return
int coissue_return
Definition: shader.hh:202
wavefront.hh
WaitClass::rdy
bool rdy(Cycles cycles=Cycles(0)) const
Definition: misc.hh:90
ComputeUnit
Definition: compute_unit.hh:200
vector_register_file.hh
LocalMemPipeline::exec
void exec()
Definition: local_memory_pipeline.cc:51
MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:278
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:237
ADD_STAT
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition: group.hh:71
LocalMemPipeline::lmIssuedRequests
std::queue< GPUDynInstPtr > lmIssuedRequests
Definition: local_memory_pipeline.hh:93
WaitClass::set
void set(uint64_t i)
Definition: misc.hh:79
LocalMemPipeline::LocalMemPipeline
LocalMemPipeline(const ComputeUnitParams &p, ComputeUnit &cu)
Definition: local_memory_pipeline.cc:44
gpu_dyn_inst.hh
local_memory_pipeline.hh
ComputeUnit::sendToLds
M5_NODISCARD 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:1983
LocalMemPipeline::lmReturnedRequests
std::queue< GPUDynInstPtr > lmReturnedRequests
Definition: local_memory_pipeline.hh:97
name
const std::string & name()
Definition: trace.cc:48
LocalMemPipeline::computeUnit
ComputeUnit & computeUnit
Definition: local_memory_pipeline.hh:87
LocalMemPipeline::issueRequest
void issueRequest(GPUDynInstPtr gpuDynInst)
Definition: local_memory_pipeline.cc:121
Shader::ScheduleAdd
void ScheduleAdd(int *val, Tick when, int x)
Definition: shader.cc:356
Wavefront
Definition: wavefront.hh:59
Stats::Group
Statistics container.
Definition: group.hh:87
GPUDynInstPtr
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:48
LocalMemPipeline::LocalMemPipelineStats::LocalMemPipelineStats
LocalMemPipelineStats(Stats::Group *parent)
Definition: local_memory_pipeline.cc:129
Stats
Definition: statistics.cc:53
curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:43
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
ComputeUnit::shader
Shader * shader
Definition: compute_unit.hh:352
ArmISA::m
Bitfield< 0 > m
Definition: miscregs_types.hh:389

Generated on Tue Jun 22 2021 15:28:28 for gem5 by doxygen 1.8.17