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

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