2009-05-11 19:38:43 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1999-2008 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.
|
|
|
|
*/
|
|
|
|
|
2011-01-10 20:11:20 +01:00
|
|
|
#include <cassert>
|
|
|
|
|
2010-04-02 20:20:32 +02:00
|
|
|
#include "base/cprintf.hh"
|
2010-12-23 06:15:24 +01:00
|
|
|
#include "base/misc.hh"
|
2014-09-03 13:42:54 +02:00
|
|
|
#include "base/random.hh"
|
2010-06-11 08:17:07 +02:00
|
|
|
#include "base/stl_helpers.hh"
|
2011-04-15 19:44:32 +02:00
|
|
|
#include "debug/RubyQueue.hh"
|
2014-09-01 23:55:40 +02:00
|
|
|
#include "mem/ruby/network/MessageBuffer.hh"
|
2015-09-16 18:03:03 +02:00
|
|
|
#include "mem/ruby/system/RubySystem.hh"
|
2009-05-11 19:38:43 +02:00
|
|
|
|
2010-04-02 20:20:32 +02:00
|
|
|
using namespace std;
|
2010-06-11 08:17:07 +02:00
|
|
|
using m5::stl_helpers::operator<<;
|
2010-04-02 20:20:32 +02:00
|
|
|
|
ruby: Expose MessageBuffers as SimObjects
Expose MessageBuffers from SLICC controllers as SimObjects that can be
manipulated in Python. This patch has numerous benefits:
1) First and foremost, it exposes MessageBuffers as SimObjects that can be
manipulated in Python code. This allows parameters to be set and checked in
Python code to avoid obfuscating parameters within protocol files. Further, now
as SimObjects, MessageBuffer parameters are printed to config output files as a
way to track parameters across simulations (e.g. buffer sizes)
2) Cleans up special-case code for responseFromMemory buffers, and aligns their
instantiation and use with mandatoryQueue buffers. These two special buffers
are the only MessageBuffers that are exposed to components outside of SLICC
controllers, and they're both slave ends of these buffers. They should be
exposed outside of SLICC in the same way, and this patch does it.
3) Distinguishes buffer-specific parameters from buffer-to-network parameters.
Specifically, buffer size, randomization, ordering, recycle latency, and ports
are all specific to a MessageBuffer, while the virtual network ID and type are
intrinsics of how the buffer is connected to network ports. The former are
specified in the Python object, while the latter are specified in the
controller *.sm files. Unlike buffer-specific parameters, which may need to
change depending on the simulated system structure, buffer-to-network
parameters can be specified statically for most or all different simulated
systems.
2015-08-14 07:19:44 +02:00
|
|
|
MessageBuffer::MessageBuffer(const Params *p)
|
2016-12-20 18:38:24 +01:00
|
|
|
: SimObject(p), m_stall_map_size(0),
|
ruby: Expose MessageBuffers as SimObjects
Expose MessageBuffers from SLICC controllers as SimObjects that can be
manipulated in Python. This patch has numerous benefits:
1) First and foremost, it exposes MessageBuffers as SimObjects that can be
manipulated in Python code. This allows parameters to be set and checked in
Python code to avoid obfuscating parameters within protocol files. Further, now
as SimObjects, MessageBuffer parameters are printed to config output files as a
way to track parameters across simulations (e.g. buffer sizes)
2) Cleans up special-case code for responseFromMemory buffers, and aligns their
instantiation and use with mandatoryQueue buffers. These two special buffers
are the only MessageBuffers that are exposed to components outside of SLICC
controllers, and they're both slave ends of these buffers. They should be
exposed outside of SLICC in the same way, and this patch does it.
3) Distinguishes buffer-specific parameters from buffer-to-network parameters.
Specifically, buffer size, randomization, ordering, recycle latency, and ports
are all specific to a MessageBuffer, while the virtual network ID and type are
intrinsics of how the buffer is connected to network ports. The former are
specified in the Python object, while the latter are specified in the
controller *.sm files. Unlike buffer-specific parameters, which may need to
change depending on the simulated system structure, buffer-to-network
parameters can be specified statically for most or all different simulated
systems.
2015-08-14 07:19:44 +02:00
|
|
|
m_max_size(p->buffer_size), m_time_last_time_size_checked(0),
|
|
|
|
m_time_last_time_enqueue(0), m_time_last_time_pop(0),
|
|
|
|
m_last_arrival_time(0), m_strict_fifo(p->ordered),
|
|
|
|
m_randomization(p->randomization)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2010-03-23 02:43:53 +01:00
|
|
|
m_msg_counter = 0;
|
2013-03-22 21:53:27 +01:00
|
|
|
m_consumer = NULL;
|
2010-03-23 02:43:53 +01:00
|
|
|
m_size_last_time_size_checked = 0;
|
|
|
|
m_size_at_cycle_start = 0;
|
|
|
|
m_msgs_this_cycle = 0;
|
|
|
|
m_priority_rank = 0;
|
2011-02-07 07:14:19 +01:00
|
|
|
|
|
|
|
m_stall_msg_map.clear();
|
2011-02-14 23:14:54 +01:00
|
|
|
m_input_link_id = 0;
|
|
|
|
m_vnet_id = 0;
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2014-03-02 06:59:57 +01:00
|
|
|
unsigned int
|
2015-09-16 18:59:56 +02:00
|
|
|
MessageBuffer::getSize(Tick curTime)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2015-09-16 18:59:56 +02:00
|
|
|
if (m_time_last_time_size_checked != curTime) {
|
|
|
|
m_time_last_time_size_checked = curTime;
|
2013-06-24 13:57:06 +02:00
|
|
|
m_size_last_time_size_checked = m_prio_heap.size();
|
2010-03-23 02:43:53 +01:00
|
|
|
}
|
2013-06-24 13:57:06 +02:00
|
|
|
|
|
|
|
return m_size_last_time_size_checked;
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
bool
|
2015-09-16 18:59:56 +02:00
|
|
|
MessageBuffer::areNSlotsAvailable(unsigned int n, Tick current_time)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
// fast path when message buffers have infinite size
|
2014-03-02 06:59:57 +01:00
|
|
|
if (m_max_size == 0) {
|
2010-03-23 02:43:53 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-24 13:57:06 +02:00
|
|
|
// determine the correct size for the current cycle
|
2010-03-23 02:43:53 +01:00
|
|
|
// pop operations shouldn't effect the network's visible size
|
2015-07-20 16:15:18 +02:00
|
|
|
// until schd cycle, but enqueue operations effect the visible
|
2010-03-23 02:43:53 +01:00
|
|
|
// size immediately
|
2013-06-24 13:57:06 +02:00
|
|
|
unsigned int current_size = 0;
|
|
|
|
|
2015-09-16 18:59:56 +02:00
|
|
|
if (m_time_last_time_pop < current_time) {
|
2013-06-24 13:57:06 +02:00
|
|
|
// no pops this cycle - heap size is correct
|
|
|
|
current_size = m_prio_heap.size();
|
2010-03-23 02:43:53 +01:00
|
|
|
} else {
|
2015-09-16 18:59:56 +02:00
|
|
|
if (m_time_last_time_enqueue < current_time) {
|
2010-03-23 02:43:53 +01:00
|
|
|
// no enqueues this cycle - m_size_at_cycle_start is correct
|
|
|
|
current_size = m_size_at_cycle_start;
|
|
|
|
} else {
|
|
|
|
// both pops and enqueues occured this cycle - add new
|
|
|
|
// enqueued msgs to m_size_at_cycle_start
|
2013-06-24 13:57:06 +02:00
|
|
|
current_size = m_size_at_cycle_start + m_msgs_this_cycle;
|
2010-03-23 02:43:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// now compare the new size with our max size
|
2016-12-20 18:38:24 +01:00
|
|
|
if (current_size + m_stall_map_size + n <= m_max_size) {
|
2010-03-23 02:43:53 +01:00
|
|
|
return true;
|
|
|
|
} else {
|
2013-06-24 13:57:06 +02:00
|
|
|
DPRINTF(RubyQueue, "n: %d, current_size: %d, heap size: %d, "
|
2010-12-01 20:30:04 +01:00
|
|
|
"m_max_size: %d\n",
|
2013-06-24 13:57:06 +02:00
|
|
|
n, current_size, m_prio_heap.size(), m_max_size);
|
2010-03-23 02:43:53 +01:00
|
|
|
m_not_avail_count++;
|
|
|
|
return false;
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
const Message*
|
2014-02-21 00:26:41 +01:00
|
|
|
MessageBuffer::peek() const
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2011-05-02 06:16:14 +02:00
|
|
|
DPRINTF(RubyQueue, "Peeking at head of queue.\n");
|
2015-07-04 17:43:46 +02:00
|
|
|
const Message* msg_ptr = m_prio_heap.front().get();
|
2010-06-11 08:17:06 +02:00
|
|
|
assert(msg_ptr);
|
2009-05-11 19:38:43 +02:00
|
|
|
|
2010-12-01 20:30:04 +01:00
|
|
|
DPRINTF(RubyQueue, "Message: %s\n", (*msg_ptr));
|
2010-03-23 02:43:53 +01:00
|
|
|
return msg_ptr;
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME - move me somewhere else
|
2015-09-16 18:59:56 +02:00
|
|
|
Tick
|
2010-03-23 02:43:53 +01:00
|
|
|
random_time()
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2015-09-16 18:59:56 +02:00
|
|
|
Tick time = 1;
|
|
|
|
time += random_mt.random(0, 3); // [0...3]
|
2014-09-03 13:42:54 +02:00
|
|
|
if (random_mt.random(0, 7) == 0) { // 1 in 8 chance
|
2015-09-16 18:59:56 +02:00
|
|
|
time += 100 + random_mt.random(1, 15); // 100 + [1...15]
|
2010-03-23 02:43:53 +01:00
|
|
|
}
|
|
|
|
return time;
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
void
|
2015-09-16 18:59:56 +02:00
|
|
|
MessageBuffer::enqueue(MsgPtr message, Tick current_time, Tick delta)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2010-03-23 02:43:53 +01:00
|
|
|
// record current time incase we have a pop that also adjusts my size
|
2015-09-16 18:59:56 +02:00
|
|
|
if (m_time_last_time_enqueue < current_time) {
|
2010-03-23 02:43:53 +01:00
|
|
|
m_msgs_this_cycle = 0; // first msg this cycle
|
2015-09-16 18:59:56 +02:00
|
|
|
m_time_last_time_enqueue = current_time;
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
2010-03-23 02:43:53 +01:00
|
|
|
|
2014-11-06 12:42:21 +01:00
|
|
|
m_msg_counter++;
|
|
|
|
m_msgs_this_cycle++;
|
2009-05-11 19:38:43 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
// Calculate the arrival time of the message, that is, the first
|
|
|
|
// cycle the message can be dequeued.
|
2013-03-22 23:21:22 +01:00
|
|
|
assert(delta > 0);
|
|
|
|
Tick arrival_time = 0;
|
2013-02-11 04:26:24 +01:00
|
|
|
|
2014-06-01 03:00:23 +02:00
|
|
|
if (!RubySystem::getRandomization() || !m_randomization) {
|
2010-03-23 02:43:53 +01:00
|
|
|
// No randomization
|
2015-09-16 18:59:56 +02:00
|
|
|
arrival_time = current_time + delta;
|
2010-03-23 02:43:53 +01:00
|
|
|
} else {
|
|
|
|
// Randomization - ignore delta
|
|
|
|
if (m_strict_fifo) {
|
|
|
|
if (m_last_arrival_time < current_time) {
|
|
|
|
m_last_arrival_time = current_time;
|
|
|
|
}
|
2015-09-16 18:59:56 +02:00
|
|
|
arrival_time = m_last_arrival_time + random_time();
|
2010-03-23 02:43:53 +01:00
|
|
|
} else {
|
2015-09-16 18:59:56 +02:00
|
|
|
arrival_time = current_time + random_time();
|
2010-03-23 02:43:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the arrival time
|
|
|
|
assert(arrival_time > current_time);
|
|
|
|
if (m_strict_fifo) {
|
|
|
|
if (arrival_time < m_last_arrival_time) {
|
2010-12-23 06:15:24 +01:00
|
|
|
panic("FIFO ordering violated: %s name: %s current time: %d "
|
|
|
|
"delta: %d arrival_time: %d last arrival_time: %d\n",
|
2015-09-16 18:59:56 +02:00
|
|
|
*this, name(), current_time, delta, arrival_time,
|
|
|
|
m_last_arrival_time);
|
2010-03-23 02:43:53 +01:00
|
|
|
}
|
|
|
|
}
|
2012-01-11 20:48:48 +01:00
|
|
|
|
|
|
|
// If running a cache trace, don't worry about the last arrival checks
|
2015-05-19 17:56:51 +02:00
|
|
|
if (!RubySystem::getWarmupEnabled()) {
|
2012-01-11 20:48:48 +01:00
|
|
|
m_last_arrival_time = arrival_time;
|
|
|
|
}
|
2010-03-23 02:43:53 +01:00
|
|
|
|
|
|
|
// compute the delay cycles and set enqueue time
|
2010-06-11 08:17:06 +02:00
|
|
|
Message* msg_ptr = message.get();
|
2010-03-23 02:43:53 +01:00
|
|
|
assert(msg_ptr != NULL);
|
|
|
|
|
2015-09-16 18:59:56 +02:00
|
|
|
assert(current_time >= msg_ptr->getLastEnqueueTime() &&
|
2010-03-23 02:43:53 +01:00
|
|
|
"ensure we aren't dequeued early");
|
|
|
|
|
2015-09-16 18:59:56 +02:00
|
|
|
msg_ptr->updateDelayedTicks(current_time);
|
2013-03-22 23:21:22 +01:00
|
|
|
msg_ptr->setLastEnqueueTime(arrival_time);
|
2015-07-04 17:43:46 +02:00
|
|
|
msg_ptr->setMsgCounter(m_msg_counter);
|
2010-03-23 02:43:53 +01:00
|
|
|
|
|
|
|
// Insert the message into the priority heap
|
2015-07-04 17:43:46 +02:00
|
|
|
m_prio_heap.push_back(message);
|
|
|
|
push_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
|
2010-03-23 02:43:53 +01:00
|
|
|
|
2013-01-14 17:04:21 +01:00
|
|
|
DPRINTF(RubyQueue, "Enqueue arrival_time: %lld, Message: %s\n",
|
2013-03-22 23:21:22 +01:00
|
|
|
arrival_time, *(message.get()));
|
2010-03-23 02:43:53 +01:00
|
|
|
|
|
|
|
// Schedule the wakeup
|
2014-02-21 00:26:41 +01:00
|
|
|
assert(m_consumer != NULL);
|
|
|
|
m_consumer->scheduleEventAbsolute(arrival_time);
|
|
|
|
m_consumer->storeEventInfo(m_vnet_id);
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2015-09-16 18:59:56 +02:00
|
|
|
Tick
|
|
|
|
MessageBuffer::dequeue(Tick current_time)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2014-05-23 13:07:02 +02:00
|
|
|
DPRINTF(RubyQueue, "Popping\n");
|
2015-09-16 18:59:56 +02:00
|
|
|
assert(isReady(current_time));
|
2014-05-23 13:07:02 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
// get MsgPtr of the message about to be dequeued
|
2015-07-04 17:43:46 +02:00
|
|
|
MsgPtr message = m_prio_heap.front();
|
2009-05-11 19:38:43 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
// get the delay cycles
|
2015-09-16 18:59:56 +02:00
|
|
|
message->updateDelayedTicks(current_time);
|
|
|
|
Tick delay = message->getDelayedTicks();
|
2010-06-11 08:17:07 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
// record previous size and time so the current buffer size isn't
|
2015-07-20 16:15:18 +02:00
|
|
|
// adjusted until schd cycle
|
2015-09-16 18:59:56 +02:00
|
|
|
if (m_time_last_time_pop < current_time) {
|
2013-06-24 13:57:06 +02:00
|
|
|
m_size_at_cycle_start = m_prio_heap.size();
|
2015-09-16 18:59:56 +02:00
|
|
|
m_time_last_time_pop = current_time;
|
2010-03-23 02:43:53 +01:00
|
|
|
}
|
2013-06-24 13:57:06 +02:00
|
|
|
|
2015-09-16 18:59:56 +02:00
|
|
|
pop_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
|
2013-06-24 13:57:06 +02:00
|
|
|
m_prio_heap.pop_back();
|
2014-05-23 13:07:02 +02:00
|
|
|
|
2015-09-16 18:59:56 +02:00
|
|
|
return delay;
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
void
|
|
|
|
MessageBuffer::clear()
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2010-06-11 08:17:07 +02:00
|
|
|
m_prio_heap.clear();
|
2009-05-11 19:38:43 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
m_msg_counter = 0;
|
2015-09-16 18:59:56 +02:00
|
|
|
m_time_last_time_enqueue = 0;
|
2014-03-02 06:59:58 +01:00
|
|
|
m_time_last_time_pop = 0;
|
2010-03-23 02:43:53 +01:00
|
|
|
m_size_at_cycle_start = 0;
|
|
|
|
m_msgs_this_cycle = 0;
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
void
|
2015-09-16 18:59:56 +02:00
|
|
|
MessageBuffer::recycle(Tick current_time, Tick recycle_latency)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2011-02-23 06:58:40 +01:00
|
|
|
DPRINTF(RubyQueue, "Recycling.\n");
|
2015-09-16 18:59:56 +02:00
|
|
|
assert(isReady(current_time));
|
2015-07-04 17:43:46 +02:00
|
|
|
MsgPtr node = m_prio_heap.front();
|
|
|
|
pop_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
|
2013-02-11 04:26:24 +01:00
|
|
|
|
2015-09-16 18:59:56 +02:00
|
|
|
Tick future_time = current_time + recycle_latency;
|
|
|
|
node->setLastEnqueueTime(future_time);
|
|
|
|
|
2010-06-11 08:17:07 +02:00
|
|
|
m_prio_heap.back() = node;
|
2015-07-04 17:43:46 +02:00
|
|
|
push_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
|
2015-09-16 18:59:56 +02:00
|
|
|
m_consumer->scheduleEventAbsolute(future_time);
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2014-02-24 02:16:15 +01:00
|
|
|
void
|
2015-07-20 16:15:18 +02:00
|
|
|
MessageBuffer::reanalyzeList(list<MsgPtr> <, Tick schdTick)
|
2014-02-24 02:16:15 +01:00
|
|
|
{
|
2016-02-07 02:21:19 +01:00
|
|
|
while (!lt.empty()) {
|
2014-02-24 02:16:15 +01:00
|
|
|
m_msg_counter++;
|
2015-07-04 17:43:46 +02:00
|
|
|
MsgPtr m = lt.front();
|
2015-07-20 16:15:18 +02:00
|
|
|
m->setLastEnqueueTime(schdTick);
|
2015-07-04 17:43:46 +02:00
|
|
|
m->setMsgCounter(m_msg_counter);
|
2014-02-24 02:16:15 +01:00
|
|
|
|
2015-07-04 17:43:46 +02:00
|
|
|
m_prio_heap.push_back(m);
|
2014-02-24 02:16:15 +01:00
|
|
|
push_heap(m_prio_heap.begin(), m_prio_heap.end(),
|
2015-07-04 17:43:46 +02:00
|
|
|
greater<MsgPtr>());
|
2014-02-24 02:16:15 +01:00
|
|
|
|
2015-07-20 16:15:18 +02:00
|
|
|
m_consumer->scheduleEventAbsolute(schdTick);
|
2014-02-24 02:16:15 +01:00
|
|
|
lt.pop_front();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-20 20:46:14 +02:00
|
|
|
void
|
2015-09-16 18:59:56 +02:00
|
|
|
MessageBuffer::reanalyzeMessages(Addr addr, Tick current_time)
|
2010-08-20 20:46:14 +02:00
|
|
|
{
|
2015-09-18 20:27:47 +02:00
|
|
|
DPRINTF(RubyQueue, "ReanalyzeMessages %#x\n", addr);
|
2010-08-20 20:46:14 +02:00
|
|
|
assert(m_stall_msg_map.count(addr) > 0);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Put all stalled messages associated with this address back on the
|
2015-07-20 16:15:18 +02:00
|
|
|
// prio heap. The reanalyzeList call will make sure the consumer is
|
|
|
|
// scheduled for the current cycle so that the previously stalled messages
|
|
|
|
// will be observed before any younger messages that may arrive this cycle
|
2010-08-20 20:46:14 +02:00
|
|
|
//
|
2016-12-20 18:38:24 +01:00
|
|
|
m_stall_map_size -= m_stall_msg_map[addr].size();
|
|
|
|
assert(m_stall_map_size >= 0);
|
2015-09-16 18:59:56 +02:00
|
|
|
reanalyzeList(m_stall_msg_map[addr], current_time);
|
2011-02-07 07:14:19 +01:00
|
|
|
m_stall_msg_map.erase(addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-09-16 18:59:56 +02:00
|
|
|
MessageBuffer::reanalyzeAllMessages(Tick current_time)
|
2011-02-07 07:14:19 +01:00
|
|
|
{
|
2013-06-24 13:57:06 +02:00
|
|
|
DPRINTF(RubyQueue, "ReanalyzeAllMessages\n");
|
2011-02-07 07:14:19 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Put all stalled messages associated with this address back on the
|
2015-07-20 16:15:18 +02:00
|
|
|
// prio heap. The reanalyzeList call will make sure the consumer is
|
|
|
|
// scheduled for the current cycle so that the previously stalled messages
|
|
|
|
// will be observed before any younger messages that may arrive this cycle.
|
2011-02-07 07:14:19 +01:00
|
|
|
//
|
|
|
|
for (StallMsgMapType::iterator map_iter = m_stall_msg_map.begin();
|
2014-02-24 02:16:15 +01:00
|
|
|
map_iter != m_stall_msg_map.end(); ++map_iter) {
|
2016-12-20 18:38:24 +01:00
|
|
|
m_stall_map_size -= map_iter->second.size();
|
|
|
|
assert(m_stall_map_size >= 0);
|
2015-09-16 18:59:56 +02:00
|
|
|
reanalyzeList(map_iter->second, current_time);
|
2011-02-07 07:14:19 +01:00
|
|
|
}
|
|
|
|
m_stall_msg_map.clear();
|
2010-08-20 20:46:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-09-16 18:59:56 +02:00
|
|
|
MessageBuffer::stallMessage(Addr addr, Tick current_time)
|
2010-08-20 20:46:14 +02:00
|
|
|
{
|
2015-09-18 20:27:47 +02:00
|
|
|
DPRINTF(RubyQueue, "Stalling due to %#x\n", addr);
|
2015-09-16 18:59:56 +02:00
|
|
|
assert(isReady(current_time));
|
2015-08-14 19:04:51 +02:00
|
|
|
assert(getOffset(addr) == 0);
|
2015-07-04 17:43:46 +02:00
|
|
|
MsgPtr message = m_prio_heap.front();
|
2010-08-20 20:46:14 +02:00
|
|
|
|
2015-09-16 18:59:56 +02:00
|
|
|
dequeue(current_time);
|
2010-08-20 20:46:14 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Note: no event is scheduled to analyze the map at a later time.
|
|
|
|
// Instead the controller is responsible to call reanalyzeMessages when
|
|
|
|
// these addresses change state.
|
|
|
|
//
|
|
|
|
(m_stall_msg_map[addr]).push_back(message);
|
2016-12-20 18:38:24 +01:00
|
|
|
m_stall_map_size++;
|
2010-08-20 20:46:14 +02:00
|
|
|
}
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
void
|
|
|
|
MessageBuffer::print(ostream& out) const
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2011-02-23 06:58:40 +01:00
|
|
|
ccprintf(out, "[MessageBuffer: ");
|
2013-03-22 21:53:27 +01:00
|
|
|
if (m_consumer != NULL) {
|
2011-02-23 06:58:40 +01:00
|
|
|
ccprintf(out, " consumer-yes ");
|
2010-03-23 02:43:53 +01:00
|
|
|
}
|
2010-06-11 08:17:07 +02:00
|
|
|
|
2015-07-04 17:43:46 +02:00
|
|
|
vector<MsgPtr> copy(m_prio_heap);
|
|
|
|
sort_heap(copy.begin(), copy.end(), greater<MsgPtr>());
|
ruby: Expose MessageBuffers as SimObjects
Expose MessageBuffers from SLICC controllers as SimObjects that can be
manipulated in Python. This patch has numerous benefits:
1) First and foremost, it exposes MessageBuffers as SimObjects that can be
manipulated in Python code. This allows parameters to be set and checked in
Python code to avoid obfuscating parameters within protocol files. Further, now
as SimObjects, MessageBuffer parameters are printed to config output files as a
way to track parameters across simulations (e.g. buffer sizes)
2) Cleans up special-case code for responseFromMemory buffers, and aligns their
instantiation and use with mandatoryQueue buffers. These two special buffers
are the only MessageBuffers that are exposed to components outside of SLICC
controllers, and they're both slave ends of these buffers. They should be
exposed outside of SLICC in the same way, and this patch does it.
3) Distinguishes buffer-specific parameters from buffer-to-network parameters.
Specifically, buffer size, randomization, ordering, recycle latency, and ports
are all specific to a MessageBuffer, while the virtual network ID and type are
intrinsics of how the buffer is connected to network ports. The former are
specified in the Python object, while the latter are specified in the
controller *.sm files. Unlike buffer-specific parameters, which may need to
change depending on the simulated system structure, buffer-to-network
parameters can be specified statically for most or all different simulated
systems.
2015-08-14 07:19:44 +02:00
|
|
|
ccprintf(out, "%s] %s", copy, name());
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2012-10-16 00:51:57 +02:00
|
|
|
bool
|
2015-09-16 18:59:56 +02:00
|
|
|
MessageBuffer::isReady(Tick current_time) const
|
2012-10-16 00:51:57 +02:00
|
|
|
{
|
|
|
|
return ((m_prio_heap.size() > 0) &&
|
2015-09-16 18:59:56 +02:00
|
|
|
(m_prio_heap.front()->getLastEnqueueTime() <= current_time));
|
2012-10-16 00:51:57 +02:00
|
|
|
}
|
|
|
|
|
2016-12-02 17:40:40 +01:00
|
|
|
void
|
|
|
|
MessageBuffer::regStats()
|
|
|
|
{
|
|
|
|
m_not_avail_count
|
|
|
|
.name(name() + ".not_avail_count")
|
|
|
|
.desc("Number of times this buffer did not have N slots available")
|
|
|
|
.flags(Stats::nozero);
|
|
|
|
}
|
|
|
|
|
2012-10-16 00:51:57 +02:00
|
|
|
uint32_t
|
|
|
|
MessageBuffer::functionalWrite(Packet *pkt)
|
|
|
|
{
|
|
|
|
uint32_t num_functional_writes = 0;
|
|
|
|
|
|
|
|
// Check the priority heap and write any messages that may
|
|
|
|
// correspond to the address in the packet.
|
|
|
|
for (unsigned int i = 0; i < m_prio_heap.size(); ++i) {
|
2015-07-04 17:43:46 +02:00
|
|
|
Message *msg = m_prio_heap[i].get();
|
2012-10-16 00:51:57 +02:00
|
|
|
if (msg->functionalWrite(pkt)) {
|
|
|
|
num_functional_writes++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the stall queue and write any messages that may
|
|
|
|
// correspond to the address in the packet.
|
|
|
|
for (StallMsgMapType::iterator map_iter = m_stall_msg_map.begin();
|
|
|
|
map_iter != m_stall_msg_map.end();
|
|
|
|
++map_iter) {
|
|
|
|
|
|
|
|
for (std::list<MsgPtr>::iterator it = (map_iter->second).begin();
|
|
|
|
it != (map_iter->second).end(); ++it) {
|
|
|
|
|
|
|
|
Message *msg = (*it).get();
|
|
|
|
if (msg->functionalWrite(pkt)) {
|
|
|
|
num_functional_writes++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_functional_writes;
|
|
|
|
}
|
ruby: Expose MessageBuffers as SimObjects
Expose MessageBuffers from SLICC controllers as SimObjects that can be
manipulated in Python. This patch has numerous benefits:
1) First and foremost, it exposes MessageBuffers as SimObjects that can be
manipulated in Python code. This allows parameters to be set and checked in
Python code to avoid obfuscating parameters within protocol files. Further, now
as SimObjects, MessageBuffer parameters are printed to config output files as a
way to track parameters across simulations (e.g. buffer sizes)
2) Cleans up special-case code for responseFromMemory buffers, and aligns their
instantiation and use with mandatoryQueue buffers. These two special buffers
are the only MessageBuffers that are exposed to components outside of SLICC
controllers, and they're both slave ends of these buffers. They should be
exposed outside of SLICC in the same way, and this patch does it.
3) Distinguishes buffer-specific parameters from buffer-to-network parameters.
Specifically, buffer size, randomization, ordering, recycle latency, and ports
are all specific to a MessageBuffer, while the virtual network ID and type are
intrinsics of how the buffer is connected to network ports. The former are
specified in the Python object, while the latter are specified in the
controller *.sm files. Unlike buffer-specific parameters, which may need to
change depending on the simulated system structure, buffer-to-network
parameters can be specified statically for most or all different simulated
systems.
2015-08-14 07:19:44 +02:00
|
|
|
|
|
|
|
MessageBuffer *
|
|
|
|
MessageBufferParams::create()
|
|
|
|
{
|
|
|
|
return new MessageBuffer(this);
|
|
|
|
}
|