gem5  v21.2.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
hw_scheduler.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2017 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef __DEV_HSA_HW_SCHEDULER_HH__
33 #define __DEV_HSA_HW_SCHEDULER_HH__
34 
35 #include <cstdint>
36 #include <map>
37 
38 #include "base/types.hh"
40 #include "enums/GfxVersion.hh"
41 #include "sim/eventq.hh"
42 
43 // We allocate one PIO page for doorbells and each
44 // address is 8 bytes
45 #define MAX_ACTIVE_QUEUES (PAGE_SIZE/8)
46 
47 namespace gem5
48 {
49 
51 {
52  public:
53  HWScheduler(HSAPacketProcessor* hsa_pp, Tick wakeup_delay)
54  : hsaPP(hsa_pp), nextALId(0), nextRLId(0),
55  wakeupDelay(wakeup_delay), schedWakeupEvent(this)
56  {}
57  void write(Addr db_addr, uint64_t doorbell_reg);
58  void registerNewQueue(uint64_t hostReadIndexPointer,
59  uint64_t basePointer,
60  uint64_t queue_id,
61  uint32_t size, int doorbellSize,
62  GfxVersion gfxVersion);
63  void unregisterQueue(uint64_t queue_id, int doorbellSize);
64  void wakeup();
65  void schedWakeup();
66  class SchedulerWakeupEvent : public Event
67  {
68  private:
70  public:
71  SchedulerWakeupEvent(HWScheduler *hw_schdlr) : hwSchdlr(hw_schdlr) {}
72  virtual void process();
73  virtual const char *description() const;
74  };
75  bool isRLQIdle(uint32_t rl_idx);
76  bool findNextActiveALQ();
77  bool findNextIdleRLQ();
78  bool unmapQFromRQ();
79  bool contextSwitchQ();
80  bool findEmptyHWQ();
81  bool mapQIfSlotAvlbl(uint32_t al_idx, AQLRingBuffer* aql_buf,
82  HSAQueueDescriptor* q_desc);
83  void addQCntxt(uint32_t al_idx, AQLRingBuffer* aql_buf,
84  HSAQueueDescriptor* q_desc);
85  void removeQCntxt();
87  void updateRRVars(uint32_t al_idx, uint32_t rl_idx);
88 
89  private:
90  // Active list keeps track of all queues created
91  std::map<uint32_t, QCntxt> activeList;
92  //TODO: Modify this to support multi-process in the future.
93  // doorbell map, maps doorbells to active list entry
94  std::map<Addr, uint32_t> dbMap;
95  // regdListMap keeps track of the mapping of queues to
96  // registered list. regdListMap is indexed with active
97  // list index (which is same as queue ID)
98  std::map<uint32_t, uint32_t> regdListMap;
100 
101  // Scheduling information.
102  // For now, this is simple round robin but
103  // this will be changed to a sophisticated logic
104  // in the future. So, in the future, we will
105  // move these variables into a scheduler class
106  uint32_t nextALId;
107  uint32_t nextRLId;
110 };
111 
112 } // namespace gem5
113 
114 #endif // __DEV_HSA_HW_SCHEDULER_HH__
gem5::HWScheduler::SchedulerWakeupEvent::process
virtual void process()
Definition: hw_scheduler.cc:52
gem5::HWScheduler::nextRLId
uint32_t nextRLId
Definition: hw_scheduler.hh:107
gem5::HWScheduler::SchedulerWakeupEvent::description
virtual const char * description() const
Return a C string describing the event.
gem5::HWScheduler::removeQCntxt
void removeQCntxt()
Definition: hw_scheduler.cc:240
gem5::HWScheduler::SchedulerWakeupEvent::SchedulerWakeupEvent
SchedulerWakeupEvent(HWScheduler *hw_schdlr)
Definition: hw_scheduler.hh:71
gem5::HWScheduler::dbMap
std::map< Addr, uint32_t > dbMap
Definition: hw_scheduler.hh:94
gem5::HWScheduler::findEmptyHWQ
bool findEmptyHWQ()
Definition: hw_scheduler.cc:128
gem5::HWScheduler::wakeup
void wakeup()
Definition: hw_scheduler.cc:58
gem5::HWScheduler::unmapQFromRQ
bool unmapQFromRQ()
Definition: hw_scheduler.cc:228
hsa_packet_processor.hh
gem5::HWScheduler::findNextActiveALQ
bool findNextActiveALQ()
Definition: hw_scheduler.cc:260
gem5::HWScheduler::isRLQIdle
bool isRLQIdle(uint32_t rl_idx)
Definition: hw_scheduler.cc:296
gem5::HWScheduler::contextSwitchQ
bool contextSwitchQ()
Definition: hw_scheduler.cc:191
gem5::HWScheduler::schedWakeup
void schedWakeup()
Definition: hw_scheduler.cc:72
gem5::HSAPacketProcessor
Definition: hsa_packet_processor.hh:249
gem5::Event
Definition: eventq.hh:251
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::HWScheduler::SchedulerWakeupEvent
Definition: hw_scheduler.hh:66
gem5::HSAQueueDescriptor
Definition: hsa_packet_processor.hh:76
gem5::HWScheduler::unregisterQueue
void unregisterQueue(uint64_t queue_id, int doorbellSize)
Definition: hw_scheduler.cc:336
gem5::HWScheduler::mapQIfSlotAvlbl
bool mapQIfSlotAvlbl(uint32_t al_idx, AQLRingBuffer *aql_buf, HSAQueueDescriptor *q_desc)
Definition: hw_scheduler.cc:150
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::HWScheduler
Definition: hw_scheduler.hh:50
gem5::HWScheduler::findNextIdleRLQ
bool findNextIdleRLQ()
Definition: hw_scheduler.cc:282
gem5::HWScheduler::activeList
std::map< uint32_t, QCntxt > activeList
Definition: hw_scheduler.hh:91
gem5::HWScheduler::registerNewQueue
void registerNewQueue(uint64_t hostReadIndexPointer, uint64_t basePointer, uint64_t queue_id, uint32_t size, int doorbellSize, GfxVersion gfxVersion)
Definition: hw_scheduler.cc:85
gem5::HWScheduler::addQCntxt
void addQCntxt(uint32_t al_idx, AQLRingBuffer *aql_buf, HSAQueueDescriptor *q_desc)
Definition: hw_scheduler.cc:176
gem5::HWScheduler::HWScheduler
HWScheduler(HSAPacketProcessor *hsa_pp, Tick wakeup_delay)
Definition: hw_scheduler.hh:53
gem5::HWScheduler::nextALId
uint32_t nextALId
Definition: hw_scheduler.hh:106
types.hh
gem5::HWScheduler::hsaPP
HSAPacketProcessor * hsaPP
Definition: hw_scheduler.hh:99
gem5::HWScheduler::scheduleAndWakeupMappedQ
void scheduleAndWakeupMappedQ()
Definition: hw_scheduler.cc:165
gem5::AQLRingBuffer
Internal ring buffer which is used to prefetch/store copies of the in-memory HSA ring buffer.
Definition: hsa_packet_processor.hh:154
gem5::HWScheduler::wakeupDelay
const Tick wakeupDelay
Definition: hw_scheduler.hh:108
gem5::HWScheduler::updateRRVars
void updateRRVars(uint32_t al_idx, uint32_t rl_idx)
Definition: hw_scheduler.cc:221
gem5::HWScheduler::SchedulerWakeupEvent::hwSchdlr
HWScheduler * hwSchdlr
Definition: hw_scheduler.hh:69
gem5::HWScheduler::schedWakeupEvent
SchedulerWakeupEvent schedWakeupEvent
Definition: hw_scheduler.hh:109
gem5::HWScheduler::write
void write(Addr db_addr, uint64_t doorbell_reg)
Definition: hw_scheduler.cc:319
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::HWScheduler::regdListMap
std::map< uint32_t, uint32_t > regdListMap
Definition: hw_scheduler.hh:98
eventq.hh

Generated on Tue Dec 21 2021 11:34:29 for gem5 by doxygen 1.8.17