2 * Copyright (c) 2014-2015 Advanced Micro Devices, Inc.
5 * For use for simulation and test purposes only
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
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.
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.
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.
34 #include "gpu-compute/local_memory_pipeline.hh"
36 #include "debug/GPUPort.hh"
37 #include "gpu-compute/compute_unit.hh"
38 #include "gpu-compute/gpu_dyn_inst.hh"
39 #include "gpu-compute/shader.hh"
40 #include "gpu-compute/vector_register_file.hh"
41 #include "gpu-compute/wavefront.hh"
43 LocalMemPipeline::LocalMemPipeline(const ComputeUnitParams
* p
) :
44 computeUnit(nullptr), lmQueueSize(p
->local_mem_queue_size
)
49 LocalMemPipeline::init(ComputeUnit
*cu
)
52 _name
= computeUnit
->name() + ".LocalMemPipeline";
56 LocalMemPipeline::exec()
58 // apply any returned shared (LDS) memory operations
59 GPUDynInstPtr m
= !lmReturnedRequests
.empty() ?
60 lmReturnedRequests
.front() : nullptr;
62 bool accessVrf
= true;
63 Wavefront
*w
= nullptr;
65 if ((m
) && (m
->isLoad() || m
->isAtomicRet())) {
69 w
->computeUnit
->vrf
[w
->simdId
]->
70 vrfOperandAccessReady(m
->seqNum(), w
, m
,
71 VrfAccessType::WRITE
);
74 if (!lmReturnedRequests
.empty() && m
->latency
.rdy() && accessVrf
&&
75 computeUnit
->locMemToVrfBus
.rdy() && (computeUnit
->shader
->coissue_return
76 || computeUnit
->wfWait
.at(m
->pipeId
).rdy())) {
78 lmReturnedRequests
.pop();
83 // Decrement outstanding request count
84 computeUnit
->shader
->ScheduleAdd(&w
->outstandingReqs
, m
->time
, -1);
86 if (m
->isStore() || m
->isAtomic()) {
87 computeUnit
->shader
->ScheduleAdd(&w
->outstandingReqsWrLm
,
91 if (m
->isLoad() || m
->isAtomic()) {
92 computeUnit
->shader
->ScheduleAdd(&w
->outstandingReqsRdLm
,
96 // Mark write bus busy for appropriate amount of time
97 computeUnit
->locMemToVrfBus
.set(m
->time
);
98 if (computeUnit
->shader
->coissue_return
== 0)
99 w
->computeUnit
->wfWait
.at(m
->pipeId
).set(m
->time
);
102 // If pipeline has executed a local memory instruction
103 // execute local memory packet and issue the packets
105 if (!lmIssuedRequests
.empty() && lmReturnedRequests
.size() < lmQueueSize
) {
107 GPUDynInstPtr m
= lmIssuedRequests
.front();
109 bool returnVal
= computeUnit
->sendToLds(m
);
111 DPRINTF(GPUPort
, "packet was nack'd and put in retry queue");
113 lmIssuedRequests
.pop();
118 LocalMemPipeline::regStats()
120 loadVrfBankConflictCycles
121 .name(name() + ".load_vrf_bank_conflict_cycles")
122 .desc("total number of cycles LDS data are delayed before updating "