From 9190940511b5783811bc6288dd4f22f8d18c9d26 Mon Sep 17 00:00:00 2001 From: Nilay Vaish Date: Mon, 27 Aug 2012 01:00:55 -0500 Subject: [PATCH] Ruby: Remove RubyEventQueue This patch removes RubyEventQueue. Consumer objects now rely on RubySystem or themselves for scheduling events. --- .../directedtest/RubyDirectedTester.cc | 1 - src/cpu/testers/rubytest/Check.cc | 4 +- src/cpu/testers/rubytest/RubyTester.cc | 5 +- src/mem/ruby/buffers/MessageBuffer.cc | 53 +++++----- src/mem/ruby/buffers/MessageBuffer.hh | 3 +- .../RubyEventQueue.cc => common/Consumer.cc} | 43 ++++----- src/mem/ruby/common/Consumer.hh | 55 ++++++----- src/mem/ruby/common/Global.cc | 2 - src/mem/ruby/common/Global.hh | 3 - src/mem/ruby/common/SConscript | 1 + src/mem/ruby/common/TypeDefines.hh | 2 - src/mem/ruby/eventqueue/RubyEventQueue.hh | 96 ------------------- src/mem/ruby/eventqueue/RubyEventQueueNode.cc | 41 -------- src/mem/ruby/eventqueue/RubyEventQueueNode.hh | 69 ------------- src/mem/ruby/eventqueue/SConscript | 37 ------- .../ruby/network/garnet/BaseGarnetNetwork.cc | 2 +- .../garnet/fixed-pipeline/GarnetNetwork_d.cc | 4 +- .../garnet/fixed-pipeline/InputUnit_d.cc | 2 +- .../garnet/fixed-pipeline/InputUnit_d.hh | 2 +- .../fixed-pipeline/NetworkInterface_d.cc | 26 ++--- .../garnet/fixed-pipeline/NetworkLink_d.cc | 4 +- .../garnet/fixed-pipeline/OutVcState_d.cc | 4 +- .../garnet/fixed-pipeline/OutputUnit_d.cc | 2 +- .../garnet/fixed-pipeline/OutputUnit_d.hh | 6 +- .../network/garnet/fixed-pipeline/Router_d.cc | 6 +- .../garnet/fixed-pipeline/SWallocator_d.cc | 4 +- .../network/garnet/fixed-pipeline/Switch_d.cc | 6 +- .../garnet/fixed-pipeline/VCallocator_d.cc | 2 +- .../garnet/fixed-pipeline/VirtualChannel_d.cc | 8 +- .../garnet/fixed-pipeline/VirtualChannel_d.hh | 2 +- .../garnet/fixed-pipeline/flitBuffer_d.cc | 4 +- .../network/garnet/fixed-pipeline/flit_d.cc | 6 +- .../network/garnet/fixed-pipeline/flit_d.hh | 6 +- .../garnet/flexible-pipeline/GarnetNetwork.cc | 4 +- .../flexible-pipeline/NetworkInterface.cc | 30 +++--- .../garnet/flexible-pipeline/NetworkLink.cc | 4 +- .../garnet/flexible-pipeline/Router.cc | 55 ++++++----- .../network/garnet/flexible-pipeline/flit.cc | 4 +- .../garnet/flexible-pipeline/flitBuffer.cc | 4 +- src/mem/ruby/network/orion/NetworkPower.cc | 4 +- src/mem/ruby/network/simple/PerfectSwitch.cc | 2 +- src/mem/ruby/network/simple/Throttle.cc | 8 +- src/mem/ruby/profiler/Profiler.cc | 26 ++--- src/mem/ruby/profiler/Profiler.hh | 19 +++- src/mem/ruby/profiler/StoreTrace.cc | 6 +- src/mem/ruby/profiler/StoreTrace.hh | 1 - src/mem/ruby/slicc_interface/Message.hh | 6 +- .../ruby/slicc_interface/RubySlicc_Util.hh | 2 +- src/mem/ruby/system/CacheMemory.cc | 13 +-- src/mem/ruby/system/CacheMemory.hh | 2 - src/mem/ruby/system/RubyMemoryControl.cc | 12 +-- src/mem/ruby/system/RubyPort.cc | 4 +- src/mem/ruby/system/Sequencer.cc | 22 ++--- src/mem/ruby/system/Sequencer.hh | 8 +- src/mem/ruby/system/System.cc | 7 +- src/mem/ruby/system/System.hh | 14 +-- src/mem/ruby/system/TimerTable.cc | 8 +- src/mem/ruby/system/TimerTable.hh | 5 +- src/mem/ruby/system/WireBuffer.cc | 11 +-- src/mem/ruby/system/WireBuffer.hh | 1 - src/mem/slicc/ast/AST.py | 2 +- src/mem/slicc/ast/FuncCallExprAST.py | 4 +- src/mem/slicc/symbols/StateMachine.py | 12 +-- src/mem/slicc/symbols/Type.py | 2 +- 64 files changed, 273 insertions(+), 540 deletions(-) rename src/mem/ruby/{eventqueue/RubyEventQueue.cc => common/Consumer.cc} (63%) delete mode 100644 src/mem/ruby/eventqueue/RubyEventQueue.hh delete mode 100644 src/mem/ruby/eventqueue/RubyEventQueueNode.cc delete mode 100644 src/mem/ruby/eventqueue/RubyEventQueueNode.hh delete mode 100644 src/mem/ruby/eventqueue/SConscript diff --git a/src/cpu/testers/directedtest/RubyDirectedTester.cc b/src/cpu/testers/directedtest/RubyDirectedTester.cc index 0aba82dd2..139798a72 100644 --- a/src/cpu/testers/directedtest/RubyDirectedTester.cc +++ b/src/cpu/testers/directedtest/RubyDirectedTester.cc @@ -42,7 +42,6 @@ #include "cpu/testers/directedtest/DirectedGenerator.hh" #include "cpu/testers/directedtest/RubyDirectedTester.hh" #include "debug/DirectedTest.hh" -#include "mem/ruby/eventqueue/RubyEventQueue.hh" #include "sim/sim_exit.hh" RubyDirectedTester::RubyDirectedTester(const Params *p) diff --git a/src/cpu/testers/rubytest/Check.cc b/src/cpu/testers/rubytest/Check.cc index 98250f042..213b8e8d2 100644 --- a/src/cpu/testers/rubytest/Check.cc +++ b/src/cpu/testers/rubytest/Check.cc @@ -313,7 +313,7 @@ Check::performCallback(NodeID proc, SubBlock* data) proc, address, data, byte_number, (int)m_value + byte_number, (int)data->getByte(byte_number), *this, - g_eventQueue_ptr->getTime()); + g_system_ptr->getTime()); } } DPRINTF(RubyTest, "Action/check success\n"); @@ -328,7 +328,7 @@ Check::performCallback(NodeID proc, SubBlock* data) } else { panic("Unexpected TesterStatus: %s proc: %d data: %s m_status: %s " "time: %d\n", - *this, proc, data, m_status, g_eventQueue_ptr->getTime()); + *this, proc, data, m_status, g_system_ptr->getTime()); } DPRINTF(RubyTest, "proc: %d, Address: 0x%x\n", proc, diff --git a/src/cpu/testers/rubytest/RubyTester.cc b/src/cpu/testers/rubytest/RubyTester.cc index 3397b00d0..bdd6dacce 100644 --- a/src/cpu/testers/rubytest/RubyTester.cc +++ b/src/cpu/testers/rubytest/RubyTester.cc @@ -45,7 +45,6 @@ #include "debug/RubyTest.hh" #include "mem/ruby/common/Global.hh" #include "mem/ruby/common/SubBlock.hh" -#include "mem/ruby/eventqueue/RubyEventQueue.hh" #include "mem/ruby/system/System.hh" #include "sim/sim_exit.hh" #include "sim/system.hh" @@ -192,7 +191,7 @@ void RubyTester::hitCallback(NodeID proc, SubBlock* data) { // Mark that we made progress - m_last_progress_vector[proc] = g_eventQueue_ptr->getTime(); + m_last_progress_vector[proc] = g_system_ptr->getTime(); DPRINTF(RubyTest, "completed request for proc: %d\n", proc); DPRINTF(RubyTest, "addr: 0x%x, size: %d, data: ", @@ -230,7 +229,7 @@ void RubyTester::checkForDeadlock() { int size = m_last_progress_vector.size(); - Time current_time = g_eventQueue_ptr->getTime(); + Time current_time = g_system_ptr->getTime(); for (int processor = 0; processor < size; processor++) { if ((current_time - m_last_progress_vector[processor]) > m_deadlock_threshold) { diff --git a/src/mem/ruby/buffers/MessageBuffer.cc b/src/mem/ruby/buffers/MessageBuffer.cc index 9a7fdb61b..ee1c709f1 100644 --- a/src/mem/ruby/buffers/MessageBuffer.cc +++ b/src/mem/ruby/buffers/MessageBuffer.cc @@ -66,10 +66,10 @@ MessageBuffer::MessageBuffer(const string &name) int MessageBuffer::getSize() { - if (m_time_last_time_size_checked == g_eventQueue_ptr->getTime()) { + if (m_time_last_time_size_checked == g_system_ptr->getTime()) { return m_size_last_time_size_checked; } else { - m_time_last_time_size_checked = g_eventQueue_ptr->getTime(); + m_time_last_time_size_checked = g_system_ptr->getTime(); m_size_last_time_size_checked = m_size; return m_size; } @@ -89,11 +89,11 @@ MessageBuffer::areNSlotsAvailable(int n) // until next cycle, but enqueue operations effect the visible // size immediately int current_size = max(m_size_at_cycle_start, m_size); - if (m_time_last_time_pop < g_eventQueue_ptr->getTime()) { + if (m_time_last_time_pop < g_system_ptr->getTime()) { // no pops this cycle - m_size is correct current_size = m_size; } else { - if (m_time_last_time_enqueue < g_eventQueue_ptr->getTime()) { + if (m_time_last_time_enqueue < g_system_ptr->getTime()) { // no enqueues this cycle - m_size_at_cycle_start is correct current_size = m_size_at_cycle_start; } else { @@ -155,9 +155,9 @@ MessageBuffer::enqueue(MsgPtr message, Time delta) m_size++; // record current time incase we have a pop that also adjusts my size - if (m_time_last_time_enqueue < g_eventQueue_ptr->getTime()) { + if (m_time_last_time_enqueue < g_system_ptr->getTime()) { m_msgs_this_cycle = 0; // first msg this cycle - m_time_last_time_enqueue = g_eventQueue_ptr->getTime(); + m_time_last_time_enqueue = g_system_ptr->getTime(); } m_msgs_this_cycle++; @@ -168,7 +168,7 @@ MessageBuffer::enqueue(MsgPtr message, Time delta) // Calculate the arrival time of the message, that is, the first // cycle the message can be dequeued. assert(delta>0); - Time current_time = g_eventQueue_ptr->getTime(); + Time current_time = g_system_ptr->getTime(); Time arrival_time = 0; if (!RubySystem::getRandomization() || (m_randomization == false)) { // No randomization @@ -192,10 +192,10 @@ MessageBuffer::enqueue(MsgPtr message, Time delta) panic("FIFO ordering violated: %s name: %s current time: %d " "delta: %d arrival_time: %d last arrival_time: %d\n", *this, m_name, - current_time * g_eventQueue_ptr->getClock(), - delta * g_eventQueue_ptr->getClock(), - arrival_time * g_eventQueue_ptr->getClock(), - m_last_arrival_time * g_eventQueue_ptr->getClock()); + current_time * g_system_ptr->getClock(), + delta * g_system_ptr->getClock(), + arrival_time * g_system_ptr->getClock(), + m_last_arrival_time * g_system_ptr->getClock()); } } @@ -208,10 +208,10 @@ MessageBuffer::enqueue(MsgPtr message, Time delta) Message* msg_ptr = message.get(); assert(msg_ptr != NULL); - assert(g_eventQueue_ptr->getTime() >= msg_ptr->getLastEnqueueTime() && + assert(g_system_ptr->getTime() >= msg_ptr->getLastEnqueueTime() && "ensure we aren't dequeued early"); - msg_ptr->setDelayedCycles(g_eventQueue_ptr->getTime() - + msg_ptr->setDelayedCycles(g_system_ptr->getTime() - msg_ptr->getLastEnqueueTime() + msg_ptr->getDelayedCycles()); msg_ptr->setLastEnqueueTime(arrival_time); @@ -223,12 +223,12 @@ MessageBuffer::enqueue(MsgPtr message, Time delta) greater()); DPRINTF(RubyQueue, "Enqueue with arrival_time %lld.\n", - arrival_time * g_eventQueue_ptr->getClock()); + arrival_time * g_system_ptr->getClock()); DPRINTF(RubyQueue, "Enqueue Message: %s.\n", (*(message.get()))); // Schedule the wakeup if (m_consumer_ptr != NULL) { - g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr, arrival_time); + m_consumer_ptr->scheduleEventAbsolute(arrival_time); m_consumer_ptr->storeEventInfo(m_vnet_id); } else { panic("No consumer: %s name: %s\n", *this, m_name); @@ -287,9 +287,9 @@ MessageBuffer::pop() // record previous size and time so the current buffer size isn't // adjusted until next cycle - if (m_time_last_time_pop < g_eventQueue_ptr->getTime()) { + if (m_time_last_time_pop < g_system_ptr->getTime()) { m_size_at_cycle_start = m_size; - m_time_last_time_pop = g_eventQueue_ptr->getTime(); + m_time_last_time_pop = g_system_ptr->getTime(); } m_size--; } @@ -315,12 +315,12 @@ MessageBuffer::recycle() MessageBufferNode node = m_prio_heap.front(); pop_heap(m_prio_heap.begin(), m_prio_heap.end(), greater()); - node.m_time = g_eventQueue_ptr->getTime() + m_recycle_latency; + node.m_time = g_system_ptr->getTime() + m_recycle_latency; m_prio_heap.back() = node; push_heap(m_prio_heap.begin(), m_prio_heap.end(), greater()); - g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr, - g_eventQueue_ptr->getTime() + m_recycle_latency); + m_consumer_ptr->scheduleEventAbsolute(g_system_ptr->getTime() + + m_recycle_latency); } void @@ -335,7 +335,7 @@ MessageBuffer::reanalyzeMessages(const Address& addr) // while(!m_stall_msg_map[addr].empty()) { m_msg_counter++; - MessageBufferNode msgNode(g_eventQueue_ptr->getTime() + 1, + MessageBufferNode msgNode(g_system_ptr->getTime() + 1, m_msg_counter, m_stall_msg_map[addr].front()); @@ -343,7 +343,7 @@ MessageBuffer::reanalyzeMessages(const Address& addr) push_heap(m_prio_heap.begin(), m_prio_heap.end(), greater()); - g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr, msgNode.m_time); + m_consumer_ptr->scheduleEventAbsolute(msgNode.m_time); m_stall_msg_map[addr].pop_front(); } m_stall_msg_map.erase(addr); @@ -364,7 +364,7 @@ MessageBuffer::reanalyzeAllMessages() while(!(map_iter->second).empty()) { m_msg_counter++; - MessageBufferNode msgNode(g_eventQueue_ptr->getTime() + 1, + MessageBufferNode msgNode(g_system_ptr->getTime() + 1, m_msg_counter, (map_iter->second).front()); @@ -372,8 +372,7 @@ MessageBuffer::reanalyzeAllMessages() push_heap(m_prio_heap.begin(), m_prio_heap.end(), greater()); - g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr, - msgNode.m_time); + m_consumer_ptr->scheduleEventAbsolute(msgNode.m_time); (map_iter->second).pop_front(); } } @@ -407,8 +406,8 @@ MessageBuffer::setAndReturnDelayCycles(MsgPtr msg_ptr) // this function should only be called on dequeue // ensure the msg hasn't been enqueued - assert(msg_ptr->getLastEnqueueTime() <= g_eventQueue_ptr->getTime()); - msg_ptr->setDelayedCycles(g_eventQueue_ptr->getTime() - + assert(msg_ptr->getLastEnqueueTime() <= g_system_ptr->getTime()); + msg_ptr->setDelayedCycles(g_system_ptr->getTime() - msg_ptr->getLastEnqueueTime() + msg_ptr->getDelayedCycles()); delay_cycles = msg_ptr->getDelayedCycles(); diff --git a/src/mem/ruby/buffers/MessageBuffer.hh b/src/mem/ruby/buffers/MessageBuffer.hh index 4193c9f73..cf7e77c2d 100644 --- a/src/mem/ruby/buffers/MessageBuffer.hh +++ b/src/mem/ruby/buffers/MessageBuffer.hh @@ -45,7 +45,6 @@ #include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Global.hh" -#include "mem/ruby/eventqueue/RubyEventQueue.hh" #include "mem/ruby/slicc_interface/Message.hh" class MessageBuffer @@ -70,7 +69,7 @@ class MessageBuffer isReady() const { return ((m_prio_heap.size() > 0) && - (m_prio_heap.front().m_time <= g_eventQueue_ptr->getTime())); + (m_prio_heap.front().m_time <= g_system_ptr->getTime())); } void diff --git a/src/mem/ruby/eventqueue/RubyEventQueue.cc b/src/mem/ruby/common/Consumer.cc similarity index 63% rename from src/mem/ruby/eventqueue/RubyEventQueue.cc rename to src/mem/ruby/common/Consumer.cc index 4ea530b05..a81396217 100644 --- a/src/mem/ruby/eventqueue/RubyEventQueue.cc +++ b/src/mem/ruby/common/Consumer.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * Copyright (c) 2012 Mark D. Hill and David A. Wood * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,43 +26,38 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include - #include "mem/ruby/common/Consumer.hh" -#include "mem/ruby/eventqueue/RubyEventQueue.hh" -#include "mem/ruby/eventqueue/RubyEventQueueNode.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/ruby/system/System.hh" -RubyEventQueue::RubyEventQueue(EventQueue* eventq, Tick _clock) - : EventManager(eventq), m_clock(_clock) +void +Consumer::scheduleEvent(Time timeDelta) { + scheduleEvent(g_system_ptr, timeDelta); } -RubyEventQueue::~RubyEventQueue() +void +Consumer::scheduleEvent(EventManager *em, Time timeDelta) { + scheduleEventAbsolute(em, timeDelta + g_system_ptr->getTime()); } void -RubyEventQueue::scheduleEvent(Consumer* consumer, Time timeDelta) +Consumer::scheduleEventAbsolute(Time timeAbs) { - scheduleEventAbsolute(consumer, timeDelta + getTime()); + scheduleEventAbsolute(g_system_ptr, timeAbs); } void -RubyEventQueue::scheduleEventAbsolute(Consumer* consumer, Time timeAbs) +Consumer::scheduleEventAbsolute(EventManager *em, Time timeAbs) { - // Check to see if this is a redundant wakeup - assert(consumer != NULL); - if (!consumer->alreadyScheduled(timeAbs)) { + Tick evt_time = timeAbs * g_system_ptr->getClock(); + if (!alreadyScheduled(evt_time)) { // This wakeup is not redundant - RubyEventQueueNode *thisNode = new RubyEventQueueNode(consumer, this); - assert(timeAbs > getTime()); - schedule(thisNode, (timeAbs * m_clock)); - consumer->insertScheduledWakeupTime(timeAbs); - } -} + ConsumerEvent *evt = new ConsumerEvent(this); + assert(timeAbs > g_system_ptr->getTime()); -void -RubyEventQueue::print(std::ostream& out) const -{ - out << "[Event Queue:]"; + em->schedule(evt, evt_time); + insertScheduledWakeupTime(evt_time); + } } diff --git a/src/mem/ruby/common/Consumer.hh b/src/mem/ruby/common/Consumer.hh index a119abb39..6a67bde39 100644 --- a/src/mem/ruby/common/Consumer.hh +++ b/src/mem/ruby/common/Consumer.hh @@ -38,10 +38,8 @@ #include #include -#include "mem/ruby/common/Global.hh" -#include "mem/ruby/eventqueue/RubyEventQueue.hh" - -class MessageBuffer; +#include "mem/ruby/common/TypeDefines.hh" +#include "sim/eventq.hh" class Consumer { @@ -55,55 +53,68 @@ class Consumer ~Consumer() { } - void - triggerWakeup(RubyEventQueue *eventQueue) - { - Time time = eventQueue->getTime(); - if (m_last_wakeup != time) { - wakeup(); - m_last_wakeup = time; - } - } - virtual void wakeup() = 0; virtual void print(std::ostream& out) const = 0; virtual void storeEventInfo(int info) {} - const Time& + const Tick& getLastScheduledWakeup() const { return m_last_scheduled_wakeup; } void - setLastScheduledWakeup(const Time& time) + setLastScheduledWakeup(const Tick& time) { m_last_scheduled_wakeup = time; } bool - alreadyScheduled(Time time) + alreadyScheduled(Tick time) { return m_scheduled_wakeups.find(time) != m_scheduled_wakeups.end(); } void - insertScheduledWakeupTime(Time time) + insertScheduledWakeupTime(Tick time) { m_scheduled_wakeups.insert(time); } void - removeScheduledWakeupTime(Time time) + removeScheduledWakeupTime(Tick time) { assert(alreadyScheduled(time)); m_scheduled_wakeups.erase(time); } + void scheduleEvent(EventManager* em, Time timeDelta); + void scheduleEventAbsolute(EventManager* em, Time timeAbs); + void scheduleEvent(Time timeDelta); + void scheduleEventAbsolute(Time timeAbs); + private: - Time m_last_scheduled_wakeup; - std::set