gem5  v21.0.1.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 
43 #ifndef __GPU_COMPUTE_DISPATCHER_HH__
44 #define __GPU_COMPUTE_DISPATCHER_HH__
45 
46 #include <queue>
47 #include <unordered_map>
48 #include <vector>
49 
50 #include "base/statistics.hh"
51 #include "base/stats/group.hh"
52 #include "dev/hsa/hsa_packet.hh"
53 #include "params/GPUDispatcher.hh"
54 #include "sim/sim_object.hh"
55 
57 class HSAQueueEntry;
58 class Shader;
59 class Wavefront;
60 
61 class GPUDispatcher : public SimObject
62 {
63  public:
64  typedef GPUDispatcherParams Params;
65 
66  GPUDispatcher(const Params &p);
68 
69  void serialize(CheckpointOut &cp) const override;
70  void unserialize(CheckpointIn &cp) override;
71  void setCommandProcessor(GPUCommandProcessor *gpu_cmd_proc);
72  void setShader(Shader *new_shader);
73  void exec();
75  void updateInvCounter(int kern_id, int val=-1);
76  bool updateWbCounter(int kern_id, int val=-1);
77  int getOutstandingWbs(int kern_id);
78  void notifyWgCompl(Wavefront *wf);
79  void scheduleDispatch();
80  void dispatch(HSAQueueEntry *task);
81  HSAQueueEntry* hsaTask(int disp_id);
82 
83  private:
87  std::unordered_map<int, HSAQueueEntry*> hsaQueueEntries;
88  // list of kernel_ids to launch
89  std::queue<int> execIds;
90  // list of kernel_ids that have finished
91  std::queue<int> doneIds;
92  // is there a kernel in execution?
94 
95  protected:
97  {
99 
102  } stats;
103 };
104 
105 #endif // __GPU_COMPUTE_DISPATCHER_HH__
GPUDispatcher::GPUDispatcher
GPUDispatcher(const Params &p)
Definition: dispatcher.cc:48
GPUDispatcher::gpuCmdProc
GPUCommandProcessor * gpuCmdProc
Definition: dispatcher.hh:85
GPUCommandProcessor
Definition: gpu_command_processor.hh:57
Shader
Definition: shader.hh:87
GPUDispatcher::~GPUDispatcher
~GPUDispatcher()
Definition: dispatcher.cc:57
group.hh
GPUDispatcher::execIds
std::queue< int > execIds
Definition: dispatcher.hh:89
GPUDispatcher::exec
void exec()
Definition: dispatcher.cc:132
GPUDispatcher::isReachingKernelEnd
bool isReachingKernelEnd(Wavefront *wf)
Definition: dispatcher.cc:225
GPUDispatcher::hsaTask
HSAQueueEntry * hsaTask(int disp_id)
Definition: dispatcher.cc:62
HSAQueueEntry
Definition: hsa_queue_entry.hh:58
GPUDispatcher::GPUDispatcherStats
Definition: dispatcher.hh:96
GPUDispatcher
Definition: dispatcher.hh:61
EventFunctionWrapper
Definition: eventq.hh:1112
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1933
GPUDispatcher::notifyWgCompl
void notifyWgCompl(Wavefront *wf)
When an end program instruction detects that the last WF in a WG has completed it will call this meth...
Definition: dispatcher.cc:294
cp
Definition: cprintf.cc:37
sim_object.hh
GPUDispatcher::dispatch
void dispatch(HSAQueueEntry *task)
After all relevant HSA data structures have been traversed/extracted from memory by the CP,...
Definition: dispatcher.cc:113
GPUDispatcher::updateInvCounter
void updateInvCounter(int kern_id, int val=-1)
update the counter of oustanding inv requests for the kernel kern_id: kernel id val: +1/-1,...
Definition: dispatcher.cc:245
statistics.hh
GPUDispatcher::dispatchActive
bool dispatchActive
Definition: dispatcher.hh:93
GPUDispatcher::GPUDispatcherStats::cyclesWaitingForDispatch
Stats::Scalar cyclesWaitingForDispatch
Definition: dispatcher.hh:101
GPUDispatcher::scheduleDispatch
void scheduleDispatch()
Definition: dispatcher.cc:340
GPUDispatcher::setCommandProcessor
void setCommandProcessor(GPUCommandProcessor *gpu_cmd_proc)
Definition: dispatcher.cc:69
GPUDispatcher::shader
Shader * shader
Definition: dispatcher.hh:84
hsa_packet.hh
GPUDispatcher::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: dispatcher.cc:92
GPUDispatcher::doneIds
std::queue< int > doneIds
Definition: dispatcher.hh:91
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
GPUDispatcher::GPUDispatcherStats::numKernelLaunched
Stats::Scalar numKernelLaunched
Definition: dispatcher.hh:100
GPUDispatcher::tickEvent
EventFunctionWrapper tickEvent
Definition: dispatcher.hh:86
GPUDispatcher::Params
GPUDispatcherParams Params
Definition: dispatcher.hh:64
GPUDispatcher::hsaQueueEntries
std::unordered_map< int, HSAQueueEntry * > hsaQueueEntries
Definition: dispatcher.hh:87
GPUDispatcher::GPUDispatcherStats::GPUDispatcherStats
GPUDispatcherStats(Stats::Group *parent)
Definition: dispatcher.cc:347
GPUDispatcher::stats
GPUDispatcher::GPUDispatcherStats stats
Wavefront
Definition: wavefront.hh:59
GPUDispatcher::getOutstandingWbs
int getOutstandingWbs(int kern_id)
get kernel's outstanding cache writeback requests
Definition: dispatcher.cc:279
Stats::Group
Statistics container.
Definition: group.hh:87
GPUDispatcher::setShader
void setShader(Shader *new_shader)
Definition: dispatcher.cc:75
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:64
GPUDispatcher::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: dispatcher.cc:81
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
CheckpointIn
Definition: serialize.hh:68
GPUDispatcher::updateWbCounter
bool updateWbCounter(int kern_id, int val=-1)
update the counter of oustanding wb requests for the kernel kern_id: kernel id val: +1/-1,...
Definition: dispatcher.cc:265
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:141

Generated on Tue Jun 22 2021 15:28:28 for gem5 by doxygen 1.8.17