gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 contributors
18  * may be used to endorse or promote products derived from this software
19  * 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  * Author: Sooraj Puthoor
34  */
35 
37 
38 #include "debug/GPUPort.hh"
41 #include "gpu-compute/shader.hh"
43 #include "gpu-compute/wavefront.hh"
44 
45 LocalMemPipeline::LocalMemPipeline(const ComputeUnitParams* p) :
46  computeUnit(nullptr), lmQueueSize(p->local_mem_queue_size)
47 {
48 }
49 
50 void
52 {
53  computeUnit = cu;
54  _name = computeUnit->name() + ".LocalMemPipeline";
55 }
56 
57 void
59 {
60  // apply any returned shared (LDS) memory operations
62  lmReturnedRequests.front() : nullptr;
63 
64  bool accessVrf = true;
65  Wavefront *w = nullptr;
66 
67  if ((m) && (m->isLoad() || m->isAtomicRet())) {
68  w = m->wavefront();
69 
70  accessVrf =
71  w->computeUnit->vrf[w->simdId]->
72  vrfOperandAccessReady(m->seqNum(), w, m,
74  }
75 
76  if (!lmReturnedRequests.empty() && m->latency.rdy() && accessVrf &&
78  || computeUnit->wfWait.at(m->pipeId).rdy())) {
79 
80  lmReturnedRequests.pop();
81  w = m->wavefront();
82 
83  m->completeAcc(m);
84 
85  // Decrement outstanding request count
86  computeUnit->shader->ScheduleAdd(&w->outstandingReqs, m->time, -1);
87 
88  if (m->isStore() || m->isAtomic()) {
90  m->time, -1);
91  }
92 
93  if (m->isLoad() || m->isAtomic()) {
95  m->time, -1);
96  }
97 
98  // Mark write bus busy for appropriate amount of time
99  computeUnit->locMemToVrfBus.set(m->time);
100  if (computeUnit->shader->coissue_return == 0)
101  w->computeUnit->wfWait.at(m->pipeId).set(m->time);
102  }
103 
104  // If pipeline has executed a local memory instruction
105  // execute local memory packet and issue the packets
106  // to LDS
107  if (!lmIssuedRequests.empty() && lmReturnedRequests.size() < lmQueueSize) {
108 
109  GPUDynInstPtr m = lmIssuedRequests.front();
110 
111  bool returnVal = computeUnit->sendToLds(m);
112  if (!returnVal) {
113  DPRINTF(GPUPort, "packet was nack'd and put in retry queue");
114  }
115  lmIssuedRequests.pop();
116  }
117 }
118 
119 void
121 {
123  .name(name() + ".load_vrf_bank_conflict_cycles")
124  .desc("total number of cycles LDS data are delayed before updating "
125  "the VRF")
126  ;
127 }
int coissue_return
Definition: shader.hh:125
#define DPRINTF(x,...)
Definition: trace.hh:212
bool rdy() const
Definition: misc.hh:70
Bitfield< 0 > m
Definition: miscregs.hh:1577
Stats::Scalar loadVrfBankConflictCycles
std::queue< GPUDynInstPtr > lmIssuedRequests
int simdId
Definition: wavefront.hh:165
void init(ComputeUnit *cu)
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:48
ComputeUnit * computeUnit
Definition: wavefront.hh:167
uint32_t outstandingReqsWrLm
Definition: wavefront.hh:217
Bitfield< 0 > w
const std::string & name() const
uint32_t outstandingReqsRdLm
Definition: wavefront.hh:221
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...
uint32_t outstandingReqs
Definition: wavefront.hh:210
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Definition: statistics.hh:254
std::queue< GPUDynInstPtr > lmReturnedRequests
Shader * shader
virtual const std::string name() const
Definition: sim_object.hh:117
void ScheduleAdd(uint32_t *val, Tick when, int x)
Definition: shader.cc:312
std::vector< VectorRegisterFile * > vrf
WaitClass locMemToVrfBus
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
Definition: statistics.hh:287
LocalMemPipeline(const ComputeUnitParams *params)
std::vector< WaitClass > wfWait
Bitfield< 0 > p
void set(uint32_t i)
Definition: misc.hh:60

Generated on Fri Jun 9 2017 13:03:48 for gem5 by doxygen 1.8.6