gem5  v21.0.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  * 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 
34 #ifndef __DEV_HSA_HW_SCHEDULER_HH__
35 #define __DEV_HSA_HW_SCHEDULER_HH__
36 
38 
39 // We allocate one PIO page for doorbells and each
40 // address is 8 bytes
41 #define MAX_ACTIVE_QUEUES (PAGE_SIZE/8)
42 
44 {
45  public:
46  HWScheduler(HSAPacketProcessor* hsa_pp, Tick wakeup_delay)
47  : hsaPP(hsa_pp), nextALId(0), nextRLId(0),
48  wakeupDelay(wakeup_delay), schedWakeupEvent(this)
49  {}
50  void write(Addr db_addr, uint32_t doorbell_reg);
51  void registerNewQueue(uint64_t hostReadIndexPointer,
52  uint64_t basePointer,
53  uint64_t queue_id,
54  uint32_t size);
55  void unregisterQueue(uint64_t queue_id);
56  void wakeup();
57  void schedWakeup();
58  class SchedulerWakeupEvent : public Event
59  {
60  private:
62  public:
63  SchedulerWakeupEvent(HWScheduler *hw_schdlr) : hwSchdlr(hw_schdlr) {}
64  virtual void process();
65  virtual const char *description() const;
66  };
67  bool isRLQIdle(uint32_t rl_idx);
68  bool findNextActiveALQ();
69  bool findNextIdleRLQ();
70  bool unmapQFromRQ();
71  bool contextSwitchQ();
72  bool findEmptyHWQ();
73  bool mapQIfSlotAvlbl(uint32_t al_idx, AQLRingBuffer* aql_buf,
74  HSAQueueDescriptor* q_desc);
75  void addQCntxt(uint32_t al_idx, AQLRingBuffer* aql_buf,
76  HSAQueueDescriptor* q_desc);
77  void removeQCntxt();
79  void updateRRVars(uint32_t al_idx, uint32_t rl_idx);
80 
81  private:
82  // Active list keeps track of all queues created
83  std::map<uint32_t, QCntxt> activeList;
84  //TODO: Modify this to support multi-process in the future.
85  // doorbell map, maps doorbells to active list entry
86  std::map<Addr, uint32_t> dbMap;
87  // regdListMap keeps track of the mapping of queues to
88  // registered list. regdListMap is indexed with active
89  // list index (which is same as queue ID)
90  std::map<uint32_t, uint32_t> regdListMap;
92 
93  // Scheduling information.
94  // For now, this is simple round robin but
95  // this will be changed to a sophisticated logic
96  // in the future. So, in the future, we will
97  // move these variables into a scheduler class
98  uint32_t nextALId;
99  uint32_t nextRLId;
102 };
103 
104 #endif // __DEV_HSA_HW_SCHEDULER_HH__
HWScheduler::registerNewQueue
void registerNewQueue(uint64_t hostReadIndexPointer, uint64_t basePointer, uint64_t queue_id, uint32_t size)
Definition: hw_scheduler.cc:82
HWScheduler::mapQIfSlotAvlbl
bool mapQIfSlotAvlbl(uint32_t al_idx, AQLRingBuffer *aql_buf, HSAQueueDescriptor *q_desc)
Definition: hw_scheduler.cc:150
HWScheduler::dbMap
std::map< Addr, uint32_t > dbMap
Definition: hw_scheduler.hh:86
HWScheduler::unregisterQueue
void unregisterQueue(uint64_t queue_id)
Definition: hw_scheduler.cc:336
HWScheduler::scheduleAndWakeupMappedQ
void scheduleAndWakeupMappedQ()
Definition: hw_scheduler.cc:165
hsa_packet_processor.hh
HWScheduler::unmapQFromRQ
bool unmapQFromRQ()
Definition: hw_scheduler.cc:228
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
HWScheduler::schedWakeup
void schedWakeup()
Definition: hw_scheduler.cc:69
HWScheduler::findNextActiveALQ
bool findNextActiveALQ()
Definition: hw_scheduler.cc:260
HSAQueueDescriptor
Definition: hsa_packet_processor.hh:72
HWScheduler::findEmptyHWQ
bool findEmptyHWQ()
Definition: hw_scheduler.cc:128
AQLRingBuffer
Internal ring buffer which is used to prefetch/store copies of the in-memory HSA ring buffer.
Definition: hsa_packet_processor.hh:117
HWScheduler
Definition: hw_scheduler.hh:43
HWScheduler::activeList
std::map< uint32_t, QCntxt > activeList
Definition: hw_scheduler.hh:83
HWScheduler::SchedulerWakeupEvent::SchedulerWakeupEvent
SchedulerWakeupEvent(HWScheduler *hw_schdlr)
Definition: hw_scheduler.hh:63
HWScheduler::updateRRVars
void updateRRVars(uint32_t al_idx, uint32_t rl_idx)
Definition: hw_scheduler.cc:221
HSAPacketProcessor
Definition: hsa_packet_processor.hh:212
Event
Definition: eventq.hh:248
HWScheduler::isRLQIdle
bool isRLQIdle(uint32_t rl_idx)
Definition: hw_scheduler.cc:296
HWScheduler::wakeupDelay
const Tick wakeupDelay
Definition: hw_scheduler.hh:100
HWScheduler::nextRLId
uint32_t nextRLId
Definition: hw_scheduler.hh:99
HWScheduler::SchedulerWakeupEvent::process
virtual void process()
Definition: hw_scheduler.cc:49
HWScheduler::SchedulerWakeupEvent
Definition: hw_scheduler.hh:58
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
HWScheduler::wakeup
void wakeup()
Definition: hw_scheduler.cc:55
HWScheduler::regdListMap
std::map< uint32_t, uint32_t > regdListMap
Definition: hw_scheduler.hh:90
HWScheduler::hsaPP
HSAPacketProcessor * hsaPP
Definition: hw_scheduler.hh:91
HWScheduler::write
void write(Addr db_addr, uint32_t doorbell_reg)
Definition: hw_scheduler.cc:319
HWScheduler::addQCntxt
void addQCntxt(uint32_t al_idx, AQLRingBuffer *aql_buf, HSAQueueDescriptor *q_desc)
Definition: hw_scheduler.cc:176
HWScheduler::SchedulerWakeupEvent::description
virtual const char * description() const
Return a C string describing the event.
HWScheduler::SchedulerWakeupEvent::hwSchdlr
HWScheduler * hwSchdlr
Definition: hw_scheduler.hh:61
HWScheduler::contextSwitchQ
bool contextSwitchQ()
Definition: hw_scheduler.cc:191
HWScheduler::removeQCntxt
void removeQCntxt()
Definition: hw_scheduler.cc:240
HWScheduler::findNextIdleRLQ
bool findNextIdleRLQ()
Definition: hw_scheduler.cc:282
HWScheduler::HWScheduler
HWScheduler(HSAPacketProcessor *hsa_pp, Tick wakeup_delay)
Definition: hw_scheduler.hh:46
HWScheduler::schedWakeupEvent
SchedulerWakeupEvent schedWakeupEvent
Definition: hw_scheduler.hh:101
HWScheduler::nextALId
uint32_t nextALId
Definition: hw_scheduler.hh:98

Generated on Tue Mar 23 2021 19:41:26 for gem5 by doxygen 1.8.17