gem5  v20.1.0.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)
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 void
129 {
131  .name(name() + ".load_vrf_bank_conflict_cycles")
132  .desc("total number of cycles LDS data are delayed before updating "
133  "the VRF")
134  ;
135 }
LocalMemPipeline::name
const std::string & name() const
Definition: local_memory_pipeline.hh:77
ComputeUnit::vectorSharedMemUnit
WaitClass vectorSharedMemUnit
Definition: compute_unit.hh:230
LocalMemPipeline::lmQueueSize
int lmQueueSize
Definition: local_memory_pipeline.hh:89
ComputeUnit::locMemToVrfBus
WaitClass locMemToVrfBus
Definition: compute_unit.hh:226
shader.hh
LocalMemPipeline::loadVrfBankConflictCycles
Stats::Scalar loadVrfBankConflictCycles
Definition: local_memory_pipeline.hh:90
compute_unit.hh
Shader::coissue_return
int coissue_return
Definition: shader.hh:222
wavefront.hh
WaitClass::rdy
bool rdy(Cycles cycles=Cycles(0)) const
Definition: misc.hh:90
ComputeUnit::sendToLds
bool sendToLds(GPUDynInstPtr gpuDynInst) __attribute__((warn_unused_result))
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:2539
ComputeUnit
Definition: compute_unit.hh:198
vector_register_file.hh
LocalMemPipeline::exec
void exec()
Definition: local_memory_pipeline.cc:51
MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:278
LocalMemPipeline::regStats
void regStats()
Definition: local_memory_pipeline.cc:128
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
LocalMemPipeline::lmIssuedRequests
std::queue< GPUDynInstPtr > lmIssuedRequests
Definition: local_memory_pipeline.hh:93
WaitClass::set
void set(uint64_t i)
Definition: misc.hh:79
gpu_dyn_inst.hh
LocalMemPipeline::LocalMemPipeline
LocalMemPipeline(const ComputeUnitParams *p, ComputeUnit &cu)
Definition: local_memory_pipeline.cc:44
local_memory_pipeline.hh
Stats::DataWrap::name
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Definition: statistics.hh:274
LocalMemPipeline::lmReturnedRequests
std::queue< GPUDynInstPtr > lmReturnedRequests
Definition: local_memory_pipeline.hh:97
name
const std::string & name()
Definition: trace.cc:50
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:431
Wavefront
Definition: wavefront.hh:57
GPUDynInstPtr
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:48
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Stats::DataWrap::desc
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
Definition: statistics.hh:307
ComputeUnit::shader
Shader * shader
Definition: compute_unit.hh:356
ArmISA::m
Bitfield< 0 > m
Definition: miscregs_types.hh:389
curTick
Tick curTick()
The current simulated tick.
Definition: core.hh:45

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