From: Nilay Vaish Date: Mon, 27 Aug 2012 06:00:55 +0000 (-0500) Subject: Ruby: Remove RubyEventQueue X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9190940511b5783811bc6288dd4f22f8d18c9d26;p=gem5.git Ruby: Remove RubyEventQueue This patch removes RubyEventQueue. Consumer objects now rely on RubySystem or themselves for scheduling events. --- 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/common/Consumer.cc b/src/mem/ruby/common/Consumer.cc new file mode 100644 index 000000000..a81396217 --- /dev/null +++ b/src/mem/ruby/common/Consumer.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2012 Mark D. Hill and David A. Wood + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "mem/ruby/common/Consumer.hh" +#include "mem/ruby/common/Global.hh" +#include "mem/ruby/system/System.hh" + +void +Consumer::scheduleEvent(Time timeDelta) +{ + scheduleEvent(g_system_ptr, timeDelta); +} + +void +Consumer::scheduleEvent(EventManager *em, Time timeDelta) +{ + scheduleEventAbsolute(em, timeDelta + g_system_ptr->getTime()); +} + +void +Consumer::scheduleEventAbsolute(Time timeAbs) +{ + scheduleEventAbsolute(g_system_ptr, timeAbs); +} + +void +Consumer::scheduleEventAbsolute(EventManager *em, Time timeAbs) +{ + Tick evt_time = timeAbs * g_system_ptr->getClock(); + if (!alreadyScheduled(evt_time)) { + // This wakeup is not redundant + ConsumerEvent *evt = new ConsumerEvent(this); + assert(timeAbs > g_system_ptr->getTime()); + + 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