gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
dispatcher.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015,2018 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  * Authors: Brad Beckmann,
34  * Marc Orr,
35  * Anthony Gutierrez
36  */
37 
38 #ifndef __GPU_DISPATCHER_HH__
39 #define __GPU_DISPATCHER_HH__
40 
41 #include <queue>
42 #include <vector>
43 
44 #include "base/statistics.hh"
45 #include "dev/dma_device.hh"
47 #include "gpu-compute/ndrange.hh"
48 #include "gpu-compute/qstruct.hh"
49 #include "mem/port.hh"
50 #include "params/GpuDispatcher.hh"
51 
52 class BaseCPU;
53 class Shader;
54 
55 class GpuDispatcher : public DmaDevice
56 {
57  public:
58  typedef GpuDispatcherParams Params;
59 
60  MasterID masterId() { return _masterId; }
61 
62  protected:
64 
65  // Base and length of PIO register space
69 
71 
72  std::unordered_map<int, NDRange> ndRangeMap;
74 
75  // list of kernel_ids to launch
76  std::queue<int> execIds;
77  // list of kernel_ids that have finished
78  std::queue<int> doneIds;
79 
80  uint64_t dispatchCount;
81  // is there a kernel in execution?
83 
88 
89 
91 
92  // sycall emulation mode can have only 1 application running(?)
93  // else we have to do some pid based tagging
94  // unused
95  typedef std::unordered_map<uint64_t, uint64_t> TranslationBuffer;
96  TranslationBuffer tlb;
97 
98  public:
99  /*statistics*/
101  GpuDispatcher(const Params *p);
102 
104 
105  void exec();
106  virtual void serialize(CheckpointOut &cp) const override;
107  virtual void unserialize(CheckpointIn &cp) override;
108  void notifyWgCompl(Wavefront *w);
109  void scheduleDispatch();
110  void accessUserVar(BaseCPU *cpu, uint64_t addr, int val, int off);
111 
112  // using singleton so that glue code can pass pointer locations
113  // to the dispatcher. when there are multiple dispatchers, we can
114  // call something like getInstance(index)
115  static void
117  {
118  instance = _instance;
119  }
120 
121  static GpuDispatcher* getInstance() { return instance; }
122 
123  class TLBPort : public MasterPort
124  {
125  public:
126 
127  TLBPort(const std::string &_name, GpuDispatcher *_dispatcher)
128  : MasterPort(_name, _dispatcher), dispatcher(_dispatcher) { }
129 
130  protected:
132 
133  virtual bool recvTimingResp(PacketPtr pkt) { return true; }
134  virtual Tick recvAtomic(PacketPtr pkt) { return 0; }
135  virtual void recvFunctional(PacketPtr pkt) { }
136  virtual void recvRangeChange() { }
137  virtual void recvReqRetry() { }
138 
139  };
140 
142 
143  Port &getPort(const std::string &if_name,
144  PortID idx=InvalidPortID) override;
145 
146  AddrRangeList getAddrRanges() const override;
147  Tick read(PacketPtr pkt) override;
148  Tick write(PacketPtr pkt) override;
149 
150  // helper functions to retrieve/set GPU attributes
151  int getNumCUs();
152  int wfSize() const;
153  void setFuncargsSize(int funcargs_size);
154 
156  uint32_t getStaticContextSize() const;
157 };
158 
159 #endif // __GPU_DISPATCHER_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:75
virtual void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: dispatcher.cc:85
Ports are used to interface objects to each other.
Definition: port.hh:60
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: dispatcher.cc:157
BaseCPU * cpu
Definition: dispatcher.hh:84
uint32_t getStaticContextSize() const
Returns the size of the static hardware context of a wavefront.
Definition: dispatcher.cc:390
const PortID InvalidPortID
Definition: types.hh:238
std::queue< int > execIds
Definition: dispatcher.hh:76
uint64_t dispatchCount
Definition: dispatcher.hh:80
ip6_addr_t addr
Definition: inet.hh:335
GpuDispatcherParams Params
Definition: dispatcher.hh:58
MasterID _masterId
Definition: dispatcher.hh:63
void setFuncargsSize(int funcargs_size)
Definition: dispatcher.cc:384
Definition: shader.hh:76
void accessUserVar(BaseCPU *cpu, uint64_t addr, int val, int off)
Definition: dispatcher.cc:355
Definition: cprintf.cc:42
TLBPort(const std::string &_name, GpuDispatcher *_dispatcher)
Definition: dispatcher.hh:127
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
int wfSize() const
Definition: dispatcher.cc:378
Bitfield< 63 > val
Definition: misc.hh:771
virtual void recvFunctional(PacketPtr pkt)
Definition: dispatcher.hh:135
std::unordered_map< uint64_t, uint64_t > TranslationBuffer
Definition: dispatcher.hh:95
HsaQueueEntry curTask
Definition: dispatcher.hh:70
void notifyWgCompl(Wavefront *w)
Definition: dispatcher.cc:310
ClDriver * driver
Definition: dispatcher.hh:86
uint64_t Tick
Tick count type.
Definition: types.hh:63
virtual void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: dispatcher.cc:100
virtual void recvRangeChange()
Called to receive an address range change from the peer slave port.
Definition: dispatcher.hh:136
TranslationBuffer tlb
Definition: dispatcher.hh:96
static void setInstance(GpuDispatcher *_instance)
Definition: dispatcher.hh:116
Port Object Declaration.
std::queue< int > doneIds
Definition: dispatcher.hh:78
Bitfield< 0 > w
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
uint16_t MasterID
Definition: request.hh:86
Stats::Scalar num_kernelLaunched
Definition: dispatcher.hh:100
virtual Tick recvAtomic(PacketPtr pkt)
Definition: dispatcher.hh:134
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
static GpuDispatcher * getInstance()
Definition: dispatcher.hh:121
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: dispatcher.hh:133
Shader * shader
Definition: dispatcher.hh:85
AddrRangeList getAddrRanges() const
Get the address ranges of the connected slave port.
Definition: port.cc:93
EventFunctionWrapper tickEvent
Definition: dispatcher.hh:87
std::ostream CheckpointOut
Definition: serialize.hh:68
void scheduleDispatch()
Definition: dispatcher.cc:348
bool dispatchActive
Definition: dispatcher.hh:82
GpuDispatcher * dispatcher
Definition: dispatcher.hh:131
TLBPort * tlbPort
Definition: dispatcher.hh:141
MasterID masterId()
Definition: dispatcher.hh:60
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: dispatcher.cc:127
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
std::unordered_map< int, NDRange > ndRangeMap
Definition: dispatcher.hh:72
static GpuDispatcher * instance
Definition: dispatcher.hh:90
NDRange ndRange
Definition: dispatcher.hh:73
Bitfield< 0 > p
GpuDispatcher(const Params *p)
Definition: dispatcher.cc:51
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: dispatcher.hh:137
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: dispatcher.cc:255

Generated on Fri Feb 28 2020 16:27:01 for gem5 by doxygen 1.8.13