gem5  v21.0.1.0
gpu_command_processor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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 
45 #ifndef __DEV_HSA_GPU_COMMAND_PROCESSOR_HH__
46 #define __DEV_HSA_GPU_COMMAND_PROCESSOR_HH__
47 
48 #include "dev/hsa/hsa_device.hh"
49 #include "dev/hsa/hsa_signal.hh"
52 
53 struct GPUCommandProcessorParams;
54 class GPUDispatcher;
55 class Shader;
56 
58 {
59  public:
60  typedef GPUCommandProcessorParams Params;
61 
62  GPUCommandProcessor() = delete;
64 
65  void setShader(Shader *shader);
66  Shader* shader();
67 
68  enum AgentCmd {
69  Nop = 0,
70  Steal = 1
71  };
72 
73  void submitAgentDispatchPkt(void *raw_pkt, uint32_t queue_id,
74  Addr host_pkt_addr) override;
75  void submitDispatchPkt(void *raw_pkt, uint32_t queue_id,
76  Addr host_pkt_addr) override;
77  void submitVendorPkt(void *raw_pkt, uint32_t queue_id,
78  Addr host_pkt_addr) override;
79  void attachDriver(HSADriver *driver) override;
80  void dispatchPkt(HSAQueueEntry *task);
81  void signalWakeupEvent(uint32_t event_id);
82 
83  Tick write(PacketPtr pkt) override { return 0; }
84  Tick read(PacketPtr pkt) override { return 0; }
85  AddrRangeList getAddrRanges() const override;
86  System *system();
87 
88  void updateHsaSignal(Addr signal_handle, uint64_t signal_value) override;
89 
90  uint64_t functionalReadHsaSignal(Addr signal_handle) override;
91 
93  {
94  return signal_handle + offsetof(amd_signal_t, value);
95  }
96 
98  {
99  return signal_handle + offsetof(amd_signal_t, event_mailbox_ptr);
100  }
101 
103  {
104  return signal_handle + offsetof(amd_signal_t, event_id);
105  }
106 
107  private:
111 
112  void initABI(HSAQueueEntry *task);
113 
127  {
128  public:
130  HSAQueueEntry *task)
131  : DmaCallback(), readDispIdOffset(0), gpuCmdProc(gpu_cmd_proc),
132  _task(task)
133  {
134  }
135 
136  void
137  process() override
138  {
149 
154  auto *mqdDmaEvent = new MQDDmaEvent(gpuCmdProc, _task);
156  sizeof(_amd_queue_t), mqdDmaEvent,
157  &_task->amdQueue);
158  }
159 
161 
162  private:
165  };
166 
174  class MQDDmaEvent : public DmaCallback
175  {
176  public:
178  : DmaCallback(), gpuCmdProc(gpu_cmd_proc), _task(task)
179  {
180  }
181 
182  void
183  process() override
184  {
186  }
187 
188  private:
191  };
192 };
193 
194 #endif // __DEV_HSA_GPU_COMMAND_PROCESSOR_HH__
HSADevice::hsaPP
HSAPacketProcessor * hsaPP
Definition: hsa_device.hh:116
hsa_queue_entry.hh
GPUCommandProcessor::ReadDispIdOffsetDmaEvent::process
void process() override
Callback function invoked on completion of all chunks.
Definition: gpu_command_processor.hh:137
GPUCommandProcessor::functionalReadHsaSignal
uint64_t functionalReadHsaSignal(Addr signal_handle) override
Definition: gpu_command_processor.cc:151
GPUCommandProcessor::dispatchPkt
void dispatchPkt(HSAQueueEntry *task)
Once the CP has finished extracting all relevant information about a task and has initialized the ABI...
Definition: gpu_command_processor.cc:280
GPUCommandProcessor::dispatcher
GPUDispatcher & dispatcher
Definition: gpu_command_processor.hh:109
GPUCommandProcessor
Definition: gpu_command_processor.hh:57
GPUCommandProcessor::_shader
Shader * _shader
Definition: gpu_command_processor.hh:108
Shader
Definition: shader.hh:87
GPUCommandProcessor::AgentCmd
AgentCmd
Definition: gpu_command_processor.hh:68
HSAPacketProcessor::getQueueDesc
HSAQueueDescriptor * getQueueDesc(uint32_t queId)
Definition: hsa_packet_processor.hh:295
GPUCommandProcessor::getAddrRanges
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition: gpu_command_processor.cc:317
GPUCommandProcessor::ReadDispIdOffsetDmaEvent
Perform a DMA read of the read_dispatch_id_field_base_byte_offset field, which follows directly after...
Definition: gpu_command_processor.hh:126
GPUCommandProcessor::ReadDispIdOffsetDmaEvent::readDispIdOffset
uint32_t readDispIdOffset
Definition: gpu_command_processor.hh:160
GPUCommandProcessor::GPUCommandProcessor
GPUCommandProcessor()=delete
GPUCommandProcessor::submitDispatchPkt
void submitDispatchPkt(void *raw_pkt, uint32_t queue_id, Addr host_pkt_addr) override
submitDispatchPkt() is the entry point into the CP from the HSAPP and is only meant to be used with A...
Definition: gpu_command_processor.cc:68
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
GPUCommandProcessor::MQDDmaEvent
Perform a DMA read of the MQD that corresponds to a hardware queue descriptor (HQD).
Definition: gpu_command_processor.hh:174
GPUCommandProcessor::MQDDmaEvent::process
void process() override
Callback function invoked on completion of all chunks.
Definition: gpu_command_processor.hh:183
GPUCommandProcessor::ReadDispIdOffsetDmaEvent::_task
HSAQueueEntry * _task
Definition: gpu_command_processor.hh:164
HSADevice::dmaReadVirt
void dmaReadVirt(Addr host_addr, unsigned size, DmaCallback *cb, void *data, Tick delay=0)
Definition: hsa_device.cc:46
HSAQueueEntry
Definition: hsa_queue_entry.hh:58
GPUCommandProcessor::getHsaSignalValueAddr
Addr getHsaSignalValueAddr(Addr signal_handle)
Definition: gpu_command_processor.hh:92
amd_signal_s
Definition: hsa_signal.hh:46
GPUCommandProcessor::shader
Shader * shader()
Definition: gpu_command_processor.cc:330
GPUDispatcher
Definition: dispatcher.hh:61
HSAQueueEntry::amdQueue
_amd_queue_t amdQueue
Keep a copy of the AMD HSA queue because we need info from some of its fields to initialize register ...
Definition: hsa_queue_entry.hh:306
HSAQueueEntry::queueId
uint32_t queueId() const
Definition: hsa_queue_entry.hh:146
HSAQueueDescriptor::hostReadIndexPtr
uint64_t hostReadIndexPtr
Definition: hsa_packet_processor.hh:79
GPUCommandProcessor::updateHsaSignal
void updateHsaSignal(Addr signal_handle, uint64_t signal_value) override
Definition: gpu_command_processor.cc:160
GPUCommandProcessor::submitAgentDispatchPkt
void submitAgentDispatchPkt(void *raw_pkt, uint32_t queue_id, Addr host_pkt_addr) override
submitAgentDispatchPkt() is for accepting agent dispatch packets.
Definition: gpu_command_processor.cc:233
HSAQueueEntry::hostAMDQueueAddr
Addr hostAMDQueueAddr
Host-side addr of the amd_queue_t on which this task was queued.
Definition: hsa_queue_entry.hh:299
GPUCommandProcessor::Params
GPUCommandProcessorParams Params
Definition: gpu_command_processor.hh:60
System
Definition: system.hh:73
GPUCommandProcessor::MQDDmaEvent::MQDDmaEvent
MQDDmaEvent(GPUCommandProcessor &gpu_cmd_proc, HSAQueueEntry *task)
Definition: gpu_command_processor.hh:177
GPUCommandProcessor::setShader
void setShader(Shader *shader)
Definition: gpu_command_processor.cc:324
GPUCommandProcessor::driver
HSADriver * driver
Definition: gpu_command_processor.hh:110
GPUCommandProcessor::getHsaSignalEventAddr
Addr getHsaSignalEventAddr(Addr signal_handle)
Definition: gpu_command_processor.hh:102
GPUCommandProcessor::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: gpu_command_processor.hh:84
GPUCommandProcessor::MQDDmaEvent::_task
HSAQueueEntry * _task
Definition: gpu_command_processor.hh:190
hsa_signal.hh
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
GPUCommandProcessor::MQDDmaEvent::gpuCmdProc
GPUCommandProcessor & gpuCmdProc
Definition: gpu_command_processor.hh:189
_amd_queue_s
Definition: hsa_queue.hh:63
GPUCommandProcessor::attachDriver
void attachDriver(HSADriver *driver) override
Definition: gpu_command_processor.cc:195
GPUCommandProcessor::submitVendorPkt
void submitVendorPkt(void *raw_pkt, uint32_t queue_id, Addr host_pkt_addr) override
submitVendorPkt() is for accepting vendor-specific packets from the HSAPP.
Definition: gpu_command_processor.cc:219
GPUCommandProcessor::system
System * system()
Definition: gpu_command_processor.cc:311
GPUCommandProcessor::Nop
@ Nop
Definition: gpu_command_processor.hh:69
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:258
GPUCommandProcessor::signalWakeupEvent
void signalWakeupEvent(uint32_t event_id)
Definition: gpu_command_processor.cc:286
DmaCallback
DMA callback class.
Definition: dma_device.hh:257
GPUCommandProcessor::Steal
@ Steal
Definition: gpu_command_processor.hh:70
GPUCommandProcessor::ReadDispIdOffsetDmaEvent::gpuCmdProc
GPUCommandProcessor & gpuCmdProc
Definition: gpu_command_processor.hh:163
HSADriver
Definition: hsa_driver.hh:61
gpu_compute_driver.hh
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
std::list< AddrRange >
GPUCommandProcessor::initABI
void initABI(HSAQueueEntry *task)
The CP is responsible for traversing all HSA-ABI-related data structures from memory and initializing...
Definition: gpu_command_processor.cc:298
hsa_device.hh
HSADevice
Definition: hsa_device.hh:43
GPUCommandProcessor::ReadDispIdOffsetDmaEvent::ReadDispIdOffsetDmaEvent
ReadDispIdOffsetDmaEvent(GPUCommandProcessor &gpu_cmd_proc, HSAQueueEntry *task)
Definition: gpu_command_processor.hh:129
GPUCommandProcessor::getHsaSignalMailboxAddr
Addr getHsaSignalMailboxAddr(Addr signal_handle)
Definition: gpu_command_processor.hh:97
DmaDevice::Params
DmaDeviceParams Params
Definition: dma_device.hh:206
GPUCommandProcessor::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: gpu_command_processor.hh:83

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