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

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17