gem5  v21.0.1.0
scalar_memory_pipeline.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2017 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/GPUReg.hh"
41 #include "gpu-compute/shader.hh"
42 #include "gpu-compute/wavefront.hh"
43 
44 ScalarMemPipeline::ScalarMemPipeline(const ComputeUnitParams &p,
45  ComputeUnit &cu)
46  : computeUnit(cu), _name(cu.name() + ".ScalarMemPipeline"),
47  queueSize(p.scalar_mem_queue_size),
48  inflightStores(0), inflightLoads(0)
49 {
50 }
51 
52 void
54 {
55  // afind oldest scalar request whose data has arrived
56  GPUDynInstPtr m = !returnedLoads.empty() ? returnedLoads.front() :
57  !returnedStores.empty() ? returnedStores.front() : nullptr;
58 
59  Wavefront *w = nullptr;
60 
61  bool accessSrf = true;
62  // check the SRF to see if the operands of a load (or load component
63  // of an atomic) are accessible
64  if ((m) && (m->isLoad() || m->isAtomicRet())) {
65  w = m->wavefront();
66 
67  accessSrf =
68  w->computeUnit->srf[w->simdId]->
69  canScheduleWriteOperandsFromLoad(w, m);
70  }
71 
72  if ((!returnedStores.empty() || !returnedLoads.empty()) &&
73  m->latency.rdy() && computeUnit.scalarMemToSrfBus.rdy() &&
74  accessSrf &&
77 
78  w = m->wavefront();
79 
80  if (m->isLoad() || m->isAtomicRet()) {
81  w->computeUnit->srf[w->simdId]->
82  scheduleWriteOperandsFromLoad(w, m);
83  }
84 
85  m->completeAcc(m);
86  w->decLGKMInstsIssued();
87 
88  if (m->isLoad() || m->isAtomic()) {
89  returnedLoads.pop();
90  assert(inflightLoads > 0);
91  --inflightLoads;
92  } else {
93  returnedStores.pop();
94  assert(inflightStores > 0);
96  }
97 
98  // Decrement outstanding register count
99  computeUnit.shader->ScheduleAdd(&w->outstandingReqs, m->time, -1);
100 
101  if (m->isStore() || m->isAtomic()) {
102  computeUnit.shader->ScheduleAdd(&w->scalarOutstandingReqsWrGm,
103  m->time, -1);
104  }
105 
106  if (m->isLoad() || m->isAtomic()) {
107  computeUnit.shader->ScheduleAdd(&w->scalarOutstandingReqsRdGm,
108  m->time, -1);
109  }
110 
111  // Mark write bus busy for appropriate amount of time
114  w->computeUnit->scalarMemUnit.set(m->time);
115  }
116 
117  // If pipeline has executed a global memory instruction
118  // execute global memory packets and issue global
119  // memory packets to DTLB
120  if (!issuedRequests.empty()) {
121  GPUDynInstPtr mp = issuedRequests.front();
122  if (mp->isLoad() || mp->isAtomic()) {
123 
124  if (inflightLoads >= queueSize) {
125  return;
126  } else {
127  ++inflightLoads;
128  }
129  } else {
130  if (inflightStores >= queueSize) {
131  return;
132  } else {
133  ++inflightStores;
134  }
135  }
136  mp->initiateAcc(mp);
137  issuedRequests.pop();
138 
139  DPRINTF(GPUMem, "CU%d: WF[%d][%d] Popping scalar mem_op\n",
140  computeUnit.cu_id, mp->simdId, mp->wfSlotId);
141  }
142 }
shader.hh
ScalarMemPipeline::computeUnit
ComputeUnit & computeUnit
Definition: scalar_memory_pipeline.hh:88
ScalarMemPipeline::returnedLoads
std::queue< GPUDynInstPtr > returnedLoads
Definition: scalar_memory_pipeline.hh:107
compute_unit.hh
ScalarMemPipeline::returnedStores
std::queue< GPUDynInstPtr > returnedStores
Definition: scalar_memory_pipeline.hh:103
ComputeUnit::cu_id
int cu_id
Definition: compute_unit.hh:291
ScalarMemPipeline::issuedRequests
std::queue< GPUDynInstPtr > issuedRequests
Definition: scalar_memory_pipeline.hh:99
ScalarMemPipeline::ScalarMemPipeline
ScalarMemPipeline(const ComputeUnitParams &p, ComputeUnit &cu)
Definition: scalar_memory_pipeline.cc:44
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
MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:278
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:237
ScalarMemPipeline::inflightStores
int inflightStores
Definition: scalar_memory_pipeline.hh:94
WaitClass::set
void set(uint64_t i)
Definition: misc.hh:79
scalar_register_file.hh
gpu_dyn_inst.hh
ComputeUnit::scalarMemUnit
WaitClass scalarMemUnit
Definition: compute_unit.hh:240
ScalarMemPipeline::exec
void exec()
Definition: scalar_memory_pipeline.cc:53
scalar_memory_pipeline.hh
name
const std::string & name()
Definition: trace.cc:48
ScalarMemPipeline::queueSize
int queueSize
Definition: scalar_memory_pipeline.hh:90
ComputeUnit::scalarMemToSrfBus
WaitClass scalarMemToSrfBus
Definition: compute_unit.hh:236
Shader::ScheduleAdd
void ScheduleAdd(int *val, Tick when, int x)
Definition: shader.cc:356
Wavefront
Definition: wavefront.hh:59
ScalarMemPipeline::inflightLoads
int inflightLoads
Definition: scalar_memory_pipeline.hh:95
GPUDynInstPtr
std::shared_ptr< GPUDynInst > GPUDynInstPtr
Definition: misc.hh:48
ArmISA::mp
Bitfield< 11 > mp
Definition: miscregs_types.hh:762
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