gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
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 * 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
33
34#include "debug/GPUMem.hh"
35#include "debug/GPUPort.hh"
38#include "gpu-compute/shader.hh"
41
42namespace gem5
43{
44
45LocalMemPipeline::LocalMemPipeline(const ComputeUnitParams &p, ComputeUnit &cu)
46 : computeUnit(cu), _name(cu.name() + ".LocalMemPipeline"),
47 lmQueueSize(p.local_mem_queue_size), stats(&cu)
48{
49}
50
51void
53{
54 // apply any returned shared (LDS) memory operations
56 lmReturnedRequests.front() : nullptr;
57
58 bool accessVrf = true;
59 Wavefront *w = nullptr;
60
61 if ((m) && m->latency.rdy() && (m->isLoad() || m->isAtomicRet())) {
62 w = m->wavefront();
63
64 accessVrf = w->computeUnit->vrf[w->simdId]->
65 canScheduleWriteOperandsFromLoad(w, m);
66
67 }
68
69 if (!lmReturnedRequests.empty() && m->latency.rdy() && accessVrf &&
70 computeUnit.locMemToVrfBus.rdy()
71 && (computeUnit.shader->coissue_return
72 || computeUnit.vectorSharedMemUnit.rdy())) {
73
75 w = m->wavefront();
76
77 if (m->isFlat() && !m->isMemSync() && !m->isEndOfKernel()
78 && m->allLanesZero()) {
79 computeUnit.getTokenManager()->recvTokens(1);
80 }
81
82 DPRINTF(GPUMem, "CU%d: WF[%d][%d]: Completing local mem instr %s\n",
83 m->cu_id, m->simdId, m->wfSlotId, m->disassemble());
84 m->completeAcc(m);
85 w->decLGKMInstsIssued();
86 w->untrackLGKMInst(m);
87
88 if (m->isLoad() || m->isAtomicRet()) {
89 w->computeUnit->vrf[w->simdId]->
90 scheduleWriteOperandsFromLoad(w, m);
91 }
92
93 // Decrement outstanding request count
94 computeUnit.shader->ScheduleAdd(&w->outstandingReqs, m->time, -1);
95
96 if (m->isStore() || m->isAtomic()) {
97 computeUnit.shader->ScheduleAdd(&w->outstandingReqsWrLm,
98 m->time, -1);
99 }
100
101 if (m->isLoad() || m->isAtomic()) {
102 computeUnit.shader->ScheduleAdd(&w->outstandingReqsRdLm,
103 m->time, -1);
104 }
105
106 // Mark write bus busy for appropriate amount of time
107 computeUnit.locMemToVrfBus.set(m->time);
108 if (computeUnit.shader->coissue_return == 0)
109 w->computeUnit->vectorSharedMemUnit.set(m->time);
110 }
111
112 // If pipeline has executed a local memory instruction
113 // execute local memory packet and issue the packets
114 // to LDS
115 if (!lmIssuedRequests.empty() && lmReturnedRequests.size() < lmQueueSize) {
116
118
119 bool returnVal = computeUnit.sendToLds(m);
120 if (!returnVal) {
121 DPRINTF(GPUPort, "packet was nack'd and put in retry queue");
122 }
123 lmIssuedRequests.pop();
124 }
125}
126
127void
129{
130 Wavefront *wf = gpuDynInst->wavefront();
131 if (gpuDynInst->isLoad()) {
132 wf->rdLmReqsInPipe--;
134 } else if (gpuDynInst->isStore()) {
135 wf->wrLmReqsInPipe--;
137 } else {
138 // Atomic, both read and write
139 wf->rdLmReqsInPipe--;
141 wf->wrLmReqsInPipe--;
143 }
144
145 wf->outstandingReqs++;
147
148 gpuDynInst->setAccessTime(curTick());
149 lmIssuedRequests.push(gpuDynInst);
150}
151
152void
154{
155 std::cout << "LMPipe issued: " << lmIssuedRequests.size()
156 << " returned: "<< lmReturnedRequests.size() << "\n";
157}
158
161 : statistics::Group(parent, "LocalMemPipeline"),
162 ADD_STAT(loadVrfBankConflictCycles, "total number of cycles LDS data "
163 "are delayed before updating the VRF")
164{
165}
166
167} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:209
gem5::LocalMemPipeline::LocalMemPipelineStats stats
const std::string & name() const
std::queue< GPUDynInstPtr > lmReturnedRequests
LocalMemPipeline(const ComputeUnitParams &p, ComputeUnit &cu)
void issueRequest(GPUDynInstPtr gpuDynInst)
std::queue< GPUDynInstPtr > lmIssuedRequests
void validateRequestCounters()
Definition wavefront.cc:827
Statistics container.
Definition group.hh:93
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition group.hh:75
Bitfield< 0 > m
Bitfield< 0 > p
Bitfield< 0 > w
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition misc.hh:49
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46

Generated on Mon May 26 2025 09:19:10 for gem5 by doxygen 1.13.2