Adding gem5 source to svn.
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1819 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
10
simulators/gem5/src/mem/ruby/Decomissioning_note
Normal file
10
simulators/gem5/src/mem/ruby/Decomissioning_note
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
1. While decomissioning log_tm
|
||||
|
||||
a. I left lots of transaction related stuff ( Xact.... ) in commands.C
|
||||
Made the minimal changes to compile it properly
|
||||
|
||||
|
||||
make[1]: *** No rule to make target `amd64-linux/generated/MI_example/obj/PartialAddressFilter.o', needed by `amd64-linux/generated/MI_example/bin/libruby.so
|
||||
|
||||
|
||||
104
simulators/gem5/src/mem/ruby/README.debugging
Normal file
104
simulators/gem5/src/mem/ruby/README.debugging
Normal file
@ -0,0 +1,104 @@
|
||||
# ------ Debugging the Ruby Tester ------
|
||||
|
||||
You can compile Ruby with debugging turned on.
|
||||
|
||||
cd ruby
|
||||
[vim or emacs] Makefile
|
||||
|
||||
Change OPT_FLAGS to "-g -O0" (the first OPT_FLAGS line). Make
|
||||
sure all the other OPT_FLAGS lines are commented out.
|
||||
|
||||
Change DEBUG_FLAGS to "-DRUBY_DEBUG=true". (Just uncomment the
|
||||
first DEBUG_FLAGS line, and comment out the second DEBUG_FLAGS
|
||||
line.)
|
||||
|
||||
You can choose which component or components to debug, and the
|
||||
level of verbosity. For example,
|
||||
|
||||
"x86-linux/generated/MOSI_SMP_bcast/bin/tester.exec -l 100000 -v med -c n"
|
||||
|
||||
gives you debugging information about the network component at
|
||||
the medium verbosity level. -v selects the verbosity, which may
|
||||
be low, med, high, or none. -c selects the component or
|
||||
components.
|
||||
|
||||
"x86-linux/generated/MOSI_SMP_bcast/bin/tester.exec -l 100000 -v med -c nSt"
|
||||
|
||||
debugs the network, the sequencer, and the tester.
|
||||
|
||||
For a list of the components you can debug, just run the tester with
|
||||
no arguments, and it will display a list of valid components. The
|
||||
components are defined in ruby/common/Debug.def.
|
||||
|
||||
The protocol debug trace is especially useful for debugging cache coherence protocols. This must be enabled at compile-time by ensuring that PROTOCOL_DEBUG_TRACE is set to true for rubyconfig.defaults (if running in Simics) or tester.defaults. You must specify the time to start tracing. The following starts the protocol trace immediately (at time 1)
|
||||
|
||||
"x86-linux/generated/MOSI_SMP_bcast/bin/tester.exec -l 100000 -s 1"
|
||||
|
||||
Also, if something seems to be wrong and you're not sure where to
|
||||
start looking, it may help to run the tester for a longer time,
|
||||
e.g.
|
||||
|
||||
"x86-linux/generated/MOSI_SMP_bcast/bin/tester.exec -l 500000"
|
||||
|
||||
This may help because some problems eventually show up as
|
||||
deadlock, but the tester has to run for a long time before a
|
||||
deadlock is detected.
|
||||
|
||||
Once your simulator has succeeded on the tester for a certain
|
||||
number of cycles, say 1000000, you may want to set the
|
||||
RANDOMIZATION variable in ruby/config/tester.defaults to "true"
|
||||
for more thorough testing. However, RANDOMIZATION may not work in
|
||||
all situations because it overrides some of the ordering in the
|
||||
network and may break your simulator in ways you don't like. For
|
||||
example, messages are added to MessageBuffers with random
|
||||
latency.
|
||||
|
||||
By default the tester driver is a generator that issues random store
|
||||
and load requests. This driver does a good job of stressing the
|
||||
cache coherency protocol by issuing racy store requests from multiple
|
||||
processors to a cache line then checks the stores with a single load.
|
||||
|
||||
Other tester drivers are available. By setting the g_SYNTHETIC_DRIVER
|
||||
to true in ruby/config/tester.defaults, you enable a tester that generates
|
||||
racy lock requests for a number of locks indicated by g_synthetic_locks.
|
||||
|
||||
Another tester driver is a series of non-racy deterministic testers. By
|
||||
setting the g_DETERMINISTIC_DRIVER in ruby/config/tester.defaults to true,
|
||||
you enable the deterministic tester. The deterministic tester can do
|
||||
different types of deterministic tests as specified by g_SpecifiedGenerator
|
||||
string. The deterministic tester works best when RANDOMIZATION is set to
|
||||
false. To easily track the queues being used with the deterministic tester,
|
||||
use the following debug flags "-v low -c nq".
|
||||
|
||||
# ------ Debugging Ruby in Simics ------
|
||||
|
||||
When you're running Simics, the debugging components and
|
||||
verbosity levels are the same. However, the way you communicate
|
||||
with Ruby changes.
|
||||
|
||||
See the README.quickstart for information on compiling the Ruby
|
||||
module and loading it into Simics. Once you've got Simics
|
||||
running, with the Ruby module loaded, you can set up Ruby
|
||||
debugging.
|
||||
|
||||
To set the debugging verbosity level, run:
|
||||
|
||||
simics> ruby0.debug-verb med
|
||||
|
||||
To set the debugging components, run: (see common/Debug.def for complete list
|
||||
of component shortcuts)
|
||||
|
||||
simics> ruby0.debug-filter n
|
||||
|
||||
(NOTE: sometimes simics will interpret a single letter as a
|
||||
command; e.g. expanding "p" into "print". If simics gives you an
|
||||
error when setting the debug filter, try setting it like so:
|
||||
simics> ruby0.debug-filter "n")
|
||||
|
||||
This gives the same kind of debugging information as running the
|
||||
tester with "-v med -c n".
|
||||
|
||||
You can also send the debugging output to a file (may be a good
|
||||
idea, since there's a lot of it). To do this, run:
|
||||
|
||||
simics> ruby0.debug-output-file <filename>
|
||||
116
simulators/gem5/src/mem/ruby/SConscript
Normal file
116
simulators/gem5/src/mem/ruby/SConscript
Normal file
@ -0,0 +1,116 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
||||
# 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.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from os.path import basename, isdir, join as joinpath
|
||||
|
||||
import SCons
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['TARGET_ISA'] == 'no':
|
||||
Return()
|
||||
|
||||
if env['PROTOCOL'] == 'None':
|
||||
Return()
|
||||
|
||||
def do_embed_text(target, source, env):
|
||||
"""convert a text file into a file that can be embedded in C
|
||||
using an #include statement, that defines a \"const char *\" pointing
|
||||
to the same text.
|
||||
|
||||
This is useful to embed scripts and configuration files in object files.
|
||||
"""
|
||||
|
||||
escape = [ "\'", "\"", "\\", "\?" ]
|
||||
|
||||
# reads the text file in, line by line, converting it to a C string
|
||||
fin = open(str(source[0]), 'r')
|
||||
fout = open(str(target[0]), 'w' )
|
||||
fout.write("static const char *%s =\n" % source[1].get_contents());
|
||||
for l in fin:
|
||||
# add escape sequences for the characters in escape
|
||||
fout.write("\"")
|
||||
for char in l:
|
||||
if char == "\n":
|
||||
break
|
||||
if char in escape:
|
||||
fout.write("\\")
|
||||
fout.write(char)
|
||||
else:
|
||||
fout.write(char)
|
||||
fout.write("\\n\"\n");
|
||||
fout.write(";\n");
|
||||
fin.close()
|
||||
fout.close()
|
||||
|
||||
#
|
||||
# Link includes
|
||||
#
|
||||
generated_dir = Dir('../protocol')
|
||||
|
||||
def MakeIncludeAction(target, source, env):
|
||||
f = file(str(target[0]), 'w')
|
||||
for s in source:
|
||||
print >>f, '#include "%s"' % str(s.abspath)
|
||||
f.close()
|
||||
|
||||
def MakeInclude(source):
|
||||
target = generated_dir.File(basename(source))
|
||||
include_action = MakeAction(MakeIncludeAction, Transform("MAKE INC", 1))
|
||||
env.Command(target, source, include_action)
|
||||
|
||||
MakeInclude('slicc_interface/AbstractEntry.hh')
|
||||
MakeInclude('slicc_interface/AbstractCacheEntry.hh')
|
||||
MakeInclude('slicc_interface/AbstractProtocol.hh')
|
||||
MakeInclude('slicc_interface/Message.hh')
|
||||
MakeInclude('slicc_interface/NetworkMessage.hh')
|
||||
MakeInclude('slicc_interface/RubyRequest.hh')
|
||||
|
||||
# External types
|
||||
MakeInclude('buffers/MessageBuffer.hh')
|
||||
MakeInclude('common/Address.hh')
|
||||
MakeInclude('common/DataBlock.hh')
|
||||
MakeInclude('common/NetDest.hh')
|
||||
MakeInclude('common/Set.hh')
|
||||
MakeInclude('filters/GenericBloomFilter.hh')
|
||||
MakeInclude('system/CacheMemory.hh')
|
||||
MakeInclude('system/DMASequencer.hh')
|
||||
MakeInclude('system/DirectoryMemory.hh')
|
||||
MakeInclude('system/MachineID.hh')
|
||||
MakeInclude('system/MemoryControl.hh')
|
||||
MakeInclude('system/WireBuffer.hh')
|
||||
MakeInclude('system/PerfectCacheMemory.hh')
|
||||
MakeInclude('system/PersistentTable.hh')
|
||||
MakeInclude('system/Sequencer.hh')
|
||||
MakeInclude('system/TBETable.hh')
|
||||
MakeInclude('system/TimerTable.hh')
|
||||
39
simulators/gem5/src/mem/ruby/SConsopts
Normal file
39
simulators/gem5/src/mem/ruby/SConsopts
Normal file
@ -0,0 +1,39 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
||||
# 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.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
|
||||
Import('*')
|
||||
|
||||
sticky_vars.AddVariables(
|
||||
BoolVariable('NO_VECTOR_BOUNDS_CHECKS', "Don't do bounds checks in Ruby",
|
||||
True),
|
||||
)
|
||||
|
||||
export_vars += [ 'NO_VECTOR_BOUNDS_CHECKS' ]
|
||||
|
||||
438
simulators/gem5/src/mem/ruby/buffers/MessageBuffer.cc
Normal file
438
simulators/gem5/src/mem/ruby/buffers/MessageBuffer.cc
Normal file
@ -0,0 +1,438 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "base/cprintf.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "base/stl_helpers.hh"
|
||||
#include "debug/RubyQueue.hh"
|
||||
#include "mem/ruby/buffers/MessageBuffer.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
using namespace std;
|
||||
using m5::stl_helpers::operator<<;
|
||||
|
||||
MessageBuffer::MessageBuffer(const string &name)
|
||||
{
|
||||
m_msg_counter = 0;
|
||||
m_consumer_ptr = NULL;
|
||||
m_ordering_set = false;
|
||||
m_strict_fifo = true;
|
||||
m_size = 0;
|
||||
m_max_size = -1;
|
||||
m_last_arrival_time = 0;
|
||||
m_randomization = true;
|
||||
m_size_last_time_size_checked = 0;
|
||||
m_time_last_time_size_checked = 0;
|
||||
m_time_last_time_enqueue = 0;
|
||||
m_time_last_time_pop = 0;
|
||||
m_size_at_cycle_start = 0;
|
||||
m_msgs_this_cycle = 0;
|
||||
m_not_avail_count = 0;
|
||||
m_priority_rank = 0;
|
||||
m_name = name;
|
||||
|
||||
m_stall_msg_map.clear();
|
||||
m_input_link_id = 0;
|
||||
m_vnet_id = 0;
|
||||
}
|
||||
|
||||
int
|
||||
MessageBuffer::getSize()
|
||||
{
|
||||
if (m_time_last_time_size_checked == g_eventQueue_ptr->getTime()) {
|
||||
return m_size_last_time_size_checked;
|
||||
} else {
|
||||
m_time_last_time_size_checked = g_eventQueue_ptr->getTime();
|
||||
m_size_last_time_size_checked = m_size;
|
||||
return m_size;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
MessageBuffer::areNSlotsAvailable(int n)
|
||||
{
|
||||
|
||||
// fast path when message buffers have infinite size
|
||||
if (m_max_size == -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// determine my correct size for the current cycle
|
||||
// pop operations shouldn't effect the network's visible size
|
||||
// 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()) {
|
||||
// no pops this cycle - m_size is correct
|
||||
current_size = m_size;
|
||||
} else {
|
||||
if (m_time_last_time_enqueue < g_eventQueue_ptr->getTime()) {
|
||||
// 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
|
||||
current_size = m_size_at_cycle_start+m_msgs_this_cycle;
|
||||
}
|
||||
}
|
||||
|
||||
// now compare the new size with our max size
|
||||
if (current_size + n <= m_max_size) {
|
||||
return true;
|
||||
} else {
|
||||
DPRINTF(RubyQueue, "n: %d, current_size: %d, m_size: %d, "
|
||||
"m_max_size: %d\n",
|
||||
n, current_size, m_size, m_max_size);
|
||||
m_not_avail_count++;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const MsgPtr
|
||||
MessageBuffer::getMsgPtrCopy() const
|
||||
{
|
||||
assert(isReady());
|
||||
|
||||
return m_prio_heap.front().m_msgptr->clone();
|
||||
}
|
||||
|
||||
const Message*
|
||||
MessageBuffer::peekAtHeadOfQueue() const
|
||||
{
|
||||
DPRINTF(RubyQueue, "Peeking at head of queue.\n");
|
||||
assert(isReady());
|
||||
|
||||
const Message* msg_ptr = m_prio_heap.front().m_msgptr.get();
|
||||
assert(msg_ptr);
|
||||
|
||||
DPRINTF(RubyQueue, "Message: %s\n", (*msg_ptr));
|
||||
return msg_ptr;
|
||||
}
|
||||
|
||||
// FIXME - move me somewhere else
|
||||
int
|
||||
random_time()
|
||||
{
|
||||
int time = 1;
|
||||
time += random() & 0x3; // [0...3]
|
||||
if ((random() & 0x7) == 0) { // 1 in 8 chance
|
||||
time += 100 + (random() % 0xf); // 100 + [1...15]
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
void
|
||||
MessageBuffer::enqueue(MsgPtr message, Time delta)
|
||||
{
|
||||
m_msg_counter++;
|
||||
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()) {
|
||||
m_msgs_this_cycle = 0; // first msg this cycle
|
||||
m_time_last_time_enqueue = g_eventQueue_ptr->getTime();
|
||||
}
|
||||
m_msgs_this_cycle++;
|
||||
|
||||
if (!m_ordering_set) {
|
||||
panic("Ordering property of %s has not been set", m_name);
|
||||
}
|
||||
|
||||
// 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 arrival_time = 0;
|
||||
if (!RubySystem::getRandomization() || (m_randomization == false)) {
|
||||
// No randomization
|
||||
arrival_time = current_time + delta;
|
||||
} else {
|
||||
// Randomization - ignore delta
|
||||
if (m_strict_fifo) {
|
||||
if (m_last_arrival_time < current_time) {
|
||||
m_last_arrival_time = current_time;
|
||||
}
|
||||
arrival_time = m_last_arrival_time + random_time();
|
||||
} else {
|
||||
arrival_time = current_time + random_time();
|
||||
}
|
||||
}
|
||||
|
||||
// Check the arrival time
|
||||
assert(arrival_time > current_time);
|
||||
if (m_strict_fifo) {
|
||||
if (arrival_time < m_last_arrival_time) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
// If running a cache trace, don't worry about the last arrival checks
|
||||
if (!g_system_ptr->m_warmup_enabled) {
|
||||
m_last_arrival_time = arrival_time;
|
||||
}
|
||||
|
||||
// compute the delay cycles and set enqueue time
|
||||
Message* msg_ptr = message.get();
|
||||
assert(msg_ptr != NULL);
|
||||
|
||||
assert(g_eventQueue_ptr->getTime() >= msg_ptr->getLastEnqueueTime() &&
|
||||
"ensure we aren't dequeued early");
|
||||
|
||||
msg_ptr->setDelayedCycles(g_eventQueue_ptr->getTime() -
|
||||
msg_ptr->getLastEnqueueTime() +
|
||||
msg_ptr->getDelayedCycles());
|
||||
msg_ptr->setLastEnqueueTime(arrival_time);
|
||||
|
||||
// Insert the message into the priority heap
|
||||
MessageBufferNode thisNode(arrival_time, m_msg_counter, message);
|
||||
m_prio_heap.push_back(thisNode);
|
||||
push_heap(m_prio_heap.begin(), m_prio_heap.end(),
|
||||
greater<MessageBufferNode>());
|
||||
|
||||
DPRINTF(RubyQueue, "Enqueue with arrival_time %lld.\n",
|
||||
arrival_time * g_eventQueue_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->storeEventInfo(m_vnet_id);
|
||||
} else {
|
||||
panic("No consumer: %s name: %s\n", *this, m_name);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
MessageBuffer::dequeue_getDelayCycles(MsgPtr& message)
|
||||
{
|
||||
int delay_cycles = -1; // null value
|
||||
|
||||
dequeue(message);
|
||||
|
||||
// get the delay cycles
|
||||
delay_cycles = setAndReturnDelayCycles(message);
|
||||
|
||||
assert(delay_cycles >= 0);
|
||||
return delay_cycles;
|
||||
}
|
||||
|
||||
void
|
||||
MessageBuffer::dequeue(MsgPtr& message)
|
||||
{
|
||||
DPRINTF(RubyQueue, "Dequeueing\n");
|
||||
message = m_prio_heap.front().m_msgptr;
|
||||
|
||||
pop();
|
||||
DPRINTF(RubyQueue, "Enqueue message is %s\n", (*(message.get())));
|
||||
}
|
||||
|
||||
int
|
||||
MessageBuffer::dequeue_getDelayCycles()
|
||||
{
|
||||
int delay_cycles = -1; // null value
|
||||
|
||||
// get MsgPtr of the message about to be dequeued
|
||||
MsgPtr message = m_prio_heap.front().m_msgptr;
|
||||
|
||||
// get the delay cycles
|
||||
delay_cycles = setAndReturnDelayCycles(message);
|
||||
|
||||
dequeue();
|
||||
|
||||
assert(delay_cycles >= 0);
|
||||
return delay_cycles;
|
||||
}
|
||||
|
||||
void
|
||||
MessageBuffer::pop()
|
||||
{
|
||||
DPRINTF(RubyQueue, "Popping\n");
|
||||
assert(isReady());
|
||||
pop_heap(m_prio_heap.begin(), m_prio_heap.end(),
|
||||
greater<MessageBufferNode>());
|
||||
m_prio_heap.pop_back();
|
||||
|
||||
// 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()) {
|
||||
m_size_at_cycle_start = m_size;
|
||||
m_time_last_time_pop = g_eventQueue_ptr->getTime();
|
||||
}
|
||||
m_size--;
|
||||
}
|
||||
|
||||
void
|
||||
MessageBuffer::clear()
|
||||
{
|
||||
m_prio_heap.clear();
|
||||
|
||||
m_msg_counter = 0;
|
||||
m_size = 0;
|
||||
m_time_last_time_enqueue = 0;
|
||||
m_time_last_time_pop = 0;
|
||||
m_size_at_cycle_start = 0;
|
||||
m_msgs_this_cycle = 0;
|
||||
}
|
||||
|
||||
void
|
||||
MessageBuffer::recycle()
|
||||
{
|
||||
DPRINTF(RubyQueue, "Recycling.\n");
|
||||
assert(isReady());
|
||||
MessageBufferNode node = m_prio_heap.front();
|
||||
pop_heap(m_prio_heap.begin(), m_prio_heap.end(),
|
||||
greater<MessageBufferNode>());
|
||||
node.m_time = g_eventQueue_ptr->getTime() + m_recycle_latency;
|
||||
m_prio_heap.back() = node;
|
||||
push_heap(m_prio_heap.begin(), m_prio_heap.end(),
|
||||
greater<MessageBufferNode>());
|
||||
g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr,
|
||||
g_eventQueue_ptr->getTime() + m_recycle_latency);
|
||||
}
|
||||
|
||||
void
|
||||
MessageBuffer::reanalyzeMessages(const Address& addr)
|
||||
{
|
||||
DPRINTF(RubyQueue, "ReanalyzeMessages\n");
|
||||
assert(m_stall_msg_map.count(addr) > 0);
|
||||
|
||||
//
|
||||
// Put all stalled messages associated with this address back on the
|
||||
// prio heap
|
||||
//
|
||||
while(!m_stall_msg_map[addr].empty()) {
|
||||
m_msg_counter++;
|
||||
MessageBufferNode msgNode(g_eventQueue_ptr->getTime() + 1,
|
||||
m_msg_counter,
|
||||
m_stall_msg_map[addr].front());
|
||||
|
||||
m_prio_heap.push_back(msgNode);
|
||||
push_heap(m_prio_heap.begin(), m_prio_heap.end(),
|
||||
greater<MessageBufferNode>());
|
||||
|
||||
g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr, msgNode.m_time);
|
||||
m_stall_msg_map[addr].pop_front();
|
||||
}
|
||||
m_stall_msg_map.erase(addr);
|
||||
}
|
||||
|
||||
void
|
||||
MessageBuffer::reanalyzeAllMessages()
|
||||
{
|
||||
DPRINTF(RubyQueue, "ReanalyzeAllMessages %s\n");
|
||||
|
||||
//
|
||||
// Put all stalled messages associated with this address back on the
|
||||
// prio heap
|
||||
//
|
||||
for (StallMsgMapType::iterator map_iter = m_stall_msg_map.begin();
|
||||
map_iter != m_stall_msg_map.end();
|
||||
++map_iter) {
|
||||
|
||||
while(!(map_iter->second).empty()) {
|
||||
m_msg_counter++;
|
||||
MessageBufferNode msgNode(g_eventQueue_ptr->getTime() + 1,
|
||||
m_msg_counter,
|
||||
(map_iter->second).front());
|
||||
|
||||
m_prio_heap.push_back(msgNode);
|
||||
push_heap(m_prio_heap.begin(), m_prio_heap.end(),
|
||||
greater<MessageBufferNode>());
|
||||
|
||||
g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr,
|
||||
msgNode.m_time);
|
||||
(map_iter->second).pop_front();
|
||||
}
|
||||
}
|
||||
m_stall_msg_map.clear();
|
||||
}
|
||||
|
||||
void
|
||||
MessageBuffer::stallMessage(const Address& addr)
|
||||
{
|
||||
DPRINTF(RubyQueue, "Stalling due to %s\n", addr);
|
||||
assert(isReady());
|
||||
assert(addr.getOffset() == 0);
|
||||
MsgPtr message = m_prio_heap.front().m_msgptr;
|
||||
|
||||
pop();
|
||||
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
|
||||
int
|
||||
MessageBuffer::setAndReturnDelayCycles(MsgPtr msg_ptr)
|
||||
{
|
||||
int delay_cycles = -1; // null value
|
||||
|
||||
// get the delay cycles of the message at the top of the queue
|
||||
|
||||
// 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() -
|
||||
msg_ptr->getLastEnqueueTime() +
|
||||
msg_ptr->getDelayedCycles());
|
||||
delay_cycles = msg_ptr->getDelayedCycles();
|
||||
|
||||
assert(delay_cycles >= 0);
|
||||
return delay_cycles;
|
||||
}
|
||||
|
||||
void
|
||||
MessageBuffer::print(ostream& out) const
|
||||
{
|
||||
ccprintf(out, "[MessageBuffer: ");
|
||||
if (m_consumer_ptr != NULL) {
|
||||
ccprintf(out, " consumer-yes ");
|
||||
}
|
||||
|
||||
vector<MessageBufferNode> copy(m_prio_heap);
|
||||
sort_heap(copy.begin(), copy.end(), greater<MessageBufferNode>());
|
||||
ccprintf(out, "%s] %s", copy, m_name);
|
||||
}
|
||||
|
||||
void
|
||||
MessageBuffer::printStats(ostream& out)
|
||||
{
|
||||
out << "MessageBuffer: " << m_name << " stats - msgs:" << m_msg_counter
|
||||
<< " full:" << m_not_avail_count << endl;
|
||||
}
|
||||
207
simulators/gem5/src/mem/ruby/buffers/MessageBuffer.hh
Normal file
207
simulators/gem5/src/mem/ruby/buffers/MessageBuffer.hh
Normal file
@ -0,0 +1,207 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Unordered buffer of messages that can be inserted such
|
||||
* that they can be dequeued after a given delta time has expired.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_BUFFERS_MESSAGEBUFFER_HH__
|
||||
#define __MEM_RUBY_BUFFERS_MESSAGEBUFFER_HH__
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/buffers/MessageBufferNode.hh"
|
||||
#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
|
||||
{
|
||||
public:
|
||||
MessageBuffer(const std::string &name = "");
|
||||
|
||||
std::string name() const { return m_name; }
|
||||
|
||||
static void printConfig(std::ostream& out) {}
|
||||
void
|
||||
setRecycleLatency(int recycle_latency)
|
||||
{
|
||||
m_recycle_latency = recycle_latency;
|
||||
}
|
||||
|
||||
void reanalyzeMessages(const Address& addr);
|
||||
void reanalyzeAllMessages();
|
||||
void stallMessage(const Address& addr);
|
||||
|
||||
// TRUE if head of queue timestamp <= SystemTime
|
||||
bool
|
||||
isReady() const
|
||||
{
|
||||
return ((m_prio_heap.size() > 0) &&
|
||||
(m_prio_heap.front().m_time <= g_eventQueue_ptr->getTime()));
|
||||
}
|
||||
|
||||
void
|
||||
delayHead()
|
||||
{
|
||||
MessageBufferNode node = m_prio_heap.front();
|
||||
std::pop_heap(m_prio_heap.begin(), m_prio_heap.end(),
|
||||
std::greater<MessageBufferNode>());
|
||||
m_prio_heap.pop_back();
|
||||
enqueue(node.m_msgptr, 1);
|
||||
}
|
||||
|
||||
bool areNSlotsAvailable(int n);
|
||||
int getPriority() { return m_priority_rank; }
|
||||
void setPriority(int rank) { m_priority_rank = rank; }
|
||||
void setConsumer(Consumer* consumer_ptr)
|
||||
{
|
||||
assert(m_consumer_ptr == NULL);
|
||||
m_consumer_ptr = consumer_ptr;
|
||||
}
|
||||
|
||||
void setDescription(const std::string& name) { m_name = name; }
|
||||
std::string getDescription() { return m_name;}
|
||||
|
||||
Consumer* getConsumer() { return m_consumer_ptr; }
|
||||
|
||||
const Message* peekAtHeadOfQueue() const;
|
||||
const Message* peek() const { return peekAtHeadOfQueue(); }
|
||||
const MsgPtr getMsgPtrCopy() const;
|
||||
|
||||
const MsgPtr&
|
||||
peekMsgPtr() const
|
||||
{
|
||||
assert(isReady());
|
||||
return m_prio_heap.front().m_msgptr;
|
||||
}
|
||||
|
||||
const MsgPtr&
|
||||
peekMsgPtrEvenIfNotReady() const
|
||||
{
|
||||
return m_prio_heap.front().m_msgptr;
|
||||
}
|
||||
|
||||
void enqueue(MsgPtr message) { enqueue(message, 1); }
|
||||
void enqueue(MsgPtr message, Time delta);
|
||||
// void enqueueAbsolute(const MsgPtr& message, Time absolute_time);
|
||||
int dequeue_getDelayCycles(MsgPtr& message); // returns delay
|
||||
// cycles of the
|
||||
// message
|
||||
void dequeue(MsgPtr& message);
|
||||
int dequeue_getDelayCycles(); // returns delay cycles of the message
|
||||
void dequeue() { pop(); }
|
||||
void pop();
|
||||
void recycle();
|
||||
bool isEmpty() const { return m_prio_heap.size() == 0; }
|
||||
|
||||
void
|
||||
setOrdering(bool order)
|
||||
{
|
||||
m_strict_fifo = order;
|
||||
m_ordering_set = true;
|
||||
}
|
||||
void resize(int size) { m_max_size = size; }
|
||||
int getSize();
|
||||
void setRandomization(bool random_flag) { m_randomization = random_flag; }
|
||||
|
||||
void clear();
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
void printStats(std::ostream& out);
|
||||
void clearStats() { m_not_avail_count = 0; m_msg_counter = 0; }
|
||||
|
||||
void setIncomingLink(int link_id) { m_input_link_id = link_id; }
|
||||
void setVnet(int net) { m_vnet_id = net; }
|
||||
|
||||
private:
|
||||
//added by SS
|
||||
int m_recycle_latency;
|
||||
|
||||
// Private Methods
|
||||
int setAndReturnDelayCycles(MsgPtr message);
|
||||
|
||||
// Private copy constructor and assignment operator
|
||||
MessageBuffer(const MessageBuffer& obj);
|
||||
MessageBuffer& operator=(const MessageBuffer& obj);
|
||||
|
||||
// Data Members (m_ prefix)
|
||||
Consumer* m_consumer_ptr; // Consumer to signal a wakeup(), can be NULL
|
||||
std::vector<MessageBufferNode> m_prio_heap;
|
||||
|
||||
// use a std::map for the stalled messages as this container is
|
||||
// sorted and ensures a well-defined iteration order
|
||||
typedef std::map< Address, std::list<MsgPtr> > StallMsgMapType;
|
||||
typedef std::vector<MsgPtr>::iterator MsgListIter;
|
||||
|
||||
StallMsgMapType m_stall_msg_map;
|
||||
std::string m_name;
|
||||
|
||||
int m_max_size;
|
||||
int m_size;
|
||||
|
||||
Time m_time_last_time_size_checked;
|
||||
int m_size_last_time_size_checked;
|
||||
|
||||
// variables used so enqueues appear to happen imediately, while
|
||||
// pop happen the next cycle
|
||||
Time m_time_last_time_enqueue;
|
||||
Time m_time_last_time_pop;
|
||||
int m_size_at_cycle_start;
|
||||
int m_msgs_this_cycle;
|
||||
|
||||
int m_not_avail_count; // count the # of times I didn't have N
|
||||
// slots available
|
||||
uint64 m_msg_counter;
|
||||
int m_priority_rank;
|
||||
bool m_strict_fifo;
|
||||
bool m_ordering_set;
|
||||
bool m_randomization;
|
||||
Time m_last_arrival_time;
|
||||
|
||||
int m_input_link_id;
|
||||
int m_vnet_id;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const MessageBuffer& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_BUFFERS_MESSAGEBUFFER_HH__
|
||||
39
simulators/gem5/src/mem/ruby/buffers/MessageBufferNode.cc
Normal file
39
simulators/gem5/src/mem/ruby/buffers/MessageBufferNode.cc
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "mem/ruby/buffers/MessageBufferNode.hh"
|
||||
|
||||
void
|
||||
MessageBufferNode::print(std::ostream& out) const
|
||||
{
|
||||
out << "[";
|
||||
out << m_time << ", ";
|
||||
out << m_msg_counter << ", ";
|
||||
out << m_msgptr << "; ";
|
||||
out << "]";
|
||||
}
|
||||
80
simulators/gem5/src/mem/ruby/buffers/MessageBufferNode.hh
Normal file
80
simulators/gem5/src/mem/ruby/buffers/MessageBufferNode.hh
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_BUFFERS_MESSAGEBUFFERNODE_HH__
|
||||
#define __MEM_RUBY_BUFFERS_MESSAGEBUFFERNODE_HH__
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/slicc_interface/Message.hh"
|
||||
|
||||
class MessageBufferNode
|
||||
{
|
||||
public:
|
||||
MessageBufferNode()
|
||||
{
|
||||
m_time = 0;
|
||||
m_msg_counter = 0;
|
||||
}
|
||||
|
||||
MessageBufferNode(const Time& time, int counter, const MsgPtr& msgptr)
|
||||
{
|
||||
m_time = time;
|
||||
m_msgptr = msgptr;
|
||||
m_msg_counter = counter;
|
||||
}
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
public:
|
||||
Time m_time;
|
||||
uint64 m_msg_counter; // FIXME, should this be a 64-bit value?
|
||||
MsgPtr m_msgptr;
|
||||
};
|
||||
|
||||
inline bool
|
||||
operator>(const MessageBufferNode& n1, const MessageBufferNode& n2)
|
||||
{
|
||||
if (n1.m_time == n2.m_time) {
|
||||
assert(n1.m_msg_counter != n2.m_msg_counter);
|
||||
return n1.m_msg_counter > n2.m_msg_counter;
|
||||
} else {
|
||||
return n1.m_time > n2.m_time;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const MessageBufferNode& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_BUFFERS_MESSAGEBUFFERNODE_HH__
|
||||
37
simulators/gem5/src/mem/ruby/buffers/SConscript
Normal file
37
simulators/gem5/src/mem/ruby/buffers/SConscript
Normal file
@ -0,0 +1,37 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
||||
# 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.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['PROTOCOL'] == 'None':
|
||||
Return()
|
||||
|
||||
Source('MessageBuffer.cc')
|
||||
Source('MessageBufferNode.cc')
|
||||
136
simulators/gem5/src/mem/ruby/common/Address.cc
Normal file
136
simulators/gem5/src/mem/ruby/common/Address.cc
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
physical_address_t
|
||||
Address::getLineAddress() const
|
||||
{
|
||||
return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH);
|
||||
}
|
||||
|
||||
physical_address_t
|
||||
Address::getOffset() const
|
||||
{
|
||||
return bitSelect(0, RubySystem::getBlockSizeBits() - 1);
|
||||
}
|
||||
|
||||
void
|
||||
Address::makeLineAddress()
|
||||
{
|
||||
m_address = maskLowOrderBits(RubySystem::getBlockSizeBits());
|
||||
}
|
||||
|
||||
// returns the next stride address based on line address
|
||||
void
|
||||
Address::makeNextStrideAddress(int stride)
|
||||
{
|
||||
m_address = maskLowOrderBits(RubySystem::getBlockSizeBits())
|
||||
+ RubySystem::getBlockSizeBytes()*stride;
|
||||
}
|
||||
|
||||
integer_t
|
||||
Address::memoryModuleIndex() const
|
||||
{
|
||||
integer_t index =
|
||||
bitSelect(RubySystem::getBlockSizeBits() +
|
||||
RubySystem::getMemorySizeBits(), ADDRESS_WIDTH);
|
||||
assert (index >= 0);
|
||||
return index;
|
||||
|
||||
// Index indexHighPortion =
|
||||
// address.bitSelect(MEMORY_SIZE_BITS - 1,
|
||||
// PAGE_SIZE_BITS + NUMBER_OF_MEMORY_MODULE_BITS);
|
||||
// Index indexLowPortion =
|
||||
// address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS - 1);
|
||||
//
|
||||
// Index index = indexLowPortion |
|
||||
// (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS));
|
||||
|
||||
/*
|
||||
Round-robin mapping of addresses, at page size granularity
|
||||
|
||||
ADDRESS_WIDTH MEMORY_SIZE_BITS PAGE_SIZE_BITS DATA_BLOCK_BITS
|
||||
| | | |
|
||||
\ / \ / \ / \ / 0
|
||||
-----------------------------------------------------------------------
|
||||
| unused |xxxxxxxxxxxxxxx| |xxxxxxxxxxxxxxx| |
|
||||
| |xxxxxxxxxxxxxxx| |xxxxxxxxxxxxxxx| |
|
||||
-----------------------------------------------------------------------
|
||||
indexHighPortion indexLowPortion
|
||||
<------->
|
||||
NUMBER_OF_MEMORY_MODULE_BITS
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
Address::print(std::ostream& out) const
|
||||
{
|
||||
using namespace std;
|
||||
out << "[" << hex << "0x" << m_address << "," << " line 0x"
|
||||
<< maskLowOrderBits(RubySystem::getBlockSizeBits()) << dec << "]"
|
||||
<< flush;
|
||||
}
|
||||
|
||||
void
|
||||
Address::output(std::ostream& out) const
|
||||
{
|
||||
// Note: this outputs addresses in the form "ffff", not "0xffff".
|
||||
// This code should always be able to write out addresses in a
|
||||
// format that can be read in by the below input() method. Please
|
||||
// don't change this without talking to Milo first.
|
||||
out << std::hex << m_address << std::dec;
|
||||
}
|
||||
|
||||
void
|
||||
Address::input(std::istream& in)
|
||||
{
|
||||
// Note: this only works with addresses in the form "ffff", not
|
||||
// "0xffff". This code should always be able to read in addresses
|
||||
// written out by the above output() method. Please don't change
|
||||
// this without talking to Milo first.
|
||||
in >> std::hex >> m_address >> std::dec;
|
||||
}
|
||||
|
||||
Address::Address(const Address& obj)
|
||||
{
|
||||
m_address = obj.m_address;
|
||||
}
|
||||
|
||||
Address&
|
||||
Address::operator=(const Address& obj)
|
||||
{
|
||||
if (this == &obj) {
|
||||
// assert(false);
|
||||
} else {
|
||||
m_address = obj.m_address;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
227
simulators/gem5/src/mem/ruby/common/Address.hh
Normal file
227
simulators/gem5/src/mem/ruby/common/Address.hh
Normal file
@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (c) 1999 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_COMMON_ADDRESS_HH__
|
||||
#define __MEM_RUBY_COMMON_ADDRESS_HH__
|
||||
|
||||
#include <cassert>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
#include "base/hashmap.hh"
|
||||
#include "mem/ruby/common/TypeDefines.hh"
|
||||
|
||||
const int ADDRESS_WIDTH = 64; // address width in bytes
|
||||
|
||||
class Address;
|
||||
typedef Address PhysAddress;
|
||||
typedef Address VirtAddress;
|
||||
|
||||
class Address
|
||||
{
|
||||
public:
|
||||
Address()
|
||||
: m_address(0)
|
||||
{ }
|
||||
|
||||
explicit
|
||||
Address(physical_address_t address)
|
||||
: m_address(address)
|
||||
{ }
|
||||
|
||||
Address(const Address& obj);
|
||||
Address& operator=(const Address& obj);
|
||||
|
||||
void setAddress(physical_address_t address) { m_address = address; }
|
||||
physical_address_t getAddress() const {return m_address;}
|
||||
// selects bits inclusive
|
||||
physical_address_t bitSelect(int small, int big) const;
|
||||
physical_address_t bitRemove(int small, int big) const;
|
||||
physical_address_t maskLowOrderBits(int number) const;
|
||||
physical_address_t maskHighOrderBits(int number) const;
|
||||
physical_address_t shiftLowOrderBits(int number) const;
|
||||
|
||||
physical_address_t getLineAddress() const;
|
||||
physical_address_t getOffset() const;
|
||||
void makeLineAddress();
|
||||
void makeNextStrideAddress(int stride);
|
||||
|
||||
int getBankSetNum() const;
|
||||
int getBankSetDist() const;
|
||||
|
||||
Index memoryModuleIndex() const;
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
void output(std::ostream& out) const;
|
||||
void input(std::istream& in);
|
||||
|
||||
void
|
||||
setOffset(int offset)
|
||||
{
|
||||
// first, zero out the offset bits
|
||||
makeLineAddress();
|
||||
m_address |= (physical_address_t) offset;
|
||||
}
|
||||
|
||||
private:
|
||||
physical_address_t m_address;
|
||||
};
|
||||
|
||||
inline Address
|
||||
line_address(const Address& addr)
|
||||
{
|
||||
Address temp(addr);
|
||||
temp.makeLineAddress();
|
||||
return temp;
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator<(const Address& obj1, const Address& obj2)
|
||||
{
|
||||
return obj1.getAddress() < obj2.getAddress();
|
||||
}
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const Address& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator==(const Address& obj1, const Address& obj2)
|
||||
{
|
||||
return (obj1.getAddress() == obj2.getAddress());
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator!=(const Address& obj1, const Address& obj2)
|
||||
{
|
||||
return (obj1.getAddress() != obj2.getAddress());
|
||||
}
|
||||
|
||||
// rips bits inclusive
|
||||
inline physical_address_t
|
||||
Address::bitSelect(int small, int big) const
|
||||
{
|
||||
physical_address_t mask;
|
||||
assert((unsigned)big >= (unsigned)small);
|
||||
|
||||
if (big >= ADDRESS_WIDTH - 1) {
|
||||
return (m_address >> small);
|
||||
} else {
|
||||
mask = ~((physical_address_t)~0 << (big + 1));
|
||||
// FIXME - this is slow to manipulate a 64-bit number using 32-bits
|
||||
physical_address_t partial = (m_address & mask);
|
||||
return (partial >> small);
|
||||
}
|
||||
}
|
||||
|
||||
// removes bits inclusive
|
||||
inline physical_address_t
|
||||
Address::bitRemove(int small, int big) const
|
||||
{
|
||||
physical_address_t mask;
|
||||
assert((unsigned)big >= (unsigned)small);
|
||||
|
||||
if (small >= ADDRESS_WIDTH - 1) {
|
||||
return m_address;
|
||||
} else if (big >= ADDRESS_WIDTH - 1) {
|
||||
mask = (physical_address_t)~0 >> small;
|
||||
return (m_address & mask);
|
||||
} else if (small == 0) {
|
||||
mask = (physical_address_t)~0 << big;
|
||||
return (m_address & mask);
|
||||
} else {
|
||||
mask = ~((physical_address_t)~0 << small);
|
||||
physical_address_t lower_bits = m_address & mask;
|
||||
mask = (physical_address_t)~0 << (big + 1);
|
||||
physical_address_t higher_bits = m_address & mask;
|
||||
|
||||
// Shift the valid high bits over the removed section
|
||||
higher_bits = higher_bits >> (big - small + 1);
|
||||
return (higher_bits | lower_bits);
|
||||
}
|
||||
}
|
||||
|
||||
inline physical_address_t
|
||||
Address::maskLowOrderBits(int number) const
|
||||
{
|
||||
physical_address_t mask;
|
||||
|
||||
if (number >= ADDRESS_WIDTH - 1) {
|
||||
mask = ~0;
|
||||
} else {
|
||||
mask = (physical_address_t)~0 << number;
|
||||
}
|
||||
return (m_address & mask);
|
||||
}
|
||||
|
||||
inline physical_address_t
|
||||
Address::maskHighOrderBits(int number) const
|
||||
{
|
||||
physical_address_t mask;
|
||||
|
||||
if (number >= ADDRESS_WIDTH - 1) {
|
||||
mask = ~0;
|
||||
} else {
|
||||
mask = (physical_address_t)~0 >> number;
|
||||
}
|
||||
return (m_address & mask);
|
||||
}
|
||||
|
||||
inline physical_address_t
|
||||
Address::shiftLowOrderBits(int number) const
|
||||
{
|
||||
return (m_address >> number);
|
||||
}
|
||||
|
||||
__hash_namespace_begin
|
||||
template <> struct hash<Address>
|
||||
{
|
||||
size_t
|
||||
operator()(const Address &s) const
|
||||
{
|
||||
return (size_t)s.getAddress();
|
||||
}
|
||||
};
|
||||
__hash_namespace_end
|
||||
|
||||
namespace std {
|
||||
template <> struct equal_to<Address>
|
||||
{
|
||||
bool
|
||||
operator()(const Address& s1, const Address& s2) const
|
||||
{
|
||||
return s1 == s2;
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
#endif // __MEM_RUBY_COMMON_ADDRESS_HH__
|
||||
117
simulators/gem5/src/mem/ruby/common/Consumer.hh
Normal file
117
simulators/gem5/src/mem/ruby/common/Consumer.hh
Normal file
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is the virtual base class of all classes that can be the
|
||||
* targets of wakeup events. There is only two methods, wakeup() and
|
||||
* print() and no data members.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_COMMON_CONSUMER_HH__
|
||||
#define __MEM_RUBY_COMMON_CONSUMER_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/eventqueue/RubyEventQueue.hh"
|
||||
|
||||
class MessageBuffer;
|
||||
|
||||
class Consumer
|
||||
{
|
||||
public:
|
||||
Consumer()
|
||||
: m_last_scheduled_wakeup(0), m_last_wakeup(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual
|
||||
~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&
|
||||
getLastScheduledWakeup() const
|
||||
{
|
||||
return m_last_scheduled_wakeup;
|
||||
}
|
||||
|
||||
void
|
||||
setLastScheduledWakeup(const Time& time)
|
||||
{
|
||||
m_last_scheduled_wakeup = time;
|
||||
}
|
||||
|
||||
bool
|
||||
alreadyScheduled(Time time)
|
||||
{
|
||||
return m_scheduled_wakeups.find(time) != m_scheduled_wakeups.end();
|
||||
}
|
||||
|
||||
void
|
||||
insertScheduledWakeupTime(Time time)
|
||||
{
|
||||
m_scheduled_wakeups.insert(time);
|
||||
}
|
||||
|
||||
void
|
||||
removeScheduledWakeupTime(Time time)
|
||||
{
|
||||
assert(alreadyScheduled(time));
|
||||
m_scheduled_wakeups.erase(time);
|
||||
}
|
||||
|
||||
private:
|
||||
Time m_last_scheduled_wakeup;
|
||||
std::set<Time> m_scheduled_wakeups;
|
||||
Time m_last_wakeup;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const Consumer& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_COMMON_CONSUMER_HH__
|
||||
100
simulators/gem5/src/mem/ruby/common/DataBlock.cc
Normal file
100
simulators/gem5/src/mem/ruby/common/DataBlock.cc
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "mem/ruby/common/DataBlock.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
DataBlock::DataBlock(const DataBlock &cp)
|
||||
{
|
||||
m_data = new uint8[RubySystem::getBlockSizeBytes()];
|
||||
memcpy(m_data, cp.m_data, RubySystem::getBlockSizeBytes());
|
||||
m_alloc = true;
|
||||
}
|
||||
|
||||
void
|
||||
DataBlock::alloc()
|
||||
{
|
||||
m_data = new uint8[RubySystem::getBlockSizeBytes()];
|
||||
m_alloc = true;
|
||||
clear();
|
||||
}
|
||||
|
||||
void
|
||||
DataBlock::clear()
|
||||
{
|
||||
memset(m_data, 0, RubySystem::getBlockSizeBytes());
|
||||
}
|
||||
|
||||
bool
|
||||
DataBlock::equal(const DataBlock& obj) const
|
||||
{
|
||||
return !memcmp(m_data, obj.m_data, RubySystem::getBlockSizeBytes());
|
||||
}
|
||||
|
||||
void
|
||||
DataBlock::print(std::ostream& out) const
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
int size = RubySystem::getBlockSizeBytes();
|
||||
out << "[ ";
|
||||
for (int i = 0; i < size; i++) {
|
||||
out << setw(2) << setfill('0') << hex << "0x" << (int)m_data[i] << " ";
|
||||
out << setfill(' ');
|
||||
}
|
||||
out << dec << "]" << flush;
|
||||
}
|
||||
|
||||
const uint8*
|
||||
DataBlock::getData(int offset, int len) const
|
||||
{
|
||||
assert(offset + len <= RubySystem::getBlockSizeBytes());
|
||||
return &m_data[offset];
|
||||
}
|
||||
|
||||
void
|
||||
DataBlock::setData(uint8* data, int offset, int len)
|
||||
{
|
||||
assert(offset + len <= RubySystem::getBlockSizeBytes());
|
||||
memcpy(&m_data[offset], data, len);
|
||||
}
|
||||
|
||||
DataBlock &
|
||||
DataBlock::operator=(const DataBlock & obj)
|
||||
{
|
||||
if (this == &obj) {
|
||||
// assert(false);
|
||||
} else {
|
||||
if (!m_alloc)
|
||||
m_data = new uint8[RubySystem::getBlockSizeBytes()];
|
||||
memcpy(m_data, obj.m_data, RubySystem::getBlockSizeBytes());
|
||||
m_alloc = true;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
114
simulators/gem5/src/mem/ruby/common/DataBlock.hh
Normal file
114
simulators/gem5/src/mem/ruby/common/DataBlock.hh
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_COMMON_DATABLOCK_HH__
|
||||
#define __MEM_RUBY_COMMON_DATABLOCK_HH__
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
#include "mem/ruby/common/TypeDefines.hh"
|
||||
|
||||
class DataBlock
|
||||
{
|
||||
public:
|
||||
DataBlock()
|
||||
{
|
||||
alloc();
|
||||
}
|
||||
|
||||
DataBlock(const DataBlock &cp);
|
||||
|
||||
~DataBlock()
|
||||
{
|
||||
if (m_alloc)
|
||||
delete [] m_data;
|
||||
}
|
||||
|
||||
DataBlock& operator=(const DataBlock& obj);
|
||||
|
||||
void assign(uint8* data);
|
||||
|
||||
void clear();
|
||||
uint8 getByte(int whichByte) const;
|
||||
const uint8* getData(int offset, int len) const;
|
||||
void setByte(int whichByte, uint8 data);
|
||||
void setData(uint8* data, int offset, int len);
|
||||
void copyPartial(const DataBlock & dblk, int offset, int len);
|
||||
bool equal(const DataBlock& obj) const;
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
void alloc();
|
||||
uint8* m_data;
|
||||
bool m_alloc;
|
||||
};
|
||||
|
||||
inline void
|
||||
DataBlock::assign(uint8* data)
|
||||
{
|
||||
if (m_alloc) {
|
||||
delete [] m_data;
|
||||
}
|
||||
m_data = data;
|
||||
m_alloc = false;
|
||||
}
|
||||
|
||||
inline uint8
|
||||
DataBlock::getByte(int whichByte) const
|
||||
{
|
||||
return m_data[whichByte];
|
||||
}
|
||||
|
||||
inline void
|
||||
DataBlock::setByte(int whichByte, uint8 data)
|
||||
{
|
||||
m_data[whichByte] = data;
|
||||
}
|
||||
|
||||
inline void
|
||||
DataBlock::copyPartial(const DataBlock & dblk, int offset, int len)
|
||||
{
|
||||
setData(&dblk.m_data[offset], offset, len);
|
||||
}
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const DataBlock& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator==(const DataBlock& obj1,const DataBlock& obj2)
|
||||
{
|
||||
return obj1.equal(obj2);
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_COMMON_DATABLOCK_HH__
|
||||
33
simulators/gem5/src/mem/ruby/common/Global.cc
Normal file
33
simulators/gem5/src/mem/ruby/common/Global.cc
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
|
||||
RubyEventQueue* g_eventQueue_ptr = 0;
|
||||
RubySystem* g_system_ptr = 0;
|
||||
|
||||
48
simulators/gem5/src/mem/ruby/common/Global.hh
Normal file
48
simulators/gem5/src/mem/ruby/common/Global.hh
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_COMMON_GLOBAL_HH__
|
||||
#define __MEM_RUBY_COMMON_GLOBAL_HH__
|
||||
|
||||
#include "base/str.hh"
|
||||
|
||||
class RubyEventQueue;
|
||||
extern RubyEventQueue* g_eventQueue_ptr;
|
||||
|
||||
class RubySystem;
|
||||
extern RubySystem* g_system_ptr;
|
||||
|
||||
// FIXME: this is required by the contructor of Directory_Entry.hh.
|
||||
// It can't go into slicc_util.hh because it opens a can of ugly worms
|
||||
extern inline int max_tokens()
|
||||
{
|
||||
return 1024;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_COMMON_GLOBAL_HH__
|
||||
|
||||
194
simulators/gem5/src/mem/ruby/common/Histogram.cc
Normal file
194
simulators/gem5/src/mem/ruby/common/Histogram.cc
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
|
||||
#include "base/intmath.hh"
|
||||
#include "mem/ruby/common/Histogram.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Histogram::Histogram(int binsize, int bins)
|
||||
{
|
||||
m_binsize = binsize;
|
||||
m_bins = bins;
|
||||
clear();
|
||||
}
|
||||
|
||||
Histogram::~Histogram()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Histogram::clear(int binsize, int bins)
|
||||
{
|
||||
m_binsize = binsize;
|
||||
clear(bins);
|
||||
}
|
||||
|
||||
void
|
||||
Histogram::clear(int bins)
|
||||
{
|
||||
m_bins = bins;
|
||||
m_largest_bin = 0;
|
||||
m_max = 0;
|
||||
m_data.resize(m_bins);
|
||||
for (int i = 0; i < m_bins; i++) {
|
||||
m_data[i] = 0;
|
||||
}
|
||||
m_count = 0;
|
||||
m_max = 0;
|
||||
|
||||
m_sumSamples = 0;
|
||||
m_sumSquaredSamples = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Histogram::add(int64 value)
|
||||
{
|
||||
assert(value >= 0);
|
||||
m_max = max(m_max, value);
|
||||
m_count++;
|
||||
|
||||
m_sumSamples += value;
|
||||
m_sumSquaredSamples += (value*value);
|
||||
|
||||
int index;
|
||||
if (m_binsize == -1) {
|
||||
// This is a log base 2 histogram
|
||||
if (value == 0) {
|
||||
index = 0;
|
||||
} else {
|
||||
index = floorLog2(value) + 1;
|
||||
if (index >= m_data.size()) {
|
||||
index = m_data.size() - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// This is a linear histogram
|
||||
while (m_max >= (m_bins * m_binsize)) {
|
||||
for (int i = 0; i < m_bins/2; i++) {
|
||||
m_data[i] = m_data[i*2] + m_data[i*2 + 1];
|
||||
}
|
||||
for (int i = m_bins/2; i < m_bins; i++) {
|
||||
m_data[i] = 0;
|
||||
}
|
||||
m_binsize *= 2;
|
||||
}
|
||||
index = value/m_binsize;
|
||||
}
|
||||
assert(index >= 0);
|
||||
m_data[index]++;
|
||||
m_largest_bin = max(m_largest_bin, index);
|
||||
}
|
||||
|
||||
void
|
||||
Histogram::add(const Histogram& hist)
|
||||
{
|
||||
assert(hist.getBins() == m_bins);
|
||||
assert(hist.getBinSize() == -1); // assume log histogram
|
||||
assert(m_binsize == -1);
|
||||
|
||||
for (int j = 0; j < hist.getData(0); j++) {
|
||||
add(0);
|
||||
}
|
||||
|
||||
for (int i = 1; i < m_bins; i++) {
|
||||
for (int j = 0; j < hist.getData(i); j++) {
|
||||
add(1<<(i-1)); // account for the + 1 index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Computation of standard deviation of samples a1, a2, ... aN
|
||||
// variance = [SUM {ai^2} - (SUM {ai})^2/N]/(N-1)
|
||||
// std deviation equals square root of variance
|
||||
double
|
||||
Histogram::getStandardDeviation() const
|
||||
{
|
||||
if (m_count <= 1)
|
||||
return 0.0;
|
||||
|
||||
double variance =
|
||||
(double)(m_sumSquaredSamples - m_sumSamples * m_sumSamples / m_count)
|
||||
/ (m_count - 1);
|
||||
return sqrt(variance);
|
||||
}
|
||||
|
||||
void
|
||||
Histogram::print(ostream& out) const
|
||||
{
|
||||
printWithMultiplier(out, 1.0);
|
||||
}
|
||||
|
||||
void
|
||||
Histogram::printPercent(ostream& out) const
|
||||
{
|
||||
if (m_count == 0) {
|
||||
printWithMultiplier(out, 0.0);
|
||||
} else {
|
||||
printWithMultiplier(out, 100.0 / double(m_count));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Histogram::printWithMultiplier(ostream& out, double multiplier) const
|
||||
{
|
||||
if (m_binsize == -1) {
|
||||
out << "[binsize: log2 ";
|
||||
} else {
|
||||
out << "[binsize: " << m_binsize << " ";
|
||||
}
|
||||
out << "max: " << m_max << " ";
|
||||
out << "count: " << m_count << " ";
|
||||
// out << "total: " << m_sumSamples << " ";
|
||||
if (m_count == 0) {
|
||||
out << "average: NaN |";
|
||||
out << "standard deviation: NaN |";
|
||||
} else {
|
||||
out << "average: " << setw(5) << ((double) m_sumSamples)/m_count
|
||||
<< " | ";
|
||||
out << "standard deviation: " << getStandardDeviation() << " |";
|
||||
}
|
||||
for (int i = 0; i < m_bins && i <= m_largest_bin; i++) {
|
||||
if (multiplier == 1.0) {
|
||||
out << " " << m_data[i];
|
||||
} else {
|
||||
out << " " << double(m_data[i]) * multiplier;
|
||||
}
|
||||
}
|
||||
out << " ]";
|
||||
}
|
||||
|
||||
bool
|
||||
node_less_then_eq(const Histogram* n1, const Histogram* n2)
|
||||
{
|
||||
return (n1->size() > n2->size());
|
||||
}
|
||||
82
simulators/gem5/src/mem/ruby/common/Histogram.hh
Normal file
82
simulators/gem5/src/mem/ruby/common/Histogram.hh
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_COMMON_HISTOGRAM_HH__
|
||||
#define __MEM_RUBY_COMMON_HISTOGRAM_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/TypeDefines.hh"
|
||||
|
||||
class Histogram
|
||||
{
|
||||
public:
|
||||
Histogram(int binsize = 1, int bins = 50);
|
||||
~Histogram();
|
||||
|
||||
void add(int64 value);
|
||||
void add(const Histogram& hist);
|
||||
void clear() { clear(m_bins); }
|
||||
void clear(int bins);
|
||||
void clear(int binsize, int bins);
|
||||
int64 size() const { return m_count; }
|
||||
int getBins() const { return m_bins; }
|
||||
int getBinSize() const { return m_binsize; }
|
||||
int64 getTotal() const { return m_sumSamples; }
|
||||
int64 getData(int index) const { return m_data[index]; }
|
||||
|
||||
void printWithMultiplier(std::ostream& out, double multiplier) const;
|
||||
void printPercent(std::ostream& out) const;
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
std::vector<int64> m_data;
|
||||
int64 m_max; // the maximum value seen so far
|
||||
int64 m_count; // the number of elements added
|
||||
int m_binsize; // the size of each bucket
|
||||
int m_bins; // the number of buckets
|
||||
int m_largest_bin; // the largest bin used
|
||||
|
||||
int64 m_sumSamples; // the sum of all samples
|
||||
int64 m_sumSquaredSamples; // the sum of the square of all samples
|
||||
|
||||
double getStandardDeviation() const;
|
||||
};
|
||||
|
||||
bool node_less_then_eq(const Histogram* n1, const Histogram* n2);
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const Histogram& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_COMMON_HISTOGRAM_HH__
|
||||
276
simulators/gem5/src/mem/ruby/common/NetDest.cc
Normal file
276
simulators/gem5/src/mem/ruby/common/NetDest.cc
Normal file
@ -0,0 +1,276 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "mem/ruby/common/NetDest.hh"
|
||||
|
||||
NetDest::NetDest()
|
||||
{
|
||||
resize();
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::add(MachineID newElement)
|
||||
{
|
||||
m_bits[vecIndex(newElement)].add(bitIndex(newElement.num));
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::addNetDest(const NetDest& netDest)
|
||||
{
|
||||
assert(m_bits.size() == netDest.getSize());
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
m_bits[i].addSet(netDest.m_bits[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::addRandom()
|
||||
{
|
||||
int i = random()%m_bits.size();
|
||||
m_bits[i].addRandom();
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::setNetDest(MachineType machine, const Set& set)
|
||||
{
|
||||
// assure that there is only one set of destinations for this machine
|
||||
assert(MachineType_base_level((MachineType)(machine + 1)) -
|
||||
MachineType_base_level(machine) == 1);
|
||||
m_bits[MachineType_base_level(machine)] = set;
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::remove(MachineID oldElement)
|
||||
{
|
||||
m_bits[vecIndex(oldElement)].remove(bitIndex(oldElement.num));
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::removeNetDest(const NetDest& netDest)
|
||||
{
|
||||
assert(m_bits.size() == netDest.getSize());
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
m_bits[i].removeSet(netDest.m_bits[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::clear()
|
||||
{
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
m_bits[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::broadcast()
|
||||
{
|
||||
for (MachineType machine = MachineType_FIRST;
|
||||
machine < MachineType_NUM; ++machine) {
|
||||
broadcast(machine);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::broadcast(MachineType machineType)
|
||||
{
|
||||
for (int i = 0; i < MachineType_base_count(machineType); i++) {
|
||||
MachineID mach = {machineType, i};
|
||||
add(mach);
|
||||
}
|
||||
}
|
||||
|
||||
//For Princeton Network
|
||||
std::vector<NodeID>
|
||||
NetDest::getAllDest()
|
||||
{
|
||||
std::vector<NodeID> dest;
|
||||
dest.clear();
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
for (int j = 0; j < m_bits[i].getSize(); j++) {
|
||||
if (m_bits[i].isElement(j)) {
|
||||
int id = MachineType_base_number((MachineType)i) + j;
|
||||
dest.push_back((NodeID)id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
int
|
||||
NetDest::count() const
|
||||
{
|
||||
int counter = 0;
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
counter += m_bits[i].count();
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
NodeID
|
||||
NetDest::elementAt(MachineID index)
|
||||
{
|
||||
return m_bits[vecIndex(index)].elementAt(bitIndex(index.num));
|
||||
}
|
||||
|
||||
MachineID
|
||||
NetDest::smallestElement() const
|
||||
{
|
||||
assert(count() > 0);
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
for (int j = 0; j < m_bits[i].getSize(); j++) {
|
||||
if (m_bits[i].isElement(j)) {
|
||||
MachineID mach = {MachineType_from_base_level(i), j};
|
||||
return mach;
|
||||
}
|
||||
}
|
||||
}
|
||||
panic("No smallest element of an empty set.");
|
||||
}
|
||||
|
||||
MachineID
|
||||
NetDest::smallestElement(MachineType machine) const
|
||||
{
|
||||
int size = m_bits[MachineType_base_level(machine)].getSize();
|
||||
for (int j = 0; j < size; j++) {
|
||||
if (m_bits[MachineType_base_level(machine)].isElement(j)) {
|
||||
MachineID mach = {machine, j};
|
||||
return mach;
|
||||
}
|
||||
}
|
||||
|
||||
panic("No smallest element of given MachineType.");
|
||||
}
|
||||
|
||||
// Returns true iff all bits are set
|
||||
bool
|
||||
NetDest::isBroadcast() const
|
||||
{
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
if (!m_bits[i].isBroadcast()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true iff no bits are set
|
||||
bool
|
||||
NetDest::isEmpty() const
|
||||
{
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
if (!m_bits[i].isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns the logical OR of "this" set and orNetDest
|
||||
NetDest
|
||||
NetDest::OR(const NetDest& orNetDest) const
|
||||
{
|
||||
assert(m_bits.size() == orNetDest.getSize());
|
||||
NetDest result;
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
result.m_bits[i] = m_bits[i].OR(orNetDest.m_bits[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// returns the logical AND of "this" set and andNetDest
|
||||
NetDest
|
||||
NetDest::AND(const NetDest& andNetDest) const
|
||||
{
|
||||
assert(m_bits.size() == andNetDest.getSize());
|
||||
NetDest result;
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
result.m_bits[i] = m_bits[i].AND(andNetDest.m_bits[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Returns true if the intersection of the two sets is non-empty
|
||||
bool
|
||||
NetDest::intersectionIsNotEmpty(const NetDest& other_netDest) const
|
||||
{
|
||||
assert(m_bits.size() == other_netDest.getSize());
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
if (!m_bits[i].intersectionIsEmpty(other_netDest.m_bits[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
NetDest::isSuperset(const NetDest& test) const
|
||||
{
|
||||
assert(m_bits.size() == test.getSize());
|
||||
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
if (!m_bits[i].isSuperset(test.m_bits[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
NetDest::isElement(MachineID element) const
|
||||
{
|
||||
return ((m_bits[vecIndex(element)])).isElement(bitIndex(element.num));
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::resize()
|
||||
{
|
||||
m_bits.resize(MachineType_base_level(MachineType_NUM));
|
||||
assert(m_bits.size() == MachineType_NUM);
|
||||
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
m_bits[i].setSize(MachineType_base_count((MachineType)i));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetDest::print(std::ostream& out) const
|
||||
{
|
||||
out << "[NetDest (" << m_bits.size() << ") ";
|
||||
|
||||
for (int i = 0; i < m_bits.size(); i++) {
|
||||
for (int j = 0; j < m_bits[i].getSize(); j++) {
|
||||
out << (bool) m_bits[i].isElement(j) << " ";
|
||||
}
|
||||
out << " - ";
|
||||
}
|
||||
out << "]";
|
||||
}
|
||||
|
||||
132
simulators/gem5/src/mem/ruby/common/NetDest.hh
Normal file
132
simulators/gem5/src/mem/ruby/common/NetDest.hh
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// NetDest specifies the network destination of a NetworkMessage
|
||||
// This is backward compatible with the Set class that was previously
|
||||
// used to specify network destinations.
|
||||
// NetDest supports both node networks and component networks
|
||||
|
||||
#ifndef __MEM_RUBY_COMMON_NETDEST_HH__
|
||||
#define __MEM_RUBY_COMMON_NETDEST_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "debug/RubyMemory.hh"
|
||||
#include "mem/protocol/MachineType.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/common/Set.hh"
|
||||
#include "mem/ruby/system/MachineID.hh"
|
||||
|
||||
class NetDest
|
||||
{
|
||||
public:
|
||||
// Constructors
|
||||
// creates and empty set
|
||||
NetDest();
|
||||
explicit NetDest(int bit_size);
|
||||
|
||||
NetDest& operator=(const Set& obj);
|
||||
|
||||
~NetDest()
|
||||
{ }
|
||||
|
||||
void add(MachineID newElement);
|
||||
void addNetDest(const NetDest& netDest);
|
||||
void addRandom();
|
||||
void setNetDest(MachineType machine, const Set& set);
|
||||
void remove(MachineID oldElement);
|
||||
void removeNetDest(const NetDest& netDest);
|
||||
void clear();
|
||||
void broadcast();
|
||||
void broadcast(MachineType machine);
|
||||
int count() const;
|
||||
bool isEqual(const NetDest& netDest);
|
||||
|
||||
// return the logical OR of this netDest and orNetDest
|
||||
NetDest OR(const NetDest& orNetDest) const;
|
||||
|
||||
// return the logical AND of this netDest and andNetDest
|
||||
NetDest AND(const NetDest& andNetDest) const;
|
||||
|
||||
// Returns true if the intersection of the two netDests is non-empty
|
||||
bool intersectionIsNotEmpty(const NetDest& other_netDest) const;
|
||||
|
||||
// Returns true if the intersection of the two netDests is empty
|
||||
bool intersectionIsEmpty(const NetDest& other_netDest) const;
|
||||
|
||||
bool isSuperset(const NetDest& test) const;
|
||||
bool isSubset(const NetDest& test) const { return test.isSuperset(*this); }
|
||||
bool isElement(MachineID element) const;
|
||||
bool isBroadcast() const;
|
||||
bool isEmpty() const;
|
||||
|
||||
// For Princeton Network
|
||||
std::vector<NodeID> getAllDest();
|
||||
|
||||
MachineID smallestElement() const;
|
||||
MachineID smallestElement(MachineType machine) const;
|
||||
|
||||
void resize();
|
||||
int getSize() const { return m_bits.size(); }
|
||||
|
||||
// get element for a index
|
||||
NodeID elementAt(MachineID index);
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
// returns a value >= MachineType_base_level("this machine")
|
||||
// and < MachineType_base_level("next highest machine")
|
||||
int
|
||||
vecIndex(MachineID m) const
|
||||
{
|
||||
int vec_index = MachineType_base_level(m.type);
|
||||
assert(vec_index < m_bits.size());
|
||||
return vec_index;
|
||||
}
|
||||
|
||||
NodeID
|
||||
bitIndex(NodeID index) const
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
std::vector<Set> m_bits; // a vector of bit vectors - i.e. Sets
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const NetDest& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_COMMON_NETDEST_HH__
|
||||
|
||||
42
simulators/gem5/src/mem/ruby/common/SConscript
Normal file
42
simulators/gem5/src/mem/ruby/common/SConscript
Normal file
@ -0,0 +1,42 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
||||
# 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.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['PROTOCOL'] == 'None':
|
||||
Return()
|
||||
|
||||
Source('Address.cc')
|
||||
Source('DataBlock.cc')
|
||||
Source('Global.cc')
|
||||
Source('Histogram.cc')
|
||||
Source('NetDest.cc')
|
||||
Source('Set.cc')
|
||||
Source('SubBlock.cc')
|
||||
361
simulators/gem5/src/mem/ruby/common/Set.cc
Normal file
361
simulators/gem5/src/mem/ruby/common/Set.cc
Normal file
@ -0,0 +1,361 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// modified (rewritten) 05/20/05 by Dan Gibson to accomimdate FASTER
|
||||
// >32 bit set sizes
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "base/misc.hh"
|
||||
#include "mem/ruby/common/Set.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
Set::Set()
|
||||
{
|
||||
m_p_nArray = NULL;
|
||||
m_nArrayLen = 0;
|
||||
m_nSize = 0;
|
||||
}
|
||||
|
||||
Set::Set(const Set& obj)
|
||||
{
|
||||
m_p_nArray = NULL;
|
||||
setSize(obj.m_nSize);
|
||||
|
||||
// copy from the host to this array
|
||||
for (int i = 0; i < m_nArrayLen; i++)
|
||||
m_p_nArray[i] = obj.m_p_nArray[i];
|
||||
}
|
||||
|
||||
Set::Set(int size)
|
||||
{
|
||||
m_p_nArray = NULL;
|
||||
m_nArrayLen = 0;
|
||||
m_nSize = 0;
|
||||
if (size > 0)
|
||||
setSize(size);
|
||||
}
|
||||
|
||||
Set::~Set()
|
||||
{
|
||||
if (m_p_nArray && m_p_nArray != &m_p_nArray_Static[0])
|
||||
delete [] m_p_nArray;
|
||||
m_p_nArray = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Set::clearExcess()
|
||||
{
|
||||
// now just ensure that no bits over the maximum size were set
|
||||
#ifdef _LP64
|
||||
long mask = 0x7FFFFFFFFFFFFFFF;
|
||||
#else
|
||||
long mask = 0x7FFFFFFF;
|
||||
#endif
|
||||
|
||||
// the number of populated spaces in the higest-order array slot
|
||||
// is: m_nSize % LONG_BITS, so the uppermost LONG_BITS -
|
||||
// m_nSize%64 bits should be cleared
|
||||
if ((m_nSize % LONG_BITS) != 0) {
|
||||
for (int j = 0; j < 64 - (m_nSize & INDEX_MASK); j++) {
|
||||
m_p_nArray[m_nArrayLen - 1] &= mask;
|
||||
mask = mask >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function should set all the bits in the current set that are
|
||||
* already set in the parameter set
|
||||
*/
|
||||
void
|
||||
Set::addSet(const Set& set)
|
||||
{
|
||||
assert(getSize()==set.getSize());
|
||||
for (int i = 0; i < m_nArrayLen; i++)
|
||||
m_p_nArray[i] |= set.m_p_nArray[i];
|
||||
}
|
||||
|
||||
/*
|
||||
* This function should randomly assign 1 to the bits in the set--it
|
||||
* should not clear the bits bits first, though?
|
||||
*/
|
||||
void
|
||||
Set::addRandom()
|
||||
{
|
||||
|
||||
for (int i = 0; i < m_nArrayLen; i++) {
|
||||
// this ensures that all 32 bits are subject to random effects,
|
||||
// as RAND_MAX typically = 0x7FFFFFFF
|
||||
m_p_nArray[i] |= random() ^ (random() << 4);
|
||||
}
|
||||
clearExcess();
|
||||
}
|
||||
|
||||
/*
|
||||
* This function clears bits that are =1 in the parameter set
|
||||
*/
|
||||
void
|
||||
Set::removeSet(const Set& set)
|
||||
{
|
||||
assert(m_nSize == set.m_nSize);
|
||||
for (int i = 0; i < m_nArrayLen; i++)
|
||||
m_p_nArray[i] &= ~set.m_p_nArray[i];
|
||||
}
|
||||
|
||||
/*
|
||||
* this function sets all bits in the set
|
||||
*/
|
||||
void
|
||||
Set::broadcast()
|
||||
{
|
||||
for (int i = 0; i < m_nArrayLen; i++)
|
||||
m_p_nArray[i] = -1; // note that -1 corresponds to all 1's in 2's comp.
|
||||
|
||||
clearExcess();
|
||||
}
|
||||
|
||||
/*
|
||||
* This function returns the population count of 1's in the set
|
||||
*/
|
||||
int
|
||||
Set::count() const
|
||||
{
|
||||
int counter = 0;
|
||||
long mask;
|
||||
|
||||
for (int i = 0; i < m_nArrayLen; i++) {
|
||||
mask = (long)0x01;
|
||||
|
||||
for (int j = 0; j < LONG_BITS; j++) {
|
||||
// FIXME - significant performance loss when array
|
||||
// population << LONG_BITS
|
||||
if ((m_p_nArray[i] & mask) != 0) {
|
||||
counter++;
|
||||
}
|
||||
mask = mask << 1;
|
||||
}
|
||||
}
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function checks for set equality
|
||||
*/
|
||||
bool
|
||||
Set::isEqual(const Set& set) const
|
||||
{
|
||||
assert(m_nSize == set.m_nSize);
|
||||
|
||||
for (int i = 0; i < m_nArrayLen; i++)
|
||||
if (m_p_nArray[i] != set.m_p_nArray[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function returns the NodeID (int) of the least set bit
|
||||
*/
|
||||
NodeID
|
||||
Set::smallestElement() const
|
||||
{
|
||||
assert(count() > 0);
|
||||
long x;
|
||||
for (int i = 0; i < m_nArrayLen; i++) {
|
||||
if (m_p_nArray[i] != 0) {
|
||||
// the least-set bit must be in here
|
||||
x = m_p_nArray[i];
|
||||
|
||||
for (int j = 0; j < LONG_BITS; j++) {
|
||||
if (x & (unsigned long)1) {
|
||||
return LONG_BITS * i + j;
|
||||
}
|
||||
|
||||
x = x >> 1;
|
||||
}
|
||||
|
||||
panic("No smallest element of an empty set.");
|
||||
}
|
||||
}
|
||||
|
||||
panic("No smallest element of an empty set.");
|
||||
}
|
||||
|
||||
/*
|
||||
* this function returns true iff all bits are set
|
||||
*/
|
||||
bool
|
||||
Set::isBroadcast() const
|
||||
{
|
||||
// check the fully-loaded words by equal to 0xffffffff
|
||||
// only the last word may not be fully loaded, it is not
|
||||
// fully loaded iff m_nSize % 32 or 64 !=0 => fully loaded iff
|
||||
// m_nSize % 32 or 64 == 0
|
||||
|
||||
int max = (m_nSize % LONG_BITS) == 0 ? m_nArrayLen : m_nArrayLen - 1;
|
||||
for (int i = 0; i < max; i++) {
|
||||
if (m_p_nArray[i] != -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// now check the last word, which may not be fully loaded
|
||||
long mask = 1;
|
||||
for (int j = 0; j < (m_nSize % LONG_BITS); j++) {
|
||||
if ((mask & m_p_nArray[m_nArrayLen-1]) == 0) {
|
||||
return false;
|
||||
}
|
||||
mask = mask << 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* this function returns true iff no bits are set
|
||||
*/
|
||||
bool
|
||||
Set::isEmpty() const
|
||||
{
|
||||
// here we can simply check if all = 0, since we ensure
|
||||
// that "extra slots" are all zero
|
||||
for (int i = 0; i < m_nArrayLen ; i++)
|
||||
if (m_p_nArray[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns the logical OR of "this" set and orSet
|
||||
Set
|
||||
Set::OR(const Set& orSet) const
|
||||
{
|
||||
Set result(m_nSize);
|
||||
assert(m_nSize == orSet.m_nSize);
|
||||
for (int i = 0; i < m_nArrayLen; i++)
|
||||
result.m_p_nArray[i] = m_p_nArray[i] | orSet.m_p_nArray[i];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// returns the logical AND of "this" set and andSet
|
||||
Set
|
||||
Set::AND(const Set& andSet) const
|
||||
{
|
||||
Set result(m_nSize);
|
||||
assert(m_nSize == andSet.m_nSize);
|
||||
|
||||
for (int i = 0; i < m_nArrayLen; i++) {
|
||||
result.m_p_nArray[i] = m_p_nArray[i] & andSet.m_p_nArray[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns false if a bit is set in the parameter set that is NOT set
|
||||
* in this set
|
||||
*/
|
||||
bool
|
||||
Set::isSuperset(const Set& test) const
|
||||
{
|
||||
assert(m_nSize == test.m_nSize);
|
||||
|
||||
for (int i = 0; i < m_nArrayLen; i++)
|
||||
if (((test.m_p_nArray[i] & m_p_nArray[i]) | ~test.m_p_nArray[i]) != -1)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Set::setSize(int size)
|
||||
{
|
||||
m_nSize = size;
|
||||
m_nArrayLen = (m_nSize + LONG_BITS - 1) / LONG_BITS;
|
||||
|
||||
// decide whether to use dynamic or static alloction
|
||||
if (m_nArrayLen <= NUMBER_WORDS_PER_SET) {
|
||||
// constant defined in RubySystem.hh
|
||||
// its OK to use the static allocation, and it will
|
||||
// probably be faster (as m_nArrayLen is already in the
|
||||
// cache and they will probably share the same cache line)
|
||||
|
||||
// if switching from dyanamic to static allocation (which
|
||||
// is probably rare, but why not be complete?), must delete
|
||||
// the dynamically allocated space
|
||||
if (m_p_nArray && m_p_nArray != &m_p_nArray_Static[0])
|
||||
delete [] m_p_nArray;
|
||||
|
||||
m_p_nArray = &m_p_nArray_Static[0];
|
||||
} else {
|
||||
// can't use static allocation...simply not enough room
|
||||
// so dynamically allocate some space
|
||||
if (m_p_nArray && m_p_nArray != &m_p_nArray_Static[0])
|
||||
delete [] m_p_nArray;
|
||||
|
||||
m_p_nArray = new long[m_nArrayLen];
|
||||
}
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
Set&
|
||||
Set::operator=(const Set& obj)
|
||||
{
|
||||
if (this != &obj) {
|
||||
// resize this item
|
||||
setSize(obj.getSize());
|
||||
|
||||
// copy the elements from obj to this
|
||||
for (int i = 0; i < m_nArrayLen; i++)
|
||||
m_p_nArray[i] = obj.m_p_nArray[i];
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
Set::print(std::ostream& out) const
|
||||
{
|
||||
if (!m_p_nArray) {
|
||||
out << "[Set {Empty}]";
|
||||
return;
|
||||
}
|
||||
|
||||
char buff[24];
|
||||
out << "[Set (" << m_nSize << ")";
|
||||
for (int i = m_nArrayLen - 1; i >= 0; i--) {
|
||||
csprintf(buff," 0x%08X", m_p_nArray[i]);
|
||||
out << buff;
|
||||
}
|
||||
out << " ]";
|
||||
}
|
||||
167
simulators/gem5/src/mem/ruby/common/Set.hh
Normal file
167
simulators/gem5/src/mem/ruby/common/Set.hh
Normal file
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// modified by Dan Gibson on 05/20/05 to accomidate FASTER
|
||||
// >32 set lengths, using an array of ints w/ 32 bits/int
|
||||
|
||||
#ifndef __MEM_RUBY_COMMON_SET_HH__
|
||||
#define __MEM_RUBY_COMMON_SET_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#include "mem/ruby/common/TypeDefines.hh"
|
||||
|
||||
/*
|
||||
* This defines the number of longs (32-bits on 32 bit machines,
|
||||
* 64-bit on 64-bit AMD machines) to use to hold the set...
|
||||
* the default is 4, allowing 128 or 256 different members
|
||||
* of the set.
|
||||
*
|
||||
* This should never need to be changed for correctness reasons,
|
||||
* though increasing it will increase performance for larger
|
||||
* set sizes at the cost of a (much) larger memory footprint
|
||||
*
|
||||
*/
|
||||
const int NUMBER_WORDS_PER_SET = 1;
|
||||
|
||||
class Set
|
||||
{
|
||||
private:
|
||||
int m_nSize; // the number of bits in this set
|
||||
int m_nArrayLen; // the number of 32-bit words that are
|
||||
// held in the array
|
||||
|
||||
// Changed 5/24/05 for static allocation of array
|
||||
// note that "long" corresponds to 32 bits on a 32-bit machine,
|
||||
// 64 bits if the -m64 parameter is passed to g++, which it is
|
||||
// for an AMD opteron under our configuration
|
||||
|
||||
long *m_p_nArray; // an word array to hold the bits in the set
|
||||
long m_p_nArray_Static[NUMBER_WORDS_PER_SET];
|
||||
|
||||
static const int LONG_BITS = std::numeric_limits<long>::digits + 1;
|
||||
static const int INDEX_SHIFT = LONG_BITS == 64 ? 6 : 5;
|
||||
static const int INDEX_MASK = (1 << INDEX_SHIFT) - 1;
|
||||
|
||||
void clearExcess();
|
||||
|
||||
public:
|
||||
Set();
|
||||
Set(int size);
|
||||
Set(const Set& obj);
|
||||
~Set();
|
||||
|
||||
Set& operator=(const Set& obj);
|
||||
|
||||
void
|
||||
add(NodeID index)
|
||||
{
|
||||
m_p_nArray[index >> INDEX_SHIFT] |=
|
||||
(((unsigned long) 1) << (index & INDEX_MASK));
|
||||
}
|
||||
|
||||
void addSet(const Set& set);
|
||||
void addRandom();
|
||||
|
||||
void
|
||||
remove(NodeID index)
|
||||
{
|
||||
m_p_nArray[index >> INDEX_SHIFT] &=
|
||||
~(((unsigned long)1) << (index & INDEX_MASK));
|
||||
}
|
||||
|
||||
void removeSet(const Set& set);
|
||||
|
||||
void
|
||||
clear()
|
||||
{
|
||||
for (int i = 0; i < m_nArrayLen; i++)
|
||||
m_p_nArray[i] = 0;
|
||||
}
|
||||
|
||||
void broadcast();
|
||||
int count() const;
|
||||
bool isEqual(const Set& set) const;
|
||||
|
||||
// return the logical OR of this set and orSet
|
||||
Set OR(const Set& orSet) const;
|
||||
|
||||
// return the logical AND of this set and andSet
|
||||
Set AND(const Set& andSet) const;
|
||||
|
||||
// Returns true if the intersection of the two sets is empty
|
||||
bool
|
||||
intersectionIsEmpty(const Set& other_set) const
|
||||
{
|
||||
for (int i = 0; i < m_nArrayLen; i++)
|
||||
if (m_p_nArray[i] & other_set.m_p_nArray[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isSuperset(const Set& test) const;
|
||||
bool isSubset(const Set& test) const { return test.isSuperset(*this); }
|
||||
|
||||
bool
|
||||
isElement(NodeID element) const
|
||||
{
|
||||
return (m_p_nArray[element>>INDEX_SHIFT] &
|
||||
(((unsigned long)1) << (element & INDEX_MASK))) != 0;
|
||||
}
|
||||
|
||||
bool isBroadcast() const;
|
||||
bool isEmpty() const;
|
||||
|
||||
NodeID smallestElement() const;
|
||||
|
||||
void setSize(int size);
|
||||
|
||||
NodeID
|
||||
elementAt(int index) const
|
||||
{
|
||||
if (isElement(index))
|
||||
return (NodeID)true;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getSize() const { return m_nSize; }
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const Set& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_COMMON_SET_HH__
|
||||
73
simulators/gem5/src/mem/ruby/common/SubBlock.cc
Normal file
73
simulators/gem5/src/mem/ruby/common/SubBlock.cc
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "base/stl_helpers.hh"
|
||||
#include "mem/ruby/common/SubBlock.hh"
|
||||
|
||||
using m5::stl_helpers::operator<<;
|
||||
|
||||
SubBlock::SubBlock(const Address& addr, int size)
|
||||
{
|
||||
m_address = addr;
|
||||
resize(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
setByte(i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SubBlock::internalMergeFrom(const DataBlock& data)
|
||||
{
|
||||
int size = getSize();
|
||||
assert(size > 0);
|
||||
int offset = m_address.getOffset();
|
||||
for (int i = 0; i < size; i++) {
|
||||
this->setByte(i, data.getByte(offset + i));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SubBlock::internalMergeTo(DataBlock& data) const
|
||||
{
|
||||
int size = getSize();
|
||||
assert(size > 0);
|
||||
int offset = m_address.getOffset();
|
||||
for (int i = 0; i < size; i++) {
|
||||
// This will detect crossing a cache line boundary
|
||||
data.setByte(offset + i, this->getByte(i));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SubBlock::print(std::ostream& out) const
|
||||
{
|
||||
out << "[" << m_address << ", " << getSize() << ", " << m_data << "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
82
simulators/gem5/src/mem/ruby/common/SubBlock.hh
Normal file
82
simulators/gem5/src/mem/ruby/common/SubBlock.hh
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_COMMON_SUBBLOCK_HH__
|
||||
#define __MEM_RUBY_COMMON_SUBBLOCK_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/DataBlock.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
|
||||
class SubBlock
|
||||
{
|
||||
public:
|
||||
SubBlock() { }
|
||||
SubBlock(const Address& addr, int size);
|
||||
~SubBlock() { }
|
||||
|
||||
const Address& getAddress() const { return m_address; }
|
||||
void setAddress(const Address& addr) { m_address = addr; }
|
||||
|
||||
int getSize() const { return m_data.size(); }
|
||||
void resize(int size) { m_data.resize(size); }
|
||||
uint8 getByte(int offset) const { return m_data[offset]; }
|
||||
void setByte(int offset, uint8 data) { m_data[offset] = data; }
|
||||
|
||||
// Shorthands
|
||||
uint8 readByte() const { return getByte(0); }
|
||||
void writeByte(uint8 data) { setByte(0, data); }
|
||||
|
||||
// Merging to and from DataBlocks - We only need to worry about
|
||||
// updates when we are using DataBlocks
|
||||
void mergeTo(DataBlock& data) const { internalMergeTo(data); }
|
||||
void mergeFrom(const DataBlock& data) { internalMergeFrom(data); }
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
void internalMergeTo(DataBlock& data) const;
|
||||
void internalMergeFrom(const DataBlock& data);
|
||||
|
||||
// Data Members (m_ prefix)
|
||||
Address m_address;
|
||||
std::vector<uint8_t> m_data;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const SubBlock& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_COMMON_SUBBLOCK_HH__
|
||||
52
simulators/gem5/src/mem/ruby/common/TypeDefines.hh
Normal file
52
simulators/gem5/src/mem/ruby/common/TypeDefines.hh
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2009 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TYPEDEFINES_H
|
||||
#define TYPEDEFINES_H
|
||||
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned int uint32;
|
||||
typedef unsigned long long uint64;
|
||||
|
||||
typedef signed char int8;
|
||||
typedef int int32;
|
||||
typedef long long int64;
|
||||
|
||||
typedef long long integer_t;
|
||||
|
||||
typedef int64 Time;
|
||||
typedef uint64 physical_address_t;
|
||||
|
||||
typedef int64 Index; // what the address bit ripper returns
|
||||
typedef int LinkID;
|
||||
typedef int NodeID;
|
||||
typedef int SwitchID;
|
||||
|
||||
#endif
|
||||
68
simulators/gem5/src/mem/ruby/eventqueue/RubyEventQueue.cc
Normal file
68
simulators/gem5/src/mem/ruby/eventqueue/RubyEventQueue.cc
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "mem/ruby/common/Consumer.hh"
|
||||
#include "mem/ruby/eventqueue/RubyEventQueue.hh"
|
||||
#include "mem/ruby/eventqueue/RubyEventQueueNode.hh"
|
||||
|
||||
RubyEventQueue::RubyEventQueue(EventQueue* eventq, Tick _clock)
|
||||
: EventManager(eventq), m_clock(_clock)
|
||||
{
|
||||
}
|
||||
|
||||
RubyEventQueue::~RubyEventQueue()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
RubyEventQueue::scheduleEvent(Consumer* consumer, Time timeDelta)
|
||||
{
|
||||
scheduleEventAbsolute(consumer, timeDelta + getTime());
|
||||
}
|
||||
|
||||
void
|
||||
RubyEventQueue::scheduleEventAbsolute(Consumer* consumer, Time timeAbs)
|
||||
{
|
||||
// Check to see if this is a redundant wakeup
|
||||
assert(consumer != NULL);
|
||||
if (!consumer->alreadyScheduled(timeAbs)) {
|
||||
// This wakeup is not redundant
|
||||
RubyEventQueueNode *thisNode = new RubyEventQueueNode(consumer, this);
|
||||
assert(timeAbs > getTime());
|
||||
schedule(thisNode, (timeAbs * m_clock));
|
||||
consumer->insertScheduledWakeupTime(timeAbs);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RubyEventQueue::print(std::ostream& out) const
|
||||
{
|
||||
out << "[Event Queue:]";
|
||||
}
|
||||
96
simulators/gem5/src/mem/ruby/eventqueue/RubyEventQueue.hh
Normal file
96
simulators/gem5/src/mem/ruby/eventqueue/RubyEventQueue.hh
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The RubyEventQueue class implements an event queue which
|
||||
* can be trigger events, allowing our simulation to be event driven.
|
||||
*
|
||||
* Currently, the only event we support is a Consumer being signaled
|
||||
* by calling the consumer's wakeup() routine. Adding the event to
|
||||
* the queue does not require a virtual function call, though calling
|
||||
* wakeup() is a virtual function call.
|
||||
*
|
||||
* The method triggerEvents() is called with a global time. All
|
||||
* events which are before or at this time are triggered in timestamp
|
||||
* order. No ordering is enforced for events scheduled to occur at
|
||||
* the same time. Events scheduled to wakeup the same consumer at the
|
||||
* same time are combined into a single event.
|
||||
*
|
||||
* The method scheduleConsumerWakeup() is called with a global time
|
||||
* and a consumer pointer. The event queue will call the wakeup()
|
||||
* method of the consumer at the appropriate time.
|
||||
*
|
||||
* This implementation of RubyEventQueue uses a dynamically sized array
|
||||
* managed as a heap. The algorithms used has O(lg n) for insert and
|
||||
* O(lg n) for extract minimum element. (Based on chapter 7 of Cormen,
|
||||
* Leiserson, and Rivest.) The array is dynamically sized and is
|
||||
* automatically doubled in size when necessary.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_EVENTQUEUE_RUBYEVENTQUEUE_HH__
|
||||
#define __MEM_RUBY_EVENTQUEUE_RUBYEVENTQUEUE_HH__
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "mem/ruby/common/TypeDefines.hh"
|
||||
#include "sim/eventq.hh"
|
||||
|
||||
class Consumer;
|
||||
class RubyEventQueueNode;
|
||||
|
||||
class RubyEventQueue : public EventManager
|
||||
{
|
||||
public:
|
||||
RubyEventQueue(EventQueue* eventq, Tick _clock);
|
||||
~RubyEventQueue();
|
||||
|
||||
Time getTime() const { return curTick()/m_clock; }
|
||||
Tick getClock() const { return m_clock; }
|
||||
void scheduleEvent(Consumer* consumer, Time timeDelta);
|
||||
void scheduleEventAbsolute(Consumer* consumer, Time timeAbs);
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
// Private copy constructor and assignment operator
|
||||
RubyEventQueue(const RubyEventQueue& obj);
|
||||
RubyEventQueue& operator=(const RubyEventQueue& obj);
|
||||
|
||||
// Data Members (m_ prefix)
|
||||
Tick m_clock;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const RubyEventQueue& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_EVENTQUEUE_RUBYEVENTQUEUE_HH__
|
||||
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "mem/ruby/eventqueue/RubyEventQueueNode.hh"
|
||||
|
||||
void
|
||||
RubyEventQueueNode::print(std::ostream& out) const
|
||||
{
|
||||
out << "[";
|
||||
if (m_consumer_ptr != NULL) {
|
||||
out << " Consumer=" << m_consumer_ptr;
|
||||
} else {
|
||||
out << " Consumer=NULL";
|
||||
}
|
||||
out << "]";
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_EVENTQUEUE_RUBYEVENTQUEUENODE_HH__
|
||||
#define __MEM_RUBY_EVENTQUEUE_RUBYEVENTQUEUENODE_HH__
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "mem/ruby/common/Consumer.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "sim/eventq.hh"
|
||||
|
||||
class RubyEventQueueNode : public Event
|
||||
{
|
||||
public:
|
||||
RubyEventQueueNode(Consumer* _consumer, RubyEventQueue* _eventq)
|
||||
: Event(Default_Pri, AutoDelete),
|
||||
m_consumer_ptr(_consumer), m_eventq_ptr(_eventq)
|
||||
{
|
||||
}
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
virtual void
|
||||
process()
|
||||
{
|
||||
m_consumer_ptr->wakeup();
|
||||
m_consumer_ptr->removeScheduledWakeupTime(m_eventq_ptr->getTime());
|
||||
}
|
||||
virtual const char *description() const { return "Ruby Event"; }
|
||||
|
||||
private:
|
||||
Consumer* m_consumer_ptr;
|
||||
RubyEventQueue* m_eventq_ptr;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const RubyEventQueueNode& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_EVENTQUEUE_EVENTQUEUENODE_HH__
|
||||
37
simulators/gem5/src/mem/ruby/eventqueue/SConscript
Normal file
37
simulators/gem5/src/mem/ruby/eventqueue/SConscript
Normal file
@ -0,0 +1,37 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
||||
# 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.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['PROTOCOL'] == 'None':
|
||||
Return()
|
||||
|
||||
Source('RubyEventQueue.cc')
|
||||
Source('RubyEventQueueNode.cc')
|
||||
59
simulators/gem5/src/mem/ruby/filters/AbstractBloomFilter.hh
Normal file
59
simulators/gem5/src/mem/ruby/filters/AbstractBloomFilter.hh
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_FILTERS_ABSTRACTBLOOMFILTER_HH__
|
||||
#define __MEM_RUBY_FILTERS_ABSTRACTBLOOMFILTER_HH__
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
|
||||
class AbstractBloomFilter
|
||||
{
|
||||
public:
|
||||
virtual ~AbstractBloomFilter() {};
|
||||
virtual void clear() = 0;
|
||||
virtual void increment(const Address& addr) = 0;
|
||||
virtual void decrement(const Address& addr) = 0;
|
||||
virtual void merge(AbstractBloomFilter * other_filter) = 0;
|
||||
virtual void set(const Address& addr) = 0;
|
||||
virtual void unset(const Address& addr) = 0;
|
||||
|
||||
virtual bool isSet(const Address& addr) = 0;
|
||||
virtual int getCount(const Address& addr) = 0;
|
||||
virtual int getTotalCount() = 0;
|
||||
|
||||
virtual void print(std::ostream& out) const = 0;
|
||||
|
||||
virtual int getIndex(const Address& addr) = 0;
|
||||
virtual int readBit(const int index) = 0;
|
||||
virtual void writeBit(const int index, const int value) = 0;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_FILTERS_ABSTRACTBLOOMFILTER_HH__
|
||||
167
simulators/gem5/src/mem/ruby/filters/BlockBloomFilter.cc
Normal file
167
simulators/gem5/src/mem/ruby/filters/BlockBloomFilter.cc
Normal file
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "base/intmath.hh"
|
||||
#include "base/str.hh"
|
||||
#include "mem/ruby/filters/BlockBloomFilter.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
BlockBloomFilter::BlockBloomFilter(string str)
|
||||
{
|
||||
string head, tail;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool success =
|
||||
#endif
|
||||
split_first(str, head, tail, '_');
|
||||
|
||||
assert(success);
|
||||
|
||||
m_filter_size = atoi(head.c_str());
|
||||
m_filter_size_bits = floorLog2(m_filter_size);
|
||||
|
||||
m_filter.resize(m_filter_size);
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
BlockBloomFilter::~BlockBloomFilter()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BlockBloomFilter::clear()
|
||||
{
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
m_filter[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BlockBloomFilter::increment(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
void
|
||||
BlockBloomFilter::decrement(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
void
|
||||
BlockBloomFilter::merge(AbstractBloomFilter * other_filter)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
BlockBloomFilter::set(const Address& addr)
|
||||
{
|
||||
int i = get_index(addr);
|
||||
m_filter[i] = 1;
|
||||
}
|
||||
|
||||
void
|
||||
BlockBloomFilter::unset(const Address& addr)
|
||||
{
|
||||
int i = get_index(addr);
|
||||
m_filter[i] = 0;
|
||||
}
|
||||
|
||||
bool
|
||||
BlockBloomFilter::isSet(const Address& addr)
|
||||
{
|
||||
int i = get_index(addr);
|
||||
return (m_filter[i]);
|
||||
}
|
||||
|
||||
int
|
||||
BlockBloomFilter::getCount(const Address& addr)
|
||||
{
|
||||
return m_filter[get_index(addr)];
|
||||
}
|
||||
|
||||
int
|
||||
BlockBloomFilter::getTotalCount()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
if (m_filter[i]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int
|
||||
BlockBloomFilter::getIndex(const Address& addr)
|
||||
{
|
||||
return get_index(addr);
|
||||
}
|
||||
|
||||
void
|
||||
BlockBloomFilter::print(ostream& out) const
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
BlockBloomFilter::readBit(const int index)
|
||||
{
|
||||
return m_filter[index];
|
||||
}
|
||||
|
||||
void
|
||||
BlockBloomFilter::writeBit(const int index, const int value)
|
||||
{
|
||||
m_filter[index] = value;
|
||||
}
|
||||
|
||||
int
|
||||
BlockBloomFilter::get_index(const Address& addr)
|
||||
{
|
||||
// Pull out some bit field ==> B1
|
||||
// Pull out additional bits, not the same as B1 ==> B2
|
||||
// XOR B1 and B2 to get hash index
|
||||
physical_address_t block_bits =
|
||||
addr.bitSelect(RubySystem::getBlockSizeBits(),
|
||||
2 * RubySystem::getBlockSizeBits() - 1);
|
||||
int offset = 5;
|
||||
physical_address_t other_bits =
|
||||
addr.bitSelect(2 * RubySystem::getBlockSizeBits() + offset,
|
||||
2 * RubySystem::getBlockSizeBits() + offset +
|
||||
m_filter_size_bits - 1);
|
||||
int index = block_bits ^ other_bits;
|
||||
assert(index < m_filter_size);
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
73
simulators/gem5/src/mem/ruby/filters/BlockBloomFilter.hh
Normal file
73
simulators/gem5/src/mem/ruby/filters/BlockBloomFilter.hh
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_FILTERS_BLOCKBLOOMFILTER_HH__
|
||||
#define __MEM_RUBY_FILTERS_BLOCKBLOOMFILTER_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/filters/AbstractBloomFilter.hh"
|
||||
|
||||
class BlockBloomFilter : public AbstractBloomFilter
|
||||
{
|
||||
public:
|
||||
BlockBloomFilter(std::string config);
|
||||
~BlockBloomFilter();
|
||||
|
||||
void clear();
|
||||
void increment(const Address& addr);
|
||||
void decrement(const Address& addr);
|
||||
void merge(AbstractBloomFilter * other_filter);
|
||||
void set(const Address& addr);
|
||||
void unset(const Address& addr);
|
||||
|
||||
bool isSet(const Address& addr);
|
||||
int getCount(const Address& addr);
|
||||
int getTotalCount();
|
||||
int getIndex(const Address& addr);
|
||||
int readBit(const int index);
|
||||
void writeBit(const int index, const int value);
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
int get_index(const Address& addr);
|
||||
|
||||
std::vector<int> m_filter;
|
||||
int m_filter_size;
|
||||
int m_filter_size_bits;
|
||||
|
||||
int m_count_bits;
|
||||
int m_count;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_FILTERS_BLOCKBLOOMFILTER_HH__
|
||||
255
simulators/gem5/src/mem/ruby/filters/BulkBloomFilter.cc
Normal file
255
simulators/gem5/src/mem/ruby/filters/BulkBloomFilter.cc
Normal file
@ -0,0 +1,255 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "base/intmath.hh"
|
||||
#include "base/str.hh"
|
||||
#include "mem/ruby/filters/BulkBloomFilter.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
BulkBloomFilter::BulkBloomFilter(string str)
|
||||
{
|
||||
string head, tail;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool success =
|
||||
#endif
|
||||
split_first(str, head, tail, '_');
|
||||
assert(success);
|
||||
|
||||
m_filter_size = atoi(head.c_str());
|
||||
m_filter_size_bits = floorLog2(m_filter_size);
|
||||
// split the filter bits in half, c0 and c1
|
||||
m_sector_bits = m_filter_size_bits - 1;
|
||||
|
||||
m_temp_filter.resize(m_filter_size);
|
||||
m_filter.resize(m_filter_size);
|
||||
clear();
|
||||
|
||||
// clear temp filter
|
||||
for (int i = 0; i < m_filter_size; ++i) {
|
||||
m_temp_filter[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BulkBloomFilter::~BulkBloomFilter()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BulkBloomFilter::clear()
|
||||
{
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
m_filter[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BulkBloomFilter::increment(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
void
|
||||
BulkBloomFilter::decrement(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
void
|
||||
BulkBloomFilter::merge(AbstractBloomFilter * other_filter)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
BulkBloomFilter::set(const Address& addr)
|
||||
{
|
||||
// c0 contains the cache index bits
|
||||
int set_bits = m_sector_bits;
|
||||
int block_bits = RubySystem::getBlockSizeBits();
|
||||
int c0 = addr.bitSelect( block_bits, block_bits + set_bits - 1);
|
||||
// c1 contains the lower m_sector_bits permuted bits
|
||||
//Address permuted_bits = permute(addr);
|
||||
//int c1 = permuted_bits.bitSelect(0, set_bits-1);
|
||||
int c1 = addr.bitSelect( block_bits+set_bits, (block_bits+2*set_bits) - 1);
|
||||
//assert(c0 < (m_filter_size/2));
|
||||
//assert(c0 + (m_filter_size/2) < m_filter_size);
|
||||
//assert(c1 < (m_filter_size/2));
|
||||
// set v0 bit
|
||||
m_filter[c0 + (m_filter_size/2)] = 1;
|
||||
// set v1 bit
|
||||
m_filter[c1] = 1;
|
||||
}
|
||||
|
||||
void
|
||||
BulkBloomFilter::unset(const Address& addr)
|
||||
{
|
||||
// not used
|
||||
}
|
||||
|
||||
bool
|
||||
BulkBloomFilter::isSet(const Address& addr)
|
||||
{
|
||||
// c0 contains the cache index bits
|
||||
int set_bits = m_sector_bits;
|
||||
int block_bits = RubySystem::getBlockSizeBits();
|
||||
int c0 = addr.bitSelect( block_bits, block_bits + set_bits - 1);
|
||||
// c1 contains the lower 10 permuted bits
|
||||
//Address permuted_bits = permute(addr);
|
||||
//int c1 = permuted_bits.bitSelect(0, set_bits-1);
|
||||
int c1 = addr.bitSelect( block_bits+set_bits, (block_bits+2*set_bits) - 1);
|
||||
//assert(c0 < (m_filter_size/2));
|
||||
//assert(c0 + (m_filter_size/2) < m_filter_size);
|
||||
//assert(c1 < (m_filter_size/2));
|
||||
// set v0 bit
|
||||
m_temp_filter[c0 + (m_filter_size/2)] = 1;
|
||||
// set v1 bit
|
||||
m_temp_filter[c1] = 1;
|
||||
|
||||
// perform filter intersection. If any c part is 0, no possibility
|
||||
// of address being in signature. get first c intersection part
|
||||
bool zero = false;
|
||||
for (int i = 0; i < m_filter_size/2; ++i){
|
||||
// get intersection of signatures
|
||||
m_temp_filter[i] = m_temp_filter[i] && m_filter[i];
|
||||
zero = zero || m_temp_filter[i];
|
||||
}
|
||||
zero = !zero;
|
||||
if (zero) {
|
||||
// one section is zero, no possiblility of address in signature
|
||||
// reset bits we just set
|
||||
m_temp_filter[c0 + (m_filter_size / 2)] = 0;
|
||||
m_temp_filter[c1] = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// check second section
|
||||
zero = false;
|
||||
for(int i = m_filter_size / 2; i < m_filter_size; ++i) {
|
||||
// get intersection of signatures
|
||||
m_temp_filter[i] = m_temp_filter[i] && m_filter[i];
|
||||
zero = zero || m_temp_filter[i];
|
||||
}
|
||||
zero = !zero;
|
||||
if (zero) {
|
||||
// one section is zero, no possiblility of address in signature
|
||||
m_temp_filter[c0 + (m_filter_size / 2)] = 0;
|
||||
m_temp_filter[c1] = 0;
|
||||
return false;
|
||||
}
|
||||
// one section has at least one bit set
|
||||
m_temp_filter[c0 + (m_filter_size / 2)] = 0;
|
||||
m_temp_filter[c1] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
BulkBloomFilter::getCount(const Address& addr)
|
||||
{
|
||||
// not used
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
BulkBloomFilter::getTotalCount()
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
if (m_filter[i]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int
|
||||
BulkBloomFilter::getIndex(const Address& addr)
|
||||
{
|
||||
return get_index(addr);
|
||||
}
|
||||
|
||||
int
|
||||
BulkBloomFilter::readBit(const int index)
|
||||
{
|
||||
return 0;
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
BulkBloomFilter::writeBit(const int index, const int value)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
BulkBloomFilter::print(ostream& out) const
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
BulkBloomFilter::get_index(const Address& addr)
|
||||
{
|
||||
return addr.bitSelect(RubySystem::getBlockSizeBits(),
|
||||
RubySystem::getBlockSizeBits() +
|
||||
m_filter_size_bits - 1);
|
||||
}
|
||||
|
||||
Address
|
||||
BulkBloomFilter::permute(const Address & addr)
|
||||
{
|
||||
// permutes the original address bits according to Table 5
|
||||
int block_offset = RubySystem::getBlockSizeBits();
|
||||
physical_address_t part1 = addr.bitSelect(block_offset, block_offset + 6),
|
||||
part2 = addr.bitSelect(block_offset + 9, block_offset + 9),
|
||||
part3 = addr.bitSelect(block_offset + 11, block_offset + 11),
|
||||
part4 = addr.bitSelect(block_offset + 17, block_offset + 17),
|
||||
part5 = addr.bitSelect(block_offset + 7, block_offset + 8),
|
||||
part6 = addr.bitSelect(block_offset + 10, block_offset + 10),
|
||||
part7 = addr.bitSelect(block_offset + 12, block_offset + 12),
|
||||
part8 = addr.bitSelect(block_offset + 13, block_offset + 13),
|
||||
part9 = addr.bitSelect(block_offset + 15, block_offset + 16),
|
||||
part10 = addr.bitSelect(block_offset + 18, block_offset + 20),
|
||||
part11 = addr.bitSelect(block_offset + 14, block_offset + 14);
|
||||
|
||||
physical_address_t result =
|
||||
(part1 << 14) | (part2 << 13) | (part3 << 12) | (part4 << 11) |
|
||||
(part5 << 9) | (part6 << 8) | (part7 << 7) | (part8 << 6) |
|
||||
(part9 << 4) | (part10 << 1) | (part11);
|
||||
|
||||
// assume 32 bit addresses (both virtual and physical)
|
||||
// select the remaining high-order 11 bits
|
||||
physical_address_t remaining_bits =
|
||||
addr.bitSelect(block_offset + 21, 31) << 21;
|
||||
result = result | remaining_bits;
|
||||
|
||||
return Address(result);
|
||||
}
|
||||
78
simulators/gem5/src/mem/ruby/filters/BulkBloomFilter.hh
Normal file
78
simulators/gem5/src/mem/ruby/filters/BulkBloomFilter.hh
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_FILTERS_BULKBLOOMFILTER_HH__
|
||||
#define __MEM_RUBY_FILTERS_BULKBLOOMFILTER_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/filters/AbstractBloomFilter.hh"
|
||||
|
||||
class BulkBloomFilter : public AbstractBloomFilter
|
||||
{
|
||||
public:
|
||||
BulkBloomFilter(std::string config);
|
||||
~BulkBloomFilter();
|
||||
|
||||
void clear();
|
||||
void increment(const Address& addr);
|
||||
void decrement(const Address& addr);
|
||||
void merge(AbstractBloomFilter * other_filter);
|
||||
void set(const Address& addr);
|
||||
void unset(const Address& addr);
|
||||
|
||||
bool isSet(const Address& addr);
|
||||
int getCount(const Address& addr);
|
||||
int getTotalCount();
|
||||
int getIndex(const Address& addr);
|
||||
int readBit(const int index);
|
||||
void writeBit(const int index, const int value);
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
int get_index(const Address& addr);
|
||||
Address permute(const Address & addr);
|
||||
|
||||
std::vector<int> m_filter;
|
||||
std::vector<int> m_temp_filter;
|
||||
|
||||
int m_filter_size;
|
||||
int m_filter_size_bits;
|
||||
|
||||
int m_sector_bits;
|
||||
|
||||
int m_count_bits;
|
||||
int m_count;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_FILTERS_BULKBLOOMFILTER_HH__
|
||||
154
simulators/gem5/src/mem/ruby/filters/GenericBloomFilter.cc
Normal file
154
simulators/gem5/src/mem/ruby/filters/GenericBloomFilter.cc
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "base/str.hh"
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/filters/BlockBloomFilter.hh"
|
||||
#include "mem/ruby/filters/BulkBloomFilter.hh"
|
||||
#include "mem/ruby/filters/GenericBloomFilter.hh"
|
||||
#include "mem/ruby/filters/H3BloomFilter.hh"
|
||||
#include "mem/ruby/filters/LSB_CountingBloomFilter.hh"
|
||||
#include "mem/ruby/filters/MultiBitSelBloomFilter.hh"
|
||||
#include "mem/ruby/filters/MultiGrainBloomFilter.hh"
|
||||
#include "mem/ruby/filters/NonCountingBloomFilter.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
GenericBloomFilter::GenericBloomFilter(string config)
|
||||
{
|
||||
string head, tail;
|
||||
#ifndef NDEBUG
|
||||
bool success =
|
||||
#endif
|
||||
split_first(config, head, tail, '_');
|
||||
assert(success);
|
||||
|
||||
if (head == "LSB_Counting" ) {
|
||||
m_filter = new LSB_CountingBloomFilter(tail);
|
||||
} else if(head == "NonCounting" ) {
|
||||
m_filter = new NonCountingBloomFilter(tail);
|
||||
} else if(head == "Bulk" ) {
|
||||
m_filter = new BulkBloomFilter(tail);
|
||||
} else if(head == "Block") {
|
||||
m_filter = new BlockBloomFilter(tail);
|
||||
} else if(head == "Multigrain"){
|
||||
m_filter = new MultiGrainBloomFilter(tail);
|
||||
} else if(head == "MultiBitSel"){
|
||||
m_filter = new MultiBitSelBloomFilter(tail);
|
||||
} else if(head == "H3"){
|
||||
m_filter = new H3BloomFilter(tail);
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
GenericBloomFilter::~GenericBloomFilter()
|
||||
{
|
||||
delete m_filter;
|
||||
}
|
||||
|
||||
void
|
||||
GenericBloomFilter::clear()
|
||||
{
|
||||
m_filter->clear();
|
||||
}
|
||||
|
||||
void
|
||||
GenericBloomFilter::increment(const Address& addr)
|
||||
{
|
||||
m_filter->increment(addr);
|
||||
}
|
||||
|
||||
void
|
||||
GenericBloomFilter::decrement(const Address& addr)
|
||||
{
|
||||
m_filter->decrement(addr);
|
||||
}
|
||||
|
||||
void
|
||||
GenericBloomFilter::merge(GenericBloomFilter * other_filter)
|
||||
{
|
||||
m_filter->merge(other_filter->getFilter());
|
||||
}
|
||||
|
||||
void
|
||||
GenericBloomFilter::set(const Address& addr)
|
||||
{
|
||||
m_filter->set(addr);
|
||||
}
|
||||
|
||||
void
|
||||
GenericBloomFilter::unset(const Address& addr)
|
||||
{
|
||||
m_filter->unset(addr);
|
||||
}
|
||||
|
||||
bool
|
||||
GenericBloomFilter::isSet(const Address& addr)
|
||||
{
|
||||
return m_filter->isSet(addr);
|
||||
}
|
||||
|
||||
int
|
||||
GenericBloomFilter::getCount(const Address& addr)
|
||||
{
|
||||
return m_filter->getCount(addr);
|
||||
}
|
||||
|
||||
int
|
||||
GenericBloomFilter::getTotalCount()
|
||||
{
|
||||
return m_filter->getTotalCount();
|
||||
}
|
||||
|
||||
int
|
||||
GenericBloomFilter::getIndex(const Address& addr)
|
||||
{
|
||||
return m_filter->getIndex(addr);
|
||||
}
|
||||
|
||||
int
|
||||
GenericBloomFilter::readBit(const int index)
|
||||
{
|
||||
return m_filter->readBit(index);
|
||||
}
|
||||
|
||||
void
|
||||
GenericBloomFilter::writeBit(const int index, const int value)
|
||||
{
|
||||
m_filter->writeBit(index, value);
|
||||
}
|
||||
|
||||
void
|
||||
GenericBloomFilter::print(ostream& out) const
|
||||
{
|
||||
return m_filter->print(out);
|
||||
}
|
||||
|
||||
|
||||
86
simulators/gem5/src/mem/ruby/filters/GenericBloomFilter.hh
Normal file
86
simulators/gem5/src/mem/ruby/filters/GenericBloomFilter.hh
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_FILTERS_GENERICBLOOMFILTER_HH__
|
||||
#define __MEM_RUBY_FILTERS_GENERICBLOOMFILTER_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/filters/AbstractBloomFilter.hh"
|
||||
|
||||
class GenericBloomFilter
|
||||
{
|
||||
public:
|
||||
GenericBloomFilter(std::string config);
|
||||
~GenericBloomFilter();
|
||||
|
||||
void clear();
|
||||
void increment(const Address& addr);
|
||||
void decrement(const Address& addr);
|
||||
void merge(GenericBloomFilter * other_filter);
|
||||
void set(const Address& addr);
|
||||
void unset(const Address& addr);
|
||||
AbstractBloomFilter *
|
||||
getFilter()
|
||||
{
|
||||
return m_filter;
|
||||
}
|
||||
|
||||
bool isSet(const Address& addr);
|
||||
|
||||
int getCount(const Address& addr);
|
||||
|
||||
int getTotalCount();
|
||||
|
||||
int getIndex(const Address& addr);
|
||||
int readBit(const int index);
|
||||
void writeBit(const int index, const int value);
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
void
|
||||
printConfig(std::ostream& out)
|
||||
{
|
||||
out << "GenericBloomFilter" << std::endl;
|
||||
}
|
||||
|
||||
private:
|
||||
AbstractBloomFilter* m_filter;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const GenericBloomFilter& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_FILTERS_GENERICBLOOMFILTER_HH__
|
||||
534
simulators/gem5/src/mem/ruby/filters/H3BloomFilter.cc
Normal file
534
simulators/gem5/src/mem/ruby/filters/H3BloomFilter.cc
Normal file
@ -0,0 +1,534 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "base/intmath.hh"
|
||||
#include "base/str.hh"
|
||||
#include "mem/ruby/filters/H3BloomFilter.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static int H3[64][16] = {
|
||||
{ 33268410, 395488709, 311024285, 456111753,
|
||||
181495008, 119997521, 220697869, 433891432,
|
||||
755927921, 515226970, 719448198, 349842774,
|
||||
269183649, 463275672, 429800228, 521598937, },
|
||||
|
||||
{ 628677802, 820947732, 809435975, 1024657192,
|
||||
887631270, 412050215, 391365090, 324227279,
|
||||
318338329, 1038393087, 489807930, 387366128,
|
||||
518096428, 324184340, 429376066, 447109279, },
|
||||
|
||||
{ 599747653, 404960623, 103933604, 946416030,
|
||||
656460913, 925957005, 1047665689, 163552053,
|
||||
88359290, 841315415, 899833584, 1067336680,
|
||||
348549994, 464045876, 270252128, 829897652, },
|
||||
|
||||
{ 215495230, 966696438, 82589012, 750102795,
|
||||
909780866, 920285789, 769759214, 331966823,
|
||||
939936006, 439950703, 883794828, 1009277508,
|
||||
61634610, 741444350, 98689608, 524144422, },
|
||||
|
||||
{ 93868534, 196958667, 774076619, 327921978,
|
||||
122538783, 879785030, 690748527, 3498564,
|
||||
83163077, 1027963025, 582088444, 466152216,
|
||||
312424878, 550064499, 646612667, 561099434, },
|
||||
|
||||
{ 1002047931, 395477707, 821317480, 890482112,
|
||||
697094476, 263813044, 840275189, 469664185,
|
||||
795625845, 211504898, 99204277, 1004491153,
|
||||
725930417, 1064479221, 893834767, 839719181, },
|
||||
|
||||
{ 278507126, 985111995, 706462983, 1042178726,
|
||||
123281719, 963778122, 500881056, 726291104,
|
||||
134293026, 568379664, 317050609, 533470307,
|
||||
1022365922, 197645211, 315125721, 634827678, },
|
||||
|
||||
{ 219227366, 553960647, 870169525, 322232839,
|
||||
508322497, 648672696, 249405795, 883596102,
|
||||
476433133, 541372919, 646647793, 1042679515,
|
||||
43242483, 600187508, 499866821, 135713210, },
|
||||
|
||||
{ 52837162, 96966684, 401840460, 1071661176,
|
||||
733560065, 150035417, 341319946, 811582750,
|
||||
636173904, 519054065, 196321433, 1028294565,
|
||||
882204070, 522965093, 48884074, 117810166, },
|
||||
|
||||
{ 650860353, 789534698, 328813544, 473250022,
|
||||
143128306, 173196006, 846958825, 174632187,
|
||||
683273509, 405459497, 787235556, 773873501,
|
||||
240110267, 426797736, 92043842, 711789240, },
|
||||
|
||||
{ 586637493, 5059646, 398035664, 6686087,
|
||||
498300175, 948278148, 681227731, 592751744,
|
||||
572019677, 558044722, 589368271, 695745538,
|
||||
1073416749, 529192035, 550984939, 1070620580, },
|
||||
|
||||
{ 102904663, 647598516, 758863940, 313426443,
|
||||
76504114, 1050747783, 708436441, 563815069,
|
||||
224107668, 875925186, 167675944, 926209739,
|
||||
279737287, 1040288182, 768184312, 371708956, },
|
||||
|
||||
{ 683968868, 1027427757, 180781926, 742898864,
|
||||
624078545, 645659833, 577225838, 987150210,
|
||||
723410002, 224013421, 993286634, 33188488,
|
||||
247264323, 888018697, 38048664, 189037096, },
|
||||
|
||||
{ 475612146, 426739285, 873726278, 529192871,
|
||||
607715202, 388486246, 987001312, 474493980,
|
||||
259747270, 417465536, 217062395, 392858482,
|
||||
563810075, 137852805, 1051814153, 72895217, },
|
||||
|
||||
{ 71277086, 785496675, 500608842, 89633426,
|
||||
274085706, 248467935, 838061983, 48106147,
|
||||
773662506, 49545328, 9071573, 100739031,
|
||||
602018002, 904371654, 534132064, 332211304, },
|
||||
|
||||
{ 401893602, 735125342, 775548339, 210224843,
|
||||
256081130, 482894412, 350801633, 1035713633,
|
||||
429458128, 327281409, 739927752, 359327650,
|
||||
886942880, 847691759, 752417993, 359445596, },
|
||||
|
||||
{ 267472014, 1050659620, 1068232362, 1049684368,
|
||||
17130239, 690524969, 793224378, 14455158,
|
||||
423092885, 873853424, 430535778, 7867877,
|
||||
309731959, 370260786, 862353083, 403906850, },
|
||||
|
||||
{ 993077283, 218812656, 389234651, 393202875,
|
||||
413116501, 263300295, 470013158, 592730725,
|
||||
441847172, 732392823, 407574059, 875664777,
|
||||
271347307, 792954404, 554774761, 1022424300, },
|
||||
|
||||
{ 675919719, 637054073, 784720745, 149714381,
|
||||
813144874, 502525801, 635436670, 1003196587,
|
||||
160786091, 947509775, 969788637, 26854073,
|
||||
257964369, 63898568, 539767732, 772364518, },
|
||||
|
||||
{ 943076868, 1021732472, 697575075, 15843624,
|
||||
617573396, 534113303, 122953324, 964873912,
|
||||
942995378, 87830944, 1012914818, 455484661,
|
||||
592160054, 599844284, 810394353, 836812568, },
|
||||
|
||||
{ 688992674, 279465370, 731582262, 687883235,
|
||||
438178468, 80493001, 342701501, 663561405,
|
||||
23360106, 531315007, 508931618, 36294623,
|
||||
231216223, 840438413, 255665680, 663205938, },
|
||||
|
||||
{ 857265418, 552630887, 8173237, 792122963,
|
||||
210140052, 823124938, 667709953, 751538219,
|
||||
991957789, 462064153, 19070176, 726604748,
|
||||
714567823, 151147895, 1012619677, 697114353, },
|
||||
|
||||
{ 467105652, 683256174, 702387467, 28730434,
|
||||
549942998, 48712701, 960519696, 1008345587,
|
||||
679267717, 370932249, 880419471, 352141567,
|
||||
331640403, 598772468, 95160685, 812053015, },
|
||||
|
||||
{ 1053491323, 430526562, 1014938507, 109685515,
|
||||
765949103, 177288303, 1034642653, 485421658,
|
||||
71850281, 981034542, 61620389, 601367920,
|
||||
504420930, 220599168, 583051998, 158735752, },
|
||||
|
||||
{ 103033901, 522494916, 658494760, 959206022,
|
||||
931348143, 834510661, 21542994, 189699884,
|
||||
679327018, 171983002, 96774168, 456133168,
|
||||
543103352, 923945936, 970074188, 643658485, },
|
||||
|
||||
{ 566379913, 805798263, 840662512, 820206124,
|
||||
796507494, 223712542, 118811519, 662246595,
|
||||
809326534, 416471323, 748027186, 161169753,
|
||||
739149488, 276330378, 924837051, 964873733, },
|
||||
|
||||
{ 585882743, 135502711, 3386031, 625631285,
|
||||
1068193307, 270342640, 432739484, 556606453,
|
||||
826419155, 1038540977, 158000202, 69109538,
|
||||
207087256, 298111218, 678046259, 184611498, },
|
||||
|
||||
{ 305310710, 46237988, 855726974, 735975153,
|
||||
930663798, 425764232, 104362407, 391371443,
|
||||
867622101, 71645091, 61824734, 661902640,
|
||||
293738633, 309416189, 281710675, 879317360, },
|
||||
|
||||
{ 398146324, 398293087, 689145387, 1038451703,
|
||||
521637478, 516134620, 314658937, 830334981,
|
||||
583400300, 340083705, 68029852, 675389876,
|
||||
994635780, 788959180, 406967042, 74403607, },
|
||||
|
||||
{ 69463153, 744427484, 191639960, 590927798,
|
||||
969916795, 546846769, 728756758, 889355646,
|
||||
520855076, 136068426, 776132410, 189663815,
|
||||
252051082, 533662856, 362198652, 1026161384, },
|
||||
|
||||
{ 584984279, 1004834381, 568439705, 834508761,
|
||||
21812513, 670870173, 1052043300, 341868768,
|
||||
473755574, 124339439, 36193947, 437997647,
|
||||
137419489, 58705193, 337793711, 340738909, },
|
||||
|
||||
{ 898051466, 512792906, 234874060, 655358775,
|
||||
683745319, 671676404, 428888546, 639928192,
|
||||
672697722, 176477579, 747020991, 758211282,
|
||||
443045009, 205395173, 1016944273, 5584717, },
|
||||
|
||||
{ 156038300, 138620174, 588466825, 1061494056,
|
||||
1013672100, 1064257198, 881417791, 839470738,
|
||||
83519030, 100875683, 237486447, 461483733,
|
||||
681527127, 777996147, 574635362, 815974538, },
|
||||
|
||||
{ 184168473, 519509808, 62531892, 51821173,
|
||||
43787358, 385711644, 141325169, 36069511,
|
||||
584183031, 571372909, 671503175, 226486781,
|
||||
194932686, 1045460970, 753718579, 331442433, },
|
||||
|
||||
{ 73065106, 1015327221, 630916840, 1058053470,
|
||||
306737587, 296343219, 907194989, 920172546,
|
||||
224516225, 818625553, 551143849, 634570650,
|
||||
432966225, 756438259, 939564853, 767999933, },
|
||||
|
||||
{ 884775648, 394862257, 446787794, 219833788,
|
||||
727195727, 728122304, 249888353, 732947974,
|
||||
289908868, 448282580, 618161877, 898939716,
|
||||
739554163, 860631799, 1058977530, 86916736, },
|
||||
|
||||
{ 143850006, 352708694, 200194048, 979764914,
|
||||
629404175, 546279766, 72106714, 860980514,
|
||||
313190585, 897143111, 308425797, 953791785,
|
||||
349924906, 221457005, 950588925, 908254505, },
|
||||
|
||||
{ 950032043, 829868728, 68623614, 714624605,
|
||||
69760597, 297275854, 355894016, 985369737,
|
||||
882852618, 864071289, 958512902, 950910111,
|
||||
991368991, 829645051, 434698210, 771350575, },
|
||||
|
||||
{ 552695074, 319195551, 80297396, 496413831,
|
||||
944046531, 621525571, 617653363, 416729825,
|
||||
441842808, 9847464, 99420657, 1033914550,
|
||||
812966458, 937053011, 673390195, 934577365, },
|
||||
|
||||
{ 1034695843, 190969665, 332900185, 51897434,
|
||||
523888639, 883512843, 146908572, 506785674,
|
||||
565814307, 692255649, 314052926, 826386588,
|
||||
430691325, 866927620, 413880214, 936474339, },
|
||||
|
||||
{ 129380164, 741739952, 1013703462, 494392795,
|
||||
957214600, 1010879043, 931790677, 94551922,
|
||||
988065869, 120637871, 882506912, 395075379,
|
||||
210570485, 812422692, 910383687, 817722285, },
|
||||
|
||||
{ 51850866, 283408630, 1053047202, 858940389,
|
||||
818507731, 477082181, 353546901, 993324368,
|
||||
407093779, 231608253, 1067319867, 73159811,
|
||||
429792535, 971320614, 565699344, 718823399, },
|
||||
|
||||
{ 408185106, 491493570, 596050720, 310776444,
|
||||
703628192, 454438809, 523988035, 728512200,
|
||||
686012353, 976339656, 72816924, 116926720,
|
||||
165866591, 452043792, 866943072, 968545481, },
|
||||
|
||||
{ 443231195, 905907843, 1061421320, 746360489,
|
||||
1043120338, 1069659155, 463359031, 688303227,
|
||||
186550710, 155347339, 1044842421, 1005904570,
|
||||
69332909, 706951903, 422513657, 882038450, },
|
||||
|
||||
{ 430990623, 946501980, 742556791, 278398643,
|
||||
183759217, 659404315, 279754382, 1069347846,
|
||||
843746517, 222777670, 990835599, 548741637,
|
||||
129220580, 1392170, 1032654091, 894058935, },
|
||||
|
||||
{ 452042227, 751640705, 259481376, 765824585,
|
||||
145991469, 1013683228, 1055491225, 536379588,
|
||||
392593350, 913368594, 1029429776, 226857786,
|
||||
31505342, 1054416381, 32341741, 687106649, },
|
||||
|
||||
{ 404750944, 811417027, 869530820, 773491060,
|
||||
810901282, 979340397, 1036910290, 461764404,
|
||||
834235095, 765695033, 604692390, 452158120,
|
||||
928988098, 442719218, 1024059719, 167723114, },
|
||||
|
||||
{ 974245177, 1046377300, 1003424287, 787349855,
|
||||
336314155, 875074696, 1018462718, 890313003,
|
||||
367376809, 86355556, 1020618772, 890710345,
|
||||
444741481, 373230261, 767064947, 840920177, },
|
||||
|
||||
{ 719581124, 431808156, 138301690, 668222575,
|
||||
497413494, 740492013, 485033226, 125301442,
|
||||
831265111, 879071459, 341690480, 152975256,
|
||||
850330086, 717444507, 694225877, 785340566, },
|
||||
|
||||
{ 1032766252, 140959364, 737474726, 1062767538,
|
||||
364464647, 331414723, 356152634, 642832379,
|
||||
158733632, 374691640, 285504811, 345349905,
|
||||
876599880, 476392727, 479589210, 606376325, },
|
||||
|
||||
{ 174997730, 778177086, 319164313, 163614456,
|
||||
10331364, 599358958, 8331663, 237538058,
|
||||
159173957, 174533880, 65588684, 878222844,
|
||||
424467599, 901803515, 187504218, 776690353, },
|
||||
|
||||
{ 803856182, 965850321, 694948067, 218315960,
|
||||
358416571, 683713254, 178069303, 428076035,
|
||||
686176454, 579553217, 357306738, 315018080,
|
||||
886852373, 568563910, 896839725, 257416821, },
|
||||
|
||||
{ 401650013, 183289141, 497957228, 879734476,
|
||||
265024455, 825794561, 889237440, 323359863,
|
||||
100258491, 991414783, 313986632, 85847250,
|
||||
362520248, 276103512, 1041630342, 525981595, },
|
||||
|
||||
{ 487732740, 46201705, 990837834, 62744493,
|
||||
1067364756, 58015363, 690846283, 680262648,
|
||||
997278956, 469357861, 432164624, 996763915,
|
||||
211907847, 167824295, 144928194, 454839915, },
|
||||
|
||||
{ 41404232, 514493300, 259546924, 578217256,
|
||||
972345130, 123299213, 346040332, 1014668104,
|
||||
520910639, 579955198, 36627803, 179072921,
|
||||
547684341, 598950511, 269497394, 854352266, },
|
||||
|
||||
{ 603906768, 100863318, 708837659, 204175569,
|
||||
375560904, 908375384, 28314106, 6303733,
|
||||
175283124, 749851198, 308667367, 415293931,
|
||||
225365403, 1032188331, 977112710, 819705229, },
|
||||
|
||||
{ 399767123, 697985692, 356790426, 643687584,
|
||||
298624218, 185095167, 381653926, 876816342,
|
||||
296720023, 2205879, 235816616, 521850105,
|
||||
622753786, 1021421218, 726349744, 256504902, },
|
||||
|
||||
{ 851245024, 1022500222, 511909628, 313809625,
|
||||
99776025, 39710175, 798739932, 741832408,
|
||||
140631966, 898295927, 607660421, 870669312,
|
||||
1051422478, 789055529, 669113756, 681943450, },
|
||||
|
||||
{ 853872755, 491465269, 503341472, 98019440,
|
||||
258267420, 335602837, 320687824, 1053324395,
|
||||
24932389, 955011453, 934255131, 435625663,
|
||||
501568768, 238967025, 549987406, 248619780, },
|
||||
|
||||
{ 411151284, 576471205, 757985419, 544137226,
|
||||
968135693, 877548443, 194586894, 74882373,
|
||||
248353663, 21207540, 273789651, 853653916,
|
||||
861267970, 533253322, 3739570, 661358586, },
|
||||
|
||||
{ 271430986, 71390029, 257643671, 949329860,
|
||||
348156406, 251939238, 445808698, 48269799,
|
||||
907589462, 105677619, 635451508, 20805932,
|
||||
464874661, 7542147, 243619464, 288304568, },
|
||||
|
||||
{ 368215982, 530288964, 770090421, 660961164,
|
||||
614935537, 630760399, 931299233, 794519275,
|
||||
779918979, 401746493, 561237006, 1027202224,
|
||||
258968003, 339508073, 1050610516, 1064307013, },
|
||||
|
||||
{ 1039172162, 448331205, 928997884, 49813151,
|
||||
198712120, 992335354, 671024050, 879525220,
|
||||
745915336, 1038822580, 138669665, 917958819,
|
||||
681422342, 792868818, 924762727, 816386174, },
|
||||
|
||||
{ 515190336, 313808618, 441296783, 1022120897,
|
||||
792325033, 354387581, 59273006, 280075434,
|
||||
411357221, 665274694, 4054464, 1059046246,
|
||||
394261773, 848616745, 15446017, 517723271, },
|
||||
};
|
||||
|
||||
H3BloomFilter::H3BloomFilter(string str)
|
||||
{
|
||||
//TODO: change this ugly init code...
|
||||
primes_list[0] = 9323;
|
||||
primes_list[1] = 11279;
|
||||
primes_list[2] = 10247;
|
||||
primes_list[3] = 30637;
|
||||
primes_list[4] = 25717;
|
||||
primes_list[5] = 43711;
|
||||
|
||||
mults_list[0] = 255;
|
||||
mults_list[1] = 29;
|
||||
mults_list[2] = 51;
|
||||
mults_list[3] = 3;
|
||||
mults_list[4] = 77;
|
||||
mults_list[5] = 43;
|
||||
|
||||
adds_list[0] = 841;
|
||||
adds_list[1] = 627;
|
||||
adds_list[2] = 1555;
|
||||
adds_list[3] = 241;
|
||||
adds_list[4] = 7777;
|
||||
adds_list[5] = 65931;
|
||||
|
||||
vector<string> items;
|
||||
tokenize(items, str, '_');
|
||||
assert(items.size() == 3);
|
||||
|
||||
// head contains filter size, tail contains bit offset from block number
|
||||
m_filter_size = atoi(items[0].c_str());
|
||||
m_num_hashes = atoi(items[1].c_str());
|
||||
|
||||
if (items[2] == "Regular") {
|
||||
isParallel = false;
|
||||
} else if (items[2] == "Parallel") {
|
||||
isParallel = true;
|
||||
} else {
|
||||
panic("ERROR: Incorrect config string for MultiHash Bloom! :%s", str);
|
||||
}
|
||||
|
||||
m_filter_size_bits = floorLog2(m_filter_size);
|
||||
|
||||
m_par_filter_size = m_filter_size / m_num_hashes;
|
||||
m_par_filter_size_bits = floorLog2(m_par_filter_size);
|
||||
|
||||
m_filter.resize(m_filter_size);
|
||||
clear();
|
||||
}
|
||||
|
||||
H3BloomFilter::~H3BloomFilter()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
H3BloomFilter::clear()
|
||||
{
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
m_filter[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
H3BloomFilter::increment(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
void
|
||||
H3BloomFilter::decrement(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
void
|
||||
H3BloomFilter::merge(AbstractBloomFilter *other_filter)
|
||||
{
|
||||
// assumes both filters are the same size!
|
||||
H3BloomFilter * temp = (H3BloomFilter*) other_filter;
|
||||
for(int i = 0; i < m_filter_size; ++i){
|
||||
m_filter[i] |= (*temp)[i];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
H3BloomFilter::set(const Address& addr)
|
||||
{
|
||||
for (int i = 0; i < m_num_hashes; i++) {
|
||||
int idx = get_index(addr, i);
|
||||
m_filter[idx] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
H3BloomFilter::unset(const Address& addr)
|
||||
{
|
||||
cout << "ERROR: Unset should never be called in a Bloom filter";
|
||||
assert(0);
|
||||
}
|
||||
|
||||
bool
|
||||
H3BloomFilter::isSet(const Address& addr)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for (int i = 0; i < m_num_hashes; i++) {
|
||||
int idx = get_index(addr, i);
|
||||
res = res && m_filter[idx];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
H3BloomFilter::getCount(const Address& addr)
|
||||
{
|
||||
return isSet(addr)? 1: 0;
|
||||
}
|
||||
|
||||
int
|
||||
H3BloomFilter::getIndex(const Address& addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
H3BloomFilter::readBit(const int index)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
H3BloomFilter::writeBit(const int index, const int value)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
H3BloomFilter::getTotalCount()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
count += m_filter[i];
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void
|
||||
H3BloomFilter::print(ostream& out) const
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
H3BloomFilter::get_index(const Address& addr, int i)
|
||||
{
|
||||
uint64 x = addr.getLineAddress();
|
||||
// uint64 y = (x*mults_list[i] + adds_list[i]) % primes_list[i];
|
||||
int y = hash_H3(x,i);
|
||||
|
||||
if (isParallel) {
|
||||
return (y % m_par_filter_size) + i*m_par_filter_size;
|
||||
} else {
|
||||
return y % m_filter_size;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
H3BloomFilter::hash_H3(uint64 value, int index)
|
||||
{
|
||||
uint64 mask = 1;
|
||||
uint64 val = value;
|
||||
int result = 0;
|
||||
|
||||
for (int i = 0; i < 64; i++) {
|
||||
if(val&mask) result ^= H3[i][index];
|
||||
val = val >> 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
93
simulators/gem5/src/mem/ruby/filters/H3BloomFilter.hh
Normal file
93
simulators/gem5/src/mem/ruby/filters/H3BloomFilter.hh
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_FILTERS_H3BLOOMFILTER_HH__
|
||||
#define __MEM_RUBY_FILTERS_H3BLOOMFILTER_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/filters/AbstractBloomFilter.hh"
|
||||
#include "mem/ruby/profiler/Profiler.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
class H3BloomFilter : public AbstractBloomFilter
|
||||
{
|
||||
public:
|
||||
H3BloomFilter(std::string config);
|
||||
~H3BloomFilter();
|
||||
|
||||
void clear();
|
||||
void increment(const Address& addr);
|
||||
void decrement(const Address& addr);
|
||||
void merge(AbstractBloomFilter * other_filter);
|
||||
void set(const Address& addr);
|
||||
void unset(const Address& addr);
|
||||
|
||||
bool isSet(const Address& addr);
|
||||
int getCount(const Address& addr);
|
||||
int getTotalCount();
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
int getIndex(const Address& addr);
|
||||
int readBit(const int index);
|
||||
void writeBit(const int index, const int value);
|
||||
|
||||
int
|
||||
operator[](const int index) const
|
||||
{
|
||||
return this->m_filter[index];
|
||||
}
|
||||
|
||||
private:
|
||||
int get_index(const Address& addr, int hashNumber);
|
||||
|
||||
int hash_H3(uint64 value, int index);
|
||||
|
||||
std::vector<int> m_filter;
|
||||
int m_filter_size;
|
||||
int m_num_hashes;
|
||||
int m_filter_size_bits;
|
||||
|
||||
int m_par_filter_size;
|
||||
int m_par_filter_size_bits;
|
||||
|
||||
int m_count_bits;
|
||||
int m_count;
|
||||
|
||||
int primes_list[6];// = {9323,11279,10247,30637,25717,43711};
|
||||
int mults_list[6]; //= {255,29,51,3,77,43};
|
||||
int adds_list[6]; //= {841,627,1555,241,7777,65391};
|
||||
|
||||
bool isParallel;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_FILTERS_H3BLOOMFILTER_HH__
|
||||
158
simulators/gem5/src/mem/ruby/filters/LSB_CountingBloomFilter.cc
Normal file
158
simulators/gem5/src/mem/ruby/filters/LSB_CountingBloomFilter.cc
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "base/intmath.hh"
|
||||
#include "base/str.hh"
|
||||
#include "mem/ruby/filters/LSB_CountingBloomFilter.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
LSB_CountingBloomFilter::LSB_CountingBloomFilter(string str)
|
||||
{
|
||||
string head, tail;
|
||||
#ifndef NDEBUG
|
||||
bool success =
|
||||
#endif
|
||||
split_first(str, head, tail, '_');
|
||||
assert(success);
|
||||
|
||||
m_filter_size = atoi(head.c_str());
|
||||
m_filter_size_bits = floorLog2(m_filter_size);
|
||||
|
||||
m_count = atoi(tail.c_str());
|
||||
m_count_bits = floorLog2(m_count);
|
||||
|
||||
m_filter.resize(m_filter_size);
|
||||
clear();
|
||||
}
|
||||
|
||||
LSB_CountingBloomFilter::~LSB_CountingBloomFilter()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
LSB_CountingBloomFilter::clear()
|
||||
{
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
m_filter[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LSB_CountingBloomFilter::increment(const Address& addr)
|
||||
{
|
||||
int i = get_index(addr);
|
||||
if (m_filter[i] < m_count)
|
||||
m_filter[i] += 1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LSB_CountingBloomFilter::decrement(const Address& addr)
|
||||
{
|
||||
int i = get_index(addr);
|
||||
if (m_filter[i] > 0)
|
||||
m_filter[i] -= 1;
|
||||
}
|
||||
|
||||
void
|
||||
LSB_CountingBloomFilter::merge(AbstractBloomFilter * other_filter)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
LSB_CountingBloomFilter::set(const Address& addr)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
LSB_CountingBloomFilter::unset(const Address& addr)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
bool
|
||||
LSB_CountingBloomFilter::isSet(const Address& addr)
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
LSB_CountingBloomFilter::getCount(const Address& addr)
|
||||
{
|
||||
return m_filter[get_index(addr)];
|
||||
}
|
||||
|
||||
int
|
||||
LSB_CountingBloomFilter::getTotalCount()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
count += m_filter[i];
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int
|
||||
LSB_CountingBloomFilter::getIndex(const Address& addr)
|
||||
{
|
||||
return get_index(addr);
|
||||
}
|
||||
|
||||
void
|
||||
LSB_CountingBloomFilter::print(ostream& out) const
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
LSB_CountingBloomFilter::readBit(const int index)
|
||||
{
|
||||
return 0;
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
LSB_CountingBloomFilter::writeBit(const int index, const int value)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int
|
||||
LSB_CountingBloomFilter::get_index(const Address& addr)
|
||||
{
|
||||
return addr.bitSelect(RubySystem::getBlockSizeBits(),
|
||||
RubySystem::getBlockSizeBits() +
|
||||
m_filter_size_bits - 1);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_FILTERS_LSBCOUNTINGBLOOMFILTER_HH__
|
||||
#define __MEM_RUBY_FILTERS_LSBCOUNTINGBLOOMFILTER_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/filters/AbstractBloomFilter.hh"
|
||||
|
||||
class LSB_CountingBloomFilter : public AbstractBloomFilter
|
||||
{
|
||||
public:
|
||||
LSB_CountingBloomFilter(std::string config);
|
||||
~LSB_CountingBloomFilter();
|
||||
|
||||
void clear();
|
||||
void increment(const Address& addr);
|
||||
void decrement(const Address& addr);
|
||||
void merge(AbstractBloomFilter * other_filter);
|
||||
void set(const Address& addr);
|
||||
void unset(const Address& addr);
|
||||
|
||||
bool isSet(const Address& addr);
|
||||
int getCount(const Address& addr);
|
||||
int getTotalCount();
|
||||
int getIndex(const Address& addr);
|
||||
int readBit(const int index);
|
||||
void writeBit(const int index, const int value);
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
int get_index(const Address& addr);
|
||||
|
||||
std::vector<int> m_filter;
|
||||
int m_filter_size;
|
||||
int m_filter_size_bits;
|
||||
|
||||
int m_count_bits;
|
||||
int m_count;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_FILTERS_LSBCOUNTINGBLOOMFILTER_HH__
|
||||
198
simulators/gem5/src/mem/ruby/filters/MultiBitSelBloomFilter.cc
Normal file
198
simulators/gem5/src/mem/ruby/filters/MultiBitSelBloomFilter.cc
Normal file
@ -0,0 +1,198 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/intmath.hh"
|
||||
#include "base/str.hh"
|
||||
#include "mem/ruby/filters/MultiBitSelBloomFilter.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
MultiBitSelBloomFilter::MultiBitSelBloomFilter(string str)
|
||||
{
|
||||
vector<string> items;
|
||||
tokenize(items, str, '_');
|
||||
assert(items.size() == 4);
|
||||
|
||||
// head contains filter size, tail contains bit offset from block number
|
||||
m_filter_size = atoi(items[0].c_str());
|
||||
m_num_hashes = atoi(items[1].c_str());
|
||||
m_skip_bits = atoi(items[2].c_str());
|
||||
|
||||
if (items[3] == "Regular") {
|
||||
isParallel = false;
|
||||
} else if (items[3] == "Parallel") {
|
||||
isParallel = true;
|
||||
} else {
|
||||
panic("ERROR: Incorrect config string for MultiBitSel Bloom! :%s",
|
||||
str);
|
||||
}
|
||||
|
||||
m_filter_size_bits = floorLog2(m_filter_size);
|
||||
|
||||
m_par_filter_size = m_filter_size / m_num_hashes;
|
||||
m_par_filter_size_bits = floorLog2(m_par_filter_size);
|
||||
|
||||
m_filter.resize(m_filter_size);
|
||||
clear();
|
||||
}
|
||||
|
||||
MultiBitSelBloomFilter::~MultiBitSelBloomFilter()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MultiBitSelBloomFilter::clear()
|
||||
{
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
m_filter[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MultiBitSelBloomFilter::increment(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MultiBitSelBloomFilter::decrement(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
void
|
||||
MultiBitSelBloomFilter::merge(AbstractBloomFilter *other_filter)
|
||||
{
|
||||
// assumes both filters are the same size!
|
||||
MultiBitSelBloomFilter * temp = (MultiBitSelBloomFilter*) other_filter;
|
||||
for(int i = 0; i < m_filter_size; ++i){
|
||||
m_filter[i] |= (*temp)[i];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MultiBitSelBloomFilter::set(const Address& addr)
|
||||
{
|
||||
for (int i = 0; i < m_num_hashes; i++) {
|
||||
int idx = get_index(addr, i);
|
||||
m_filter[idx] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MultiBitSelBloomFilter::unset(const Address& addr)
|
||||
{
|
||||
cout << "ERROR: Unset should never be called in a Bloom filter";
|
||||
assert(0);
|
||||
}
|
||||
|
||||
bool
|
||||
MultiBitSelBloomFilter::isSet(const Address& addr)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for (int i=0; i < m_num_hashes; i++) {
|
||||
int idx = get_index(addr, i);
|
||||
res = res && m_filter[idx];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
MultiBitSelBloomFilter::getCount(const Address& addr)
|
||||
{
|
||||
return isSet(addr)? 1: 0;
|
||||
}
|
||||
|
||||
int
|
||||
MultiBitSelBloomFilter::getIndex(const Address& addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
MultiBitSelBloomFilter::readBit(const int index)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
MultiBitSelBloomFilter::writeBit(const int index, const int value)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
MultiBitSelBloomFilter::getTotalCount()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
count += m_filter[i];
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void
|
||||
MultiBitSelBloomFilter::print(ostream& out) const
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
MultiBitSelBloomFilter::get_index(const Address& addr, int i)
|
||||
{
|
||||
// m_skip_bits is used to perform BitSelect after skipping some
|
||||
// bits. Used to simulate BitSel hashing on larger than cache-line
|
||||
// granularities
|
||||
uint64 x = (addr.getLineAddress()) >> m_skip_bits;
|
||||
int y = hash_bitsel(x, i, m_num_hashes, 30, m_filter_size_bits);
|
||||
//36-bit addresses, 6-bit cache lines
|
||||
|
||||
if (isParallel) {
|
||||
return (y % m_par_filter_size) + i*m_par_filter_size;
|
||||
} else {
|
||||
return y % m_filter_size;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
MultiBitSelBloomFilter::hash_bitsel(uint64 value, int index, int jump,
|
||||
int maxBits, int numBits)
|
||||
{
|
||||
uint64 mask = 1;
|
||||
int result = 0;
|
||||
int bit, i;
|
||||
|
||||
for (i = 0; i < numBits; i++) {
|
||||
bit = (index + jump*i) % maxBits;
|
||||
if (value & (mask << bit)) result += mask << i;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_FILTERS_MULTIBITSELBLOOMFILTER_HH__
|
||||
#define __MEM_RUBY_FILTERS_MULTIBITSELBLOOMFILTER_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/filters/AbstractBloomFilter.hh"
|
||||
#include "mem/ruby/profiler/Profiler.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
class MultiBitSelBloomFilter : public AbstractBloomFilter
|
||||
{
|
||||
public:
|
||||
MultiBitSelBloomFilter(std::string config);
|
||||
~MultiBitSelBloomFilter();
|
||||
|
||||
void clear();
|
||||
void increment(const Address& addr);
|
||||
void decrement(const Address& addr);
|
||||
void merge(AbstractBloomFilter * other_filter);
|
||||
void set(const Address& addr);
|
||||
void unset(const Address& addr);
|
||||
|
||||
bool isSet(const Address& addr);
|
||||
int getCount(const Address& addr);
|
||||
int getTotalCount();
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
int getIndex(const Address& addr);
|
||||
int readBit(const int index);
|
||||
void writeBit(const int index, const int value);
|
||||
|
||||
int
|
||||
operator[](const int index) const
|
||||
{
|
||||
return this->m_filter[index];
|
||||
}
|
||||
|
||||
private:
|
||||
int get_index(const Address& addr, int hashNumber);
|
||||
|
||||
int hash_bitsel(uint64 value, int index, int jump, int maxBits,
|
||||
int numBits);
|
||||
|
||||
std::vector<int> m_filter;
|
||||
int m_filter_size;
|
||||
int m_num_hashes;
|
||||
int m_filter_size_bits;
|
||||
int m_skip_bits;
|
||||
|
||||
int m_par_filter_size;
|
||||
int m_par_filter_size_bits;
|
||||
|
||||
int m_count_bits;
|
||||
int m_count;
|
||||
|
||||
bool isParallel;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_FILTERS_MULTIBITSELBLOOMFILTER_HH__
|
||||
188
simulators/gem5/src/mem/ruby/filters/MultiGrainBloomFilter.cc
Normal file
188
simulators/gem5/src/mem/ruby/filters/MultiGrainBloomFilter.cc
Normal file
@ -0,0 +1,188 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "base/intmath.hh"
|
||||
#include "base/str.hh"
|
||||
#include "mem/ruby/filters/MultiGrainBloomFilter.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
MultiGrainBloomFilter::MultiGrainBloomFilter(string str)
|
||||
{
|
||||
string head, tail;
|
||||
#ifndef NDEBUG
|
||||
bool success =
|
||||
#endif
|
||||
split_first(str, head, tail, '_');
|
||||
assert(success);
|
||||
|
||||
// head contains size of 1st bloom filter, tail contains size of
|
||||
// 2nd bloom filter
|
||||
|
||||
m_filter_size = atoi(head.c_str());
|
||||
m_filter_size_bits = floorLog2(m_filter_size);
|
||||
|
||||
m_page_filter_size = atoi(tail.c_str());
|
||||
m_page_filter_size_bits = floorLog2(m_page_filter_size);
|
||||
|
||||
m_filter.resize(m_filter_size);
|
||||
m_page_filter.resize(m_page_filter_size);
|
||||
clear();
|
||||
}
|
||||
|
||||
MultiGrainBloomFilter::~MultiGrainBloomFilter()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MultiGrainBloomFilter::clear()
|
||||
{
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
m_filter[i] = 0;
|
||||
}
|
||||
for(int i=0; i < m_page_filter_size; ++i){
|
||||
m_page_filter[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MultiGrainBloomFilter::increment(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MultiGrainBloomFilter::decrement(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
void
|
||||
MultiGrainBloomFilter::merge(AbstractBloomFilter *other_filter)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
MultiGrainBloomFilter::set(const Address& addr)
|
||||
{
|
||||
int i = get_block_index(addr);
|
||||
assert(i < m_filter_size);
|
||||
assert(get_page_index(addr) < m_page_filter_size);
|
||||
m_filter[i] = 1;
|
||||
m_page_filter[i] = 1;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MultiGrainBloomFilter::unset(const Address& addr)
|
||||
{
|
||||
// not used
|
||||
}
|
||||
|
||||
bool
|
||||
MultiGrainBloomFilter::isSet(const Address& addr)
|
||||
{
|
||||
int i = get_block_index(addr);
|
||||
assert(i < m_filter_size);
|
||||
assert(get_page_index(addr) < m_page_filter_size);
|
||||
// we have to have both indices set
|
||||
return (m_filter[i] && m_page_filter[i]);
|
||||
}
|
||||
|
||||
int
|
||||
MultiGrainBloomFilter::getCount(const Address& addr)
|
||||
{
|
||||
// not used
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
MultiGrainBloomFilter::getTotalCount()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
count += m_filter[i];
|
||||
}
|
||||
|
||||
for(int i=0; i < m_page_filter_size; ++i) {
|
||||
count += m_page_filter[i] = 0;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int
|
||||
MultiGrainBloomFilter::getIndex(const Address& addr)
|
||||
{
|
||||
return 0;
|
||||
// TODO
|
||||
}
|
||||
|
||||
int
|
||||
MultiGrainBloomFilter::readBit(const int index)
|
||||
{
|
||||
return 0;
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
MultiGrainBloomFilter::writeBit(const int index, const int value)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
MultiGrainBloomFilter::print(ostream& out) const
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
MultiGrainBloomFilter::get_block_index(const Address& addr)
|
||||
{
|
||||
// grap a chunk of bits after byte offset
|
||||
return addr.bitSelect(RubySystem::getBlockSizeBits(),
|
||||
RubySystem::getBlockSizeBits() +
|
||||
m_filter_size_bits - 1);
|
||||
}
|
||||
|
||||
int
|
||||
MultiGrainBloomFilter::get_page_index(const Address & addr)
|
||||
{
|
||||
int bits = RubySystem::getBlockSizeBits() + m_filter_size_bits - 1;
|
||||
|
||||
// grap a chunk of bits after first chunk
|
||||
return addr.bitSelect(bits, bits + m_page_filter_size_bits - 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_FILTERS_MULTIGRAINBLOOMFILTER_HH__
|
||||
#define __MEM_RUBY_FILTERS_MULTIGRAINBLOOMFILTER_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/filters/AbstractBloomFilter.hh"
|
||||
|
||||
class MultiGrainBloomFilter : public AbstractBloomFilter
|
||||
{
|
||||
public:
|
||||
MultiGrainBloomFilter(std::string str);
|
||||
~MultiGrainBloomFilter();
|
||||
|
||||
void clear();
|
||||
void increment(const Address& addr);
|
||||
void decrement(const Address& addr);
|
||||
void merge(AbstractBloomFilter * other_filter);
|
||||
void set(const Address& addr);
|
||||
void unset(const Address& addr);
|
||||
|
||||
bool isSet(const Address& addr);
|
||||
int getCount(const Address& addr);
|
||||
int getTotalCount();
|
||||
int getIndex(const Address& addr);
|
||||
int readBit(const int index);
|
||||
void writeBit(const int index, const int value);
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
int get_block_index(const Address& addr);
|
||||
int get_page_index(const Address & addr);
|
||||
|
||||
// The block filter
|
||||
std::vector<int> m_filter;
|
||||
int m_filter_size;
|
||||
int m_filter_size_bits;
|
||||
// The page number filter
|
||||
std::vector<int> m_page_filter;
|
||||
int m_page_filter_size;
|
||||
int m_page_filter_size_bits;
|
||||
|
||||
int m_count_bits;
|
||||
int m_count;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_FILTERS_MULTIGRAINBLOOMFILTER_HH__
|
||||
158
simulators/gem5/src/mem/ruby/filters/NonCountingBloomFilter.cc
Normal file
158
simulators/gem5/src/mem/ruby/filters/NonCountingBloomFilter.cc
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "base/intmath.hh"
|
||||
#include "base/str.hh"
|
||||
#include "mem/ruby/filters/NonCountingBloomFilter.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
NonCountingBloomFilter::NonCountingBloomFilter(string str)
|
||||
{
|
||||
string head, tail;
|
||||
#ifndef NDEBUG
|
||||
bool success =
|
||||
#endif
|
||||
split_first(str, head, tail, '_');
|
||||
assert(success);
|
||||
|
||||
// head contains filter size, tail contains bit offset from block number
|
||||
m_filter_size = atoi(head.c_str());
|
||||
m_offset = atoi(tail.c_str());
|
||||
m_filter_size_bits = floorLog2(m_filter_size);
|
||||
|
||||
m_filter.resize(m_filter_size);
|
||||
clear();
|
||||
}
|
||||
|
||||
NonCountingBloomFilter::~NonCountingBloomFilter()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
NonCountingBloomFilter::clear()
|
||||
{
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
m_filter[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NonCountingBloomFilter::increment(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
void
|
||||
NonCountingBloomFilter::decrement(const Address& addr)
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
||||
void
|
||||
NonCountingBloomFilter::merge(AbstractBloomFilter *other_filter)
|
||||
{
|
||||
// assumes both filters are the same size!
|
||||
NonCountingBloomFilter * temp = (NonCountingBloomFilter*) other_filter;
|
||||
for(int i = 0; i < m_filter_size; ++i){
|
||||
m_filter[i] |= (*temp)[i];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NonCountingBloomFilter::set(const Address& addr)
|
||||
{
|
||||
int i = get_index(addr);
|
||||
m_filter[i] = 1;
|
||||
}
|
||||
|
||||
void
|
||||
NonCountingBloomFilter::unset(const Address& addr)
|
||||
{
|
||||
int i = get_index(addr);
|
||||
m_filter[i] = 0;
|
||||
}
|
||||
|
||||
bool
|
||||
NonCountingBloomFilter::isSet(const Address& addr)
|
||||
{
|
||||
int i = get_index(addr);
|
||||
return (m_filter[i]);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
NonCountingBloomFilter::getCount(const Address& addr)
|
||||
{
|
||||
return m_filter[get_index(addr)];
|
||||
}
|
||||
|
||||
int
|
||||
NonCountingBloomFilter::getTotalCount()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < m_filter_size; i++) {
|
||||
count += m_filter[i];
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void
|
||||
NonCountingBloomFilter::print(ostream& out) const
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
NonCountingBloomFilter::getIndex(const Address& addr)
|
||||
{
|
||||
return get_index(addr);
|
||||
}
|
||||
|
||||
int
|
||||
NonCountingBloomFilter::readBit(const int index)
|
||||
{
|
||||
return m_filter[index];
|
||||
}
|
||||
|
||||
void
|
||||
NonCountingBloomFilter::writeBit(const int index, const int value)
|
||||
{
|
||||
m_filter[index] = value;
|
||||
}
|
||||
|
||||
int
|
||||
NonCountingBloomFilter::get_index(const Address& addr)
|
||||
{
|
||||
return addr.bitSelect(RubySystem::getBlockSizeBits() + m_offset,
|
||||
RubySystem::getBlockSizeBits() + m_offset +
|
||||
m_filter_size_bits - 1);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_FILTERS_NONCOUNTINGBLOOMFILTER_HH__
|
||||
#define __MEM_RUBY_FILTERS_NONCOUNTINGBLOOMFILTER_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Address.hh"
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/filters/AbstractBloomFilter.hh"
|
||||
|
||||
class NonCountingBloomFilter : public AbstractBloomFilter
|
||||
{
|
||||
public:
|
||||
NonCountingBloomFilter(std::string config);
|
||||
~NonCountingBloomFilter();
|
||||
|
||||
void clear();
|
||||
void increment(const Address& addr);
|
||||
void decrement(const Address& addr);
|
||||
void merge(AbstractBloomFilter * other_filter);
|
||||
void set(const Address& addr);
|
||||
void unset(const Address& addr);
|
||||
|
||||
bool isSet(const Address& addr);
|
||||
int getCount(const Address& addr);
|
||||
int getTotalCount();
|
||||
|
||||
int getIndex(const Address& addr);
|
||||
int readBit(const int index);
|
||||
void writeBit(const int index, const int value);
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
int
|
||||
operator[](const int index) const
|
||||
{
|
||||
return this->m_filter[index];
|
||||
}
|
||||
|
||||
private:
|
||||
int get_index(const Address& addr);
|
||||
|
||||
std::vector<int> m_filter;
|
||||
int m_filter_size;
|
||||
int m_offset;
|
||||
int m_filter_size_bits;
|
||||
|
||||
int m_count_bits;
|
||||
int m_count;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_FILTERS_NONCOUNTINGBLOOMFILTER_HH__
|
||||
43
simulators/gem5/src/mem/ruby/filters/SConscript
Normal file
43
simulators/gem5/src/mem/ruby/filters/SConscript
Normal file
@ -0,0 +1,43 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
||||
# 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.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['PROTOCOL'] == 'None':
|
||||
Return()
|
||||
|
||||
Source('BlockBloomFilter.cc')
|
||||
Source('BulkBloomFilter.cc')
|
||||
Source('GenericBloomFilter.cc')
|
||||
Source('H3BloomFilter.cc')
|
||||
Source('LSB_CountingBloomFilter.cc')
|
||||
Source('MultiBitSelBloomFilter.cc')
|
||||
Source('MultiGrainBloomFilter.cc')
|
||||
Source('NonCountingBloomFilter.cc')
|
||||
80
simulators/gem5/src/mem/ruby/network/BasicLink.cc
Normal file
80
simulators/gem5/src/mem/ruby/network/BasicLink.cc
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Advanced Micro Devices, Inc.
|
||||
* 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/network/BasicLink.hh"
|
||||
|
||||
BasicLink::BasicLink(const Params *p)
|
||||
: SimObject(p)
|
||||
{
|
||||
m_latency = p->latency;
|
||||
m_bandwidth_factor = p->bandwidth_factor;
|
||||
m_weight = p->weight;
|
||||
}
|
||||
|
||||
void
|
||||
BasicLink::init()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BasicLink::print(std::ostream& out) const
|
||||
{
|
||||
out << name();
|
||||
}
|
||||
|
||||
BasicLink *
|
||||
BasicLinkParams::create()
|
||||
{
|
||||
return new BasicLink(this);
|
||||
}
|
||||
|
||||
BasicExtLink::BasicExtLink(const Params *p)
|
||||
: BasicLink(p)
|
||||
{
|
||||
m_int_node = p->int_node;
|
||||
m_ext_node = p->ext_node;
|
||||
}
|
||||
|
||||
BasicExtLink *
|
||||
BasicExtLinkParams::create()
|
||||
{
|
||||
return new BasicExtLink(this);
|
||||
}
|
||||
|
||||
BasicIntLink::BasicIntLink(const Params *p)
|
||||
: BasicLink(p)
|
||||
{
|
||||
m_node_a = p->node_a;
|
||||
m_node_b = p->node_b;
|
||||
}
|
||||
|
||||
BasicIntLink *
|
||||
BasicIntLinkParams::create()
|
||||
{
|
||||
return new BasicIntLink(this);
|
||||
}
|
||||
96
simulators/gem5/src/mem/ruby/network/BasicLink.hh
Normal file
96
simulators/gem5/src/mem/ruby/network/BasicLink.hh
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Advanced Micro Devices, Inc.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_BASIC_LINK_HH__
|
||||
#define __MEM_RUBY_NETWORK_BASIC_LINK_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "params/BasicExtLink.hh"
|
||||
#include "params/BasicIntLink.hh"
|
||||
#include "params/BasicLink.hh"
|
||||
#include "mem/ruby/network/BasicRouter.hh"
|
||||
#include "mem/ruby/network/Topology.hh"
|
||||
#include "mem/ruby/slicc_interface/AbstractController.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
|
||||
class BasicLink : public SimObject
|
||||
{
|
||||
public:
|
||||
typedef BasicLinkParams Params;
|
||||
BasicLink(const Params *p);
|
||||
const Params *params() const { return (const Params *)_params; }
|
||||
|
||||
void init();
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
int m_latency;
|
||||
int m_bandwidth_factor;
|
||||
int m_weight;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const BasicLink& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
class BasicExtLink : public BasicLink
|
||||
{
|
||||
public:
|
||||
typedef BasicExtLinkParams Params;
|
||||
BasicExtLink(const Params *p);
|
||||
const Params *params() const { return (const Params *)_params; }
|
||||
|
||||
friend class Topology;
|
||||
|
||||
protected:
|
||||
BasicRouter* m_int_node;
|
||||
AbstractController* m_ext_node;
|
||||
};
|
||||
|
||||
class BasicIntLink : public BasicLink
|
||||
{
|
||||
public:
|
||||
typedef BasicIntLinkParams Params;
|
||||
BasicIntLink(const Params *p);
|
||||
const Params *params() const { return (const Params *)_params; }
|
||||
|
||||
friend class Topology;
|
||||
|
||||
protected:
|
||||
BasicRouter* m_node_a;
|
||||
BasicRouter* m_node_b;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_BASIC_LINK_HH__
|
||||
54
simulators/gem5/src/mem/ruby/network/BasicLink.py
Normal file
54
simulators/gem5/src/mem/ruby/network/BasicLink.py
Normal file
@ -0,0 +1,54 @@
|
||||
# Copyright (c) 2011 Advanced Micro Devices, Inc.
|
||||
# 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.
|
||||
#
|
||||
# Authors: Steve Reinhardt
|
||||
# Brad Beckmann
|
||||
|
||||
from m5.params import *
|
||||
from m5.SimObject import SimObject
|
||||
|
||||
class BasicLink(SimObject):
|
||||
type = 'BasicLink'
|
||||
link_id = Param.Int("ID in relation to other links")
|
||||
latency = Param.Int(1, "latency")
|
||||
# The following banwidth factor does not translate to the same value for
|
||||
# both the simple and Garnet models. For the most part, the bandwidth
|
||||
# factor is the width of the link in bytes, expect for certain situations
|
||||
# with regard to the simple network.
|
||||
bandwidth_factor = Param.Int("generic bandwidth factor, usually in bytes")
|
||||
weight = Param.Int(1, "used to restrict routing in shortest path analysis")
|
||||
|
||||
class BasicExtLink(BasicLink):
|
||||
type = 'BasicExtLink'
|
||||
ext_node = Param.RubyController("External node")
|
||||
int_node = Param.BasicRouter("ID of internal node")
|
||||
bandwidth_factor = 16
|
||||
|
||||
class BasicIntLink(BasicLink):
|
||||
type = 'BasicIntLink'
|
||||
node_a = Param.BasicRouter("Router on one end")
|
||||
node_b = Param.BasicRouter("Router on other end")
|
||||
bandwidth_factor = 16
|
||||
52
simulators/gem5/src/mem/ruby/network/BasicRouter.cc
Normal file
52
simulators/gem5/src/mem/ruby/network/BasicRouter.cc
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Advanced Micro Devices, Inc.
|
||||
* 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/network/BasicRouter.hh"
|
||||
|
||||
BasicRouter::BasicRouter(const Params *p)
|
||||
: SimObject(p)
|
||||
{
|
||||
m_id = p->router_id;
|
||||
}
|
||||
|
||||
void
|
||||
BasicRouter::init()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BasicRouter::print(std::ostream& out) const
|
||||
{
|
||||
out << name();
|
||||
}
|
||||
|
||||
BasicRouter *
|
||||
BasicRouterParams::create()
|
||||
{
|
||||
return new BasicRouter(this);
|
||||
}
|
||||
67
simulators/gem5/src/mem/ruby/network/BasicRouter.hh
Normal file
67
simulators/gem5/src/mem/ruby/network/BasicRouter.hh
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Advanced Micro Devices, Inc.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_BASIC_ROUTER_HH__
|
||||
#define __MEM_RUBY_NETWORK_BASIC_ROUTER_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "params/BasicRouter.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
|
||||
class BasicRouter : public SimObject
|
||||
{
|
||||
public:
|
||||
typedef BasicRouterParams Params;
|
||||
BasicRouter(const Params *p);
|
||||
const Params *params() const { return (const Params *)_params; }
|
||||
|
||||
void init();
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
friend class Topology;
|
||||
|
||||
protected:
|
||||
//
|
||||
// ID in relation to other routers in the system
|
||||
//
|
||||
int m_id;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const BasicRouter& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_BASIC_ROUTER_HH__
|
||||
35
simulators/gem5/src/mem/ruby/network/BasicRouter.py
Normal file
35
simulators/gem5/src/mem/ruby/network/BasicRouter.py
Normal file
@ -0,0 +1,35 @@
|
||||
# Copyright (c) 2011 Advanced Micro Devices, Inc.
|
||||
# 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.
|
||||
#
|
||||
# Authors: Steve Reinhardt
|
||||
# Brad Beckmann
|
||||
|
||||
from m5.params import *
|
||||
from m5.SimObject import SimObject
|
||||
|
||||
class BasicRouter(SimObject):
|
||||
type = 'BasicRouter'
|
||||
router_id = Param.Int("ID in relation to other routers")
|
||||
97
simulators/gem5/src/mem/ruby/network/Network.cc
Normal file
97
simulators/gem5/src/mem/ruby/network/Network.cc
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "base/misc.hh"
|
||||
#include "mem/protocol/MachineType.hh"
|
||||
#include "mem/ruby/network/Network.hh"
|
||||
#include "mem/ruby/network/Topology.hh"
|
||||
#include "mem/ruby/system/System.hh"
|
||||
|
||||
Network::Network(const Params *p)
|
||||
: SimObject(p)
|
||||
{
|
||||
m_virtual_networks = p->number_of_virtual_networks;
|
||||
m_topology_ptr = p->topology;
|
||||
m_control_msg_size = p->control_msg_size;
|
||||
|
||||
// Total nodes/controllers in network
|
||||
// Must make sure this is called after the State Machine constructors
|
||||
m_nodes = MachineType_base_number(MachineType_NUM);
|
||||
assert(m_nodes != 0);
|
||||
|
||||
assert(m_virtual_networks != 0);
|
||||
assert(m_topology_ptr != NULL);
|
||||
|
||||
// Initialize the controller's network pointers
|
||||
m_topology_ptr->initNetworkPtr(this);
|
||||
p->ruby_system->registerNetwork(this);
|
||||
}
|
||||
|
||||
void
|
||||
Network::init()
|
||||
{
|
||||
m_data_msg_size = RubySystem::getBlockSizeBytes() + m_control_msg_size;
|
||||
}
|
||||
|
||||
int
|
||||
Network::MessageSizeType_to_int(MessageSizeType size_type)
|
||||
{
|
||||
switch(size_type) {
|
||||
case MessageSizeType_Undefined:
|
||||
panic("Can't convert Undefined MessageSizeType to integer");
|
||||
break;
|
||||
case MessageSizeType_Control:
|
||||
case MessageSizeType_Request_Control:
|
||||
case MessageSizeType_Reissue_Control:
|
||||
case MessageSizeType_Response_Control:
|
||||
case MessageSizeType_Writeback_Control:
|
||||
case MessageSizeType_Broadcast_Control:
|
||||
case MessageSizeType_Multicast_Control:
|
||||
case MessageSizeType_Forwarded_Control:
|
||||
case MessageSizeType_Invalidate_Control:
|
||||
case MessageSizeType_Unblock_Control:
|
||||
case MessageSizeType_Persistent_Control:
|
||||
case MessageSizeType_Completion_Control:
|
||||
return m_control_msg_size;
|
||||
case MessageSizeType_Data:
|
||||
case MessageSizeType_Response_Data:
|
||||
case MessageSizeType_ResponseLocal_Data:
|
||||
case MessageSizeType_ResponseL2hit_Data:
|
||||
case MessageSizeType_Writeback_Data:
|
||||
return m_data_msg_size;
|
||||
default:
|
||||
panic("Invalid range for type MessageSizeType");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<Throttle*>*
|
||||
Network::getThrottles(NodeID id) const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
120
simulators/gem5/src/mem/ruby/network/Network.hh
Normal file
120
simulators/gem5/src/mem/ruby/network/Network.hh
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The Network class is the base class for classes that implement the
|
||||
* interconnection network between components (processor/cache
|
||||
* components and memory/directory components). The interconnection
|
||||
* network as described here is not a physical network, but a
|
||||
* programming concept used to implement all communication between
|
||||
* components. Thus parts of this 'network' will model the on-chip
|
||||
* connections between cache controllers and directory controllers as
|
||||
* well as the links between chip and network switches.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_NETWORK_HH__
|
||||
#define __MEM_RUBY_NETWORK_NETWORK_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/protocol/LinkDirection.hh"
|
||||
#include "mem/protocol/MessageSizeType.hh"
|
||||
#include "mem/ruby/common/TypeDefines.hh"
|
||||
#include "params/RubyNetwork.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
|
||||
class NetDest;
|
||||
class MessageBuffer;
|
||||
class Throttle;
|
||||
class Topology;
|
||||
|
||||
class Network : public SimObject
|
||||
{
|
||||
public:
|
||||
typedef RubyNetworkParams Params;
|
||||
Network(const Params *p);
|
||||
virtual ~Network() {}
|
||||
|
||||
virtual void init();
|
||||
|
||||
int getNumberOfVirtualNetworks() { return m_virtual_networks; }
|
||||
int MessageSizeType_to_int(MessageSizeType size_type);
|
||||
|
||||
// returns the queue requested for the given component
|
||||
virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered,
|
||||
int netNumber, std::string vnet_type) = 0;
|
||||
virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered,
|
||||
int netNumber, std::string vnet_type) = 0;
|
||||
virtual const std::vector<Throttle*>* getThrottles(NodeID id) const;
|
||||
virtual int getNumNodes() {return 1;}
|
||||
|
||||
virtual void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
|
||||
LinkDirection direction,
|
||||
const NetDest& routing_table_entry,
|
||||
bool isReconfiguration) = 0;
|
||||
virtual void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
|
||||
LinkDirection direction,
|
||||
const NetDest& routing_table_entry,
|
||||
bool isReconfiguration) = 0;
|
||||
virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
|
||||
LinkDirection direction,
|
||||
const NetDest& routing_table_entry,
|
||||
bool isReconfiguration) = 0;
|
||||
|
||||
virtual void reset() = 0;
|
||||
|
||||
virtual void printStats(std::ostream& out) const = 0;
|
||||
virtual void clearStats() = 0;
|
||||
virtual void printConfig(std::ostream& out) const = 0;
|
||||
virtual void print(std::ostream& out) const = 0;
|
||||
|
||||
protected:
|
||||
// Private copy constructor and assignment operator
|
||||
Network(const Network& obj);
|
||||
Network& operator=(const Network& obj);
|
||||
|
||||
protected:
|
||||
const std::string m_name;
|
||||
int m_nodes;
|
||||
int m_virtual_networks;
|
||||
Topology* m_topology_ptr;
|
||||
int m_control_msg_size;
|
||||
int m_data_msg_size;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const Network& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_NETWORK_HH__
|
||||
51
simulators/gem5/src/mem/ruby/network/Network.py
Normal file
51
simulators/gem5/src/mem/ruby/network/Network.py
Normal file
@ -0,0 +1,51 @@
|
||||
# Copyright (c) 2009 Advanced Micro Devices, Inc.
|
||||
# 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.
|
||||
#
|
||||
# Authors: Steve Reinhardt
|
||||
# Brad Beckmann
|
||||
|
||||
from m5.params import *
|
||||
from m5.SimObject import SimObject
|
||||
from BasicLink import BasicLink
|
||||
|
||||
class Topology(SimObject):
|
||||
type = 'Topology'
|
||||
description = Param.String("Not Specified",
|
||||
"the name of the imported topology module")
|
||||
ext_links = VectorParam.BasicExtLink("Links to external nodes")
|
||||
int_links = VectorParam.BasicIntLink("Links between internal nodes")
|
||||
routers = VectorParam.BasicRouter("Network routers")
|
||||
print_config = Param.Bool(False,
|
||||
"display topology config in the stats file")
|
||||
|
||||
class RubyNetwork(SimObject):
|
||||
type = 'RubyNetwork'
|
||||
cxx_class = 'Network'
|
||||
abstract = True
|
||||
number_of_virtual_networks = Param.Int(10, "");
|
||||
topology = Param.Topology("");
|
||||
control_msg_size = Param.Int(8, "");
|
||||
ruby_system = Param.RubySystem("");
|
||||
43
simulators/gem5/src/mem/ruby/network/SConscript
Normal file
43
simulators/gem5/src/mem/ruby/network/SConscript
Normal file
@ -0,0 +1,43 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
||||
# 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.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['PROTOCOL'] == 'None':
|
||||
Return()
|
||||
|
||||
SimObject('BasicLink.py')
|
||||
SimObject('BasicRouter.py')
|
||||
SimObject('Network.py')
|
||||
|
||||
Source('BasicLink.cc')
|
||||
Source('BasicRouter.cc')
|
||||
Source('Network.cc')
|
||||
Source('Topology.cc')
|
||||
432
simulators/gem5/src/mem/ruby/network/Topology.cc
Normal file
432
simulators/gem5/src/mem/ruby/network/Topology.cc
Normal file
@ -0,0 +1,432 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "debug/RubyNetwork.hh"
|
||||
#include "mem/protocol/MachineType.hh"
|
||||
#include "mem/protocol/TopologyType.hh"
|
||||
#include "mem/ruby/common/NetDest.hh"
|
||||
#include "mem/ruby/network/BasicLink.hh"
|
||||
#include "mem/ruby/network/BasicRouter.hh"
|
||||
#include "mem/ruby/network/Network.hh"
|
||||
#include "mem/ruby/network/Topology.hh"
|
||||
#include "mem/ruby/slicc_interface/AbstractController.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int INFINITE_LATENCY = 10000; // Yes, this is a big hack
|
||||
|
||||
class BasicRouter;
|
||||
|
||||
// Note: In this file, we use the first 2*m_nodes SwitchIDs to
|
||||
// represent the input and output endpoint links. These really are
|
||||
// not 'switches', as they will not have a Switch object allocated for
|
||||
// them. The first m_nodes SwitchIDs are the links into the network,
|
||||
// the second m_nodes set of SwitchIDs represent the the output queues
|
||||
// of the network.
|
||||
|
||||
// Helper functions based on chapter 29 of Cormen et al.
|
||||
void extend_shortest_path(Matrix& current_dist, Matrix& latencies,
|
||||
Matrix& inter_switches);
|
||||
Matrix shortest_path(const Matrix& weights, Matrix& latencies,
|
||||
Matrix& inter_switches);
|
||||
bool link_is_shortest_path_to_node(SwitchID src, SwitchID next,
|
||||
SwitchID final, const Matrix& weights, const Matrix& dist);
|
||||
NetDest shortest_path_to_node(SwitchID src, SwitchID next,
|
||||
const Matrix& weights, const Matrix& dist);
|
||||
|
||||
Topology::Topology(const Params *p)
|
||||
: SimObject(p)
|
||||
{
|
||||
m_print_config = p->print_config;
|
||||
m_number_of_switches = p->routers.size();
|
||||
|
||||
// initialize component latencies record
|
||||
m_component_latencies.resize(0);
|
||||
m_component_inter_switches.resize(0);
|
||||
|
||||
// Total nodes/controllers in network
|
||||
// Must make sure this is called after the State Machine constructors
|
||||
m_nodes = MachineType_base_number(MachineType_NUM);
|
||||
assert(m_nodes > 1);
|
||||
|
||||
if (m_nodes != params()->ext_links.size() &&
|
||||
m_nodes != params()->ext_links.size()) {
|
||||
fatal("m_nodes (%d) != ext_links vector length (%d)\n",
|
||||
m_nodes != params()->ext_links.size());
|
||||
}
|
||||
|
||||
// analyze both the internal and external links, create data structures
|
||||
// Note that the python created links are bi-directional, but that the
|
||||
// topology and networks utilize uni-directional links. Thus each
|
||||
// BasicLink is converted to two calls to add link, on for each direction
|
||||
for (vector<BasicExtLink*>::const_iterator i = params()->ext_links.begin();
|
||||
i != params()->ext_links.end(); ++i) {
|
||||
BasicExtLink *ext_link = (*i);
|
||||
AbstractController *abs_cntrl = ext_link->params()->ext_node;
|
||||
BasicRouter *router = ext_link->params()->int_node;
|
||||
|
||||
// Store the controller and ExtLink pointers for later
|
||||
m_controller_vector.push_back(abs_cntrl);
|
||||
m_ext_link_vector.push_back(ext_link);
|
||||
|
||||
int ext_idx1 = abs_cntrl->params()->cntrl_id;
|
||||
int ext_idx2 = ext_idx1 + m_nodes;
|
||||
int int_idx = router->params()->router_id + 2*m_nodes;
|
||||
|
||||
// create the internal uni-directional links in both directions
|
||||
// the first direction is marked: In
|
||||
addLink(ext_idx1, int_idx, ext_link, LinkDirection_In);
|
||||
// the first direction is marked: Out
|
||||
addLink(int_idx, ext_idx2, ext_link, LinkDirection_Out);
|
||||
}
|
||||
|
||||
for (vector<BasicIntLink*>::const_iterator i = params()->int_links.begin();
|
||||
i != params()->int_links.end(); ++i) {
|
||||
BasicIntLink *int_link = (*i);
|
||||
BasicRouter *router_a = int_link->params()->node_a;
|
||||
BasicRouter *router_b = int_link->params()->node_b;
|
||||
|
||||
// Store the IntLink pointers for later
|
||||
m_int_link_vector.push_back(int_link);
|
||||
|
||||
int a = router_a->params()->router_id + 2*m_nodes;
|
||||
int b = router_b->params()->router_id + 2*m_nodes;
|
||||
|
||||
// create the internal uni-directional links in both directions
|
||||
// the first direction is marked: In
|
||||
addLink(a, b, int_link, LinkDirection_In);
|
||||
// the second direction is marked: Out
|
||||
addLink(b, a, int_link, LinkDirection_Out);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Topology::init()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Topology::initNetworkPtr(Network* net_ptr)
|
||||
{
|
||||
for (vector<BasicExtLink*>::const_iterator i = params()->ext_links.begin();
|
||||
i != params()->ext_links.end(); ++i) {
|
||||
BasicExtLink *ext_link = (*i);
|
||||
AbstractController *abs_cntrl = ext_link->params()->ext_node;
|
||||
abs_cntrl->initNetworkPtr(net_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Topology::createLinks(Network *net, bool isReconfiguration)
|
||||
{
|
||||
// Find maximum switchID
|
||||
SwitchID max_switch_id = 0;
|
||||
for (LinkMap::const_iterator i = m_link_map.begin();
|
||||
i != m_link_map.end(); ++i) {
|
||||
std::pair<int, int> src_dest = (*i).first;
|
||||
max_switch_id = max(max_switch_id, src_dest.first);
|
||||
max_switch_id = max(max_switch_id, src_dest.second);
|
||||
}
|
||||
|
||||
// Initialize weight, latency, and inter switched vectors
|
||||
Matrix topology_weights;
|
||||
int num_switches = max_switch_id+1;
|
||||
topology_weights.resize(num_switches);
|
||||
m_component_latencies.resize(num_switches);
|
||||
m_component_inter_switches.resize(num_switches);
|
||||
|
||||
for (int i = 0; i < topology_weights.size(); i++) {
|
||||
topology_weights[i].resize(num_switches);
|
||||
m_component_latencies[i].resize(num_switches);
|
||||
m_component_inter_switches[i].resize(num_switches);
|
||||
|
||||
for (int j = 0; j < topology_weights[i].size(); j++) {
|
||||
topology_weights[i][j] = INFINITE_LATENCY;
|
||||
|
||||
// initialize to invalid values
|
||||
m_component_latencies[i][j] = -1;
|
||||
|
||||
// initially assume direct connections / no intermediate
|
||||
// switches between components
|
||||
m_component_inter_switches[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Set identity weights to zero
|
||||
for (int i = 0; i < topology_weights.size(); i++) {
|
||||
topology_weights[i][i] = 0;
|
||||
}
|
||||
|
||||
// Fill in the topology weights and bandwidth multipliers
|
||||
for (LinkMap::const_iterator i = m_link_map.begin();
|
||||
i != m_link_map.end(); ++i) {
|
||||
std::pair<int, int> src_dest = (*i).first;
|
||||
BasicLink* link = (*i).second.link;
|
||||
int src = src_dest.first;
|
||||
int dst = src_dest.second;
|
||||
m_component_latencies[src][dst] = link->m_latency;
|
||||
topology_weights[src][dst] = link->m_weight;
|
||||
}
|
||||
|
||||
// Walk topology and hookup the links
|
||||
Matrix dist = shortest_path(topology_weights, m_component_latencies,
|
||||
m_component_inter_switches);
|
||||
for (int i = 0; i < topology_weights.size(); i++) {
|
||||
for (int j = 0; j < topology_weights[i].size(); j++) {
|
||||
int weight = topology_weights[i][j];
|
||||
if (weight > 0 && weight != INFINITE_LATENCY) {
|
||||
NetDest destination_set = shortest_path_to_node(i, j,
|
||||
topology_weights, dist);
|
||||
makeLink(net, i, j, destination_set, isReconfiguration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Topology::addLink(SwitchID src, SwitchID dest, BasicLink* link,
|
||||
LinkDirection dir)
|
||||
{
|
||||
assert(src <= m_number_of_switches+m_nodes+m_nodes);
|
||||
assert(dest <= m_number_of_switches+m_nodes+m_nodes);
|
||||
|
||||
std::pair<int, int> src_dest_pair;
|
||||
LinkEntry link_entry;
|
||||
|
||||
src_dest_pair.first = src;
|
||||
src_dest_pair.second = dest;
|
||||
link_entry.direction = dir;
|
||||
link_entry.link = link;
|
||||
m_link_map[src_dest_pair] = link_entry;
|
||||
}
|
||||
|
||||
void
|
||||
Topology::makeLink(Network *net, SwitchID src, SwitchID dest,
|
||||
const NetDest& routing_table_entry, bool isReconfiguration)
|
||||
{
|
||||
// Make sure we're not trying to connect two end-point nodes
|
||||
// directly together
|
||||
assert(src >= 2 * m_nodes || dest >= 2 * m_nodes);
|
||||
|
||||
std::pair<int, int> src_dest;
|
||||
LinkEntry link_entry;
|
||||
|
||||
if (src < m_nodes) {
|
||||
src_dest.first = src;
|
||||
src_dest.second = dest;
|
||||
link_entry = m_link_map[src_dest];
|
||||
net->makeInLink(src, dest - (2 * m_nodes), link_entry.link,
|
||||
link_entry.direction,
|
||||
routing_table_entry,
|
||||
isReconfiguration);
|
||||
} else if (dest < 2*m_nodes) {
|
||||
assert(dest >= m_nodes);
|
||||
NodeID node = dest - m_nodes;
|
||||
src_dest.first = src;
|
||||
src_dest.second = dest;
|
||||
link_entry = m_link_map[src_dest];
|
||||
net->makeOutLink(src - (2 * m_nodes), node, link_entry.link,
|
||||
link_entry.direction,
|
||||
routing_table_entry,
|
||||
isReconfiguration);
|
||||
} else {
|
||||
assert((src >= 2 * m_nodes) && (dest >= 2 * m_nodes));
|
||||
src_dest.first = src;
|
||||
src_dest.second = dest;
|
||||
link_entry = m_link_map[src_dest];
|
||||
net->makeInternalLink(src - (2 * m_nodes), dest - (2 * m_nodes),
|
||||
link_entry.link, link_entry.direction,
|
||||
routing_table_entry, isReconfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Topology::printStats(std::ostream& out) const
|
||||
{
|
||||
for (int cntrl = 0; cntrl < m_controller_vector.size(); cntrl++) {
|
||||
m_controller_vector[cntrl]->printStats(out);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Topology::clearStats()
|
||||
{
|
||||
for (int cntrl = 0; cntrl < m_controller_vector.size(); cntrl++) {
|
||||
m_controller_vector[cntrl]->clearStats();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Topology::printConfig(std::ostream& out) const
|
||||
{
|
||||
if (m_print_config == false)
|
||||
return;
|
||||
|
||||
assert(m_component_latencies.size() > 0);
|
||||
|
||||
out << "--- Begin Topology Print ---" << endl
|
||||
<< endl
|
||||
<< "Topology print ONLY indicates the _NETWORK_ latency between two "
|
||||
<< "machines" << endl
|
||||
<< "It does NOT include the latency within the machines" << endl
|
||||
<< endl;
|
||||
|
||||
for (int m = 0; m < MachineType_NUM; m++) {
|
||||
int i_end = MachineType_base_count((MachineType)m);
|
||||
for (int i = 0; i < i_end; i++) {
|
||||
MachineID cur_mach = {(MachineType)m, i};
|
||||
out << cur_mach << " Network Latencies" << endl;
|
||||
for (int n = 0; n < MachineType_NUM; n++) {
|
||||
int j_end = MachineType_base_count((MachineType)n);
|
||||
for (int j = 0; j < j_end; j++) {
|
||||
MachineID dest_mach = {(MachineType)n, j};
|
||||
if (cur_mach == dest_mach)
|
||||
continue;
|
||||
|
||||
int src = MachineType_base_number((MachineType)m) + i;
|
||||
int dst = MachineType_base_number(MachineType_NUM) +
|
||||
MachineType_base_number((MachineType)n) + j;
|
||||
int link_latency = m_component_latencies[src][dst];
|
||||
int intermediate_switches =
|
||||
m_component_inter_switches[src][dst];
|
||||
|
||||
// NOTE switches are assumed to have single
|
||||
// cycle latency
|
||||
out << " " << cur_mach << " -> " << dest_mach
|
||||
<< " net_lat: "
|
||||
<< link_latency + intermediate_switches << endl;
|
||||
}
|
||||
}
|
||||
out << endl;
|
||||
}
|
||||
}
|
||||
|
||||
out << "--- End Topology Print ---" << endl;
|
||||
}
|
||||
|
||||
// The following all-pairs shortest path algorithm is based on the
|
||||
// discussion from Cormen et al., Chapter 26.1.
|
||||
void
|
||||
extend_shortest_path(Matrix& current_dist, Matrix& latencies,
|
||||
Matrix& inter_switches)
|
||||
{
|
||||
bool change = true;
|
||||
int nodes = current_dist.size();
|
||||
|
||||
while (change) {
|
||||
change = false;
|
||||
for (int i = 0; i < nodes; i++) {
|
||||
for (int j = 0; j < nodes; j++) {
|
||||
int minimum = current_dist[i][j];
|
||||
int previous_minimum = minimum;
|
||||
int intermediate_switch = -1;
|
||||
for (int k = 0; k < nodes; k++) {
|
||||
minimum = min(minimum,
|
||||
current_dist[i][k] + current_dist[k][j]);
|
||||
if (previous_minimum != minimum) {
|
||||
intermediate_switch = k;
|
||||
inter_switches[i][j] =
|
||||
inter_switches[i][k] +
|
||||
inter_switches[k][j] + 1;
|
||||
}
|
||||
previous_minimum = minimum;
|
||||
}
|
||||
if (current_dist[i][j] != minimum) {
|
||||
change = true;
|
||||
current_dist[i][j] = minimum;
|
||||
assert(intermediate_switch >= 0);
|
||||
assert(intermediate_switch < latencies[i].size());
|
||||
latencies[i][j] = latencies[i][intermediate_switch] +
|
||||
latencies[intermediate_switch][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Matrix
|
||||
shortest_path(const Matrix& weights, Matrix& latencies, Matrix& inter_switches)
|
||||
{
|
||||
Matrix dist = weights;
|
||||
extend_shortest_path(dist, latencies, inter_switches);
|
||||
return dist;
|
||||
}
|
||||
|
||||
bool
|
||||
link_is_shortest_path_to_node(SwitchID src, SwitchID next, SwitchID final,
|
||||
const Matrix& weights, const Matrix& dist)
|
||||
{
|
||||
return weights[src][next] + dist[next][final] == dist[src][final];
|
||||
}
|
||||
|
||||
NetDest
|
||||
shortest_path_to_node(SwitchID src, SwitchID next, const Matrix& weights,
|
||||
const Matrix& dist)
|
||||
{
|
||||
NetDest result;
|
||||
int d = 0;
|
||||
int machines;
|
||||
int max_machines;
|
||||
|
||||
machines = MachineType_NUM;
|
||||
max_machines = MachineType_base_number(MachineType_NUM);
|
||||
|
||||
for (int m = 0; m < machines; m++) {
|
||||
for (int i = 0; i < MachineType_base_count((MachineType)m); i++) {
|
||||
// we use "d+max_machines" below since the "destination"
|
||||
// switches for the machines are numbered
|
||||
// [MachineType_base_number(MachineType_NUM)...
|
||||
// 2*MachineType_base_number(MachineType_NUM)-1] for the
|
||||
// component network
|
||||
if (link_is_shortest_path_to_node(src, next, d + max_machines,
|
||||
weights, dist)) {
|
||||
MachineID mach = {(MachineType)m, i};
|
||||
result.add(mach);
|
||||
}
|
||||
d++;
|
||||
}
|
||||
}
|
||||
|
||||
DPRINTF(RubyNetwork, "Returning shortest path\n"
|
||||
"(src-(2*max_machines)): %d, (next-(2*max_machines)): %d, "
|
||||
"src: %d, next: %d, result: %s\n",
|
||||
(src-(2*max_machines)), (next-(2*max_machines)),
|
||||
src, next, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Topology *
|
||||
TopologyParams::create()
|
||||
{
|
||||
return new Topology(this);
|
||||
}
|
||||
|
||||
121
simulators/gem5/src/mem/ruby/network/Topology.hh
Normal file
121
simulators/gem5/src/mem/ruby/network/Topology.hh
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The topology here is configurable; it can be a hierachical (default
|
||||
* one) or a 2D torus or a 2D torus with half switches killed. I think
|
||||
* all input port has a one-input-one-output switch connected just to
|
||||
* control and bandwidth, since we don't control bandwidth on input
|
||||
* ports. Basically, the class has a vector of nodes and edges. First
|
||||
* 2*m_nodes elements in the node vector are input and output
|
||||
* ports. Edges are represented in two vectors of src and dest
|
||||
* nodes. All edges have latency.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_SIMPLE_TOPOLOGY_HH__
|
||||
#define __MEM_RUBY_NETWORK_SIMPLE_TOPOLOGY_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/protocol/LinkDirection.hh"
|
||||
#include "mem/ruby/common/TypeDefines.hh"
|
||||
#include "params/Topology.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
|
||||
class NetDest;
|
||||
class Network;
|
||||
|
||||
typedef std::vector<std::vector<int> > Matrix;
|
||||
|
||||
struct LinkEntry
|
||||
{
|
||||
BasicLink *link;
|
||||
LinkDirection direction;
|
||||
};
|
||||
|
||||
typedef std::map<std::pair<int, int>, LinkEntry> LinkMap;
|
||||
|
||||
class Topology : public SimObject
|
||||
{
|
||||
public:
|
||||
typedef TopologyParams Params;
|
||||
Topology(const Params *p);
|
||||
virtual ~Topology() {}
|
||||
const Params *params() const { return (const Params *)_params; }
|
||||
|
||||
void init();
|
||||
int numSwitches() const { return m_number_of_switches; }
|
||||
void createLinks(Network *net, bool isReconfiguration);
|
||||
|
||||
void initNetworkPtr(Network* net_ptr);
|
||||
|
||||
const std::string getName() { return m_name; }
|
||||
void printStats(std::ostream& out) const;
|
||||
void clearStats();
|
||||
void printConfig(std::ostream& out) const;
|
||||
void print(std::ostream& out) const { out << "[Topology]"; }
|
||||
|
||||
protected:
|
||||
void addLink(SwitchID src, SwitchID dest, BasicLink* link,
|
||||
LinkDirection dir);
|
||||
void makeLink(Network *net, SwitchID src, SwitchID dest,
|
||||
const NetDest& routing_table_entry,
|
||||
bool isReconfiguration);
|
||||
|
||||
std::string getDesignStr();
|
||||
// Private copy constructor and assignment operator
|
||||
Topology(const Topology& obj);
|
||||
Topology& operator=(const Topology& obj);
|
||||
|
||||
std::string m_name;
|
||||
bool m_print_config;
|
||||
NodeID m_nodes;
|
||||
int m_number_of_switches;
|
||||
|
||||
std::vector<AbstractController*> m_controller_vector;
|
||||
std::vector<BasicExtLink*> m_ext_link_vector;
|
||||
std::vector<BasicIntLink*> m_int_link_vector;
|
||||
|
||||
Matrix m_component_latencies;
|
||||
Matrix m_component_inter_switches;
|
||||
|
||||
LinkMap m_link_map;
|
||||
std::vector<BasicRouter*> m_router_vector;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const Topology& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_SIMPLE_TOPOLOGY_HH__
|
||||
277
simulators/gem5/src/mem/ruby/network/fault_model/FaultModel.cc
Normal file
277
simulators/gem5/src/mem/ruby/network/fault_model/FaultModel.cc
Normal file
@ -0,0 +1,277 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Massachusetts Institute of Technology
|
||||
* 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.
|
||||
*
|
||||
* Authors: Konstantinos Aisopos
|
||||
*/
|
||||
|
||||
/*
|
||||
* Official Tool Website: www.mit.edu/~kaisopos/FaultModel
|
||||
*
|
||||
* If you use our tool for academic research, we request that you cite:
|
||||
* Konstantinos Aisopos, Chia-Hsin Owen Chen, and Li-Shiuan Peh. Enabling
|
||||
* System-Level Modeling of Variation-Induced Faults in Networks-on-Chip.
|
||||
* Proceedings of the 48th Design Automation Conference (DAC'11)
|
||||
*/
|
||||
|
||||
// C++ includes
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
// GEM5 includes
|
||||
#include "FaultModel.hh"
|
||||
#include "base/misc.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define MAX(a,b) ((a > b) ? (a) : (b))
|
||||
|
||||
|
||||
FaultModel::FaultModel(const Params *p) : SimObject(p)
|
||||
{
|
||||
// read configurations into "configurations" vector
|
||||
// format: <buff/vc> <vcs> <10 fault types>
|
||||
bool more_records = true;
|
||||
for (int i = 0; more_records; i += (fields_per_conf_record)){
|
||||
system_conf configuration;
|
||||
configuration.buff_per_vc =
|
||||
p->baseline_fault_vector_database[i + conf_record_buff_per_vc];
|
||||
configuration.vcs =
|
||||
p->baseline_fault_vector_database[i + conf_record_vcs];
|
||||
for (int fault_index = 0; fault_index < number_of_fault_types;
|
||||
fault_index++){
|
||||
configuration.fault_type[fault_index] =
|
||||
p->baseline_fault_vector_database[i +
|
||||
conf_record_first_fault_type + fault_index] / 100;
|
||||
}
|
||||
configurations.push_back(configuration);
|
||||
if (p->baseline_fault_vector_database[i+fields_per_conf_record] < 0){
|
||||
more_records = false;
|
||||
}
|
||||
}
|
||||
|
||||
// read temperature weights into "temperature_weights" vector
|
||||
// format: <temperature> <weight>
|
||||
more_records = true;
|
||||
for (int i = 0; more_records; i += (fields_per_temperature_record)){
|
||||
int record_temperature =
|
||||
p->temperature_weights_database[i + temperature_record_temp];
|
||||
int record_weight =
|
||||
p->temperature_weights_database[i + temperature_record_weight];
|
||||
static int first_record = true;
|
||||
if (first_record){
|
||||
for (int temperature = 0; temperature < record_temperature;
|
||||
temperature++){
|
||||
temperature_weights.push_back(0);
|
||||
}
|
||||
first_record = false;
|
||||
}
|
||||
assert(record_temperature == temperature_weights.size());
|
||||
temperature_weights.push_back(record_weight);
|
||||
if (p->temperature_weights_database[i +
|
||||
fields_per_temperature_record] < 0){
|
||||
more_records = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string
|
||||
FaultModel::fault_type_to_string(int ft)
|
||||
{
|
||||
if (ft == data_corruption__few_bits){
|
||||
return "data_corruption__few_bits";
|
||||
} else if (ft == data_corruption__all_bits){
|
||||
return "data_corruption__all_bits";
|
||||
} else if (ft == flit_conservation__flit_duplication){
|
||||
return "flit_conservation__flit_duplication";
|
||||
} else if (ft == flit_conservation__flit_loss_or_split){
|
||||
return "flit_conservation__flit_loss_or_split";
|
||||
} else if (ft == misrouting){
|
||||
return "misrouting";
|
||||
} else if (ft == credit_conservation__credit_generation){
|
||||
return "credit_conservation__credit_generation";
|
||||
} else if (ft == credit_conservation__credit_loss){
|
||||
return "credit_conservation__credit_loss";
|
||||
} else if (ft == erroneous_allocation__VC){
|
||||
return "erroneous_allocation__VC";
|
||||
} else if (ft == erroneous_allocation__switch){
|
||||
return "erroneous_allocation__switch";
|
||||
} else if (ft == unfair_arbitration){
|
||||
return "unfair_arbitration";
|
||||
} else if (ft == number_of_fault_types){
|
||||
return "none";
|
||||
} else {
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
FaultModel::declare_router(int number_of_inputs,
|
||||
int number_of_outputs,
|
||||
int number_of_vcs_per_input,
|
||||
int number_of_buff_per_data_vc,
|
||||
int number_of_buff_per_ctrl_vc)
|
||||
{
|
||||
// check inputs (are they legal?)
|
||||
if (number_of_inputs <= 0 || number_of_outputs <= 0 ||
|
||||
number_of_vcs_per_input <= 0 || number_of_buff_per_data_vc <= 0 ||
|
||||
number_of_buff_per_ctrl_vc <= 0){
|
||||
fatal("Fault Model: ERROR in argument of FaultModel_declare_router!");
|
||||
}
|
||||
int number_of_buffers_per_vc = MAX(number_of_buff_per_data_vc,
|
||||
number_of_buff_per_ctrl_vc);
|
||||
int total_vcs = number_of_inputs * number_of_vcs_per_input;
|
||||
if (total_vcs > MAX_VCs){
|
||||
fatal("Fault Model: ERROR! Number inputs*VCs (MAX_VCs) unsupported");
|
||||
}
|
||||
if (number_of_buffers_per_vc > MAX_BUFFERS_per_VC){
|
||||
fatal("Fault Model: ERROR! buffers/VC (MAX_BUFFERS_per_VC) too high");
|
||||
}
|
||||
|
||||
// link the router to a DB record
|
||||
int record_hit = -1;
|
||||
for (int record = 0; record < configurations.size(); record++){
|
||||
if ((configurations[record].buff_per_vc == number_of_buffers_per_vc)&&
|
||||
(configurations[record].vcs == total_vcs)){
|
||||
record_hit = record;
|
||||
}
|
||||
}
|
||||
if (record_hit == -1){
|
||||
panic("Fault Model: ERROR! configuration not found in DB. BUG?");
|
||||
}
|
||||
|
||||
// remember the router and return its ID
|
||||
routers.push_back(configurations[record_hit]);
|
||||
static int router_index = 0;
|
||||
return router_index++;
|
||||
}
|
||||
|
||||
bool
|
||||
FaultModel::fault_vector(int routerID,
|
||||
int temperature_input,
|
||||
float fault_vector[])
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
// is the routerID recorded?
|
||||
if (routerID < 0 || routerID >= ((int) routers.size())){
|
||||
warn("Fault Model: ERROR! unknown router ID argument.");
|
||||
fatal("Fault Model: Did you enable the fault model flag)?");
|
||||
}
|
||||
|
||||
// is the temperature too high/too low?
|
||||
int temperature = temperature_input;
|
||||
if (temperature_input >= ((int) temperature_weights.size())){
|
||||
ok = false;
|
||||
warn_once("Fault Model: Temperature exceeded simulated upper bound.");
|
||||
warn_once("Fault Model: The fault model is not accurate any more.");
|
||||
temperature = (temperature_weights.size() - 1);
|
||||
} else if (temperature_input < 0){
|
||||
ok = false;
|
||||
warn_once("Fault Model: Temperature exceeded simulated lower bound.");
|
||||
warn_once("Fault Model: The fault model is not accurate any more.");
|
||||
temperature = 0;
|
||||
}
|
||||
|
||||
// recover the router record and return its fault vector
|
||||
for (int i = 0; i < number_of_fault_types; i++){
|
||||
fault_vector[i] = routers[routerID].fault_type[i] *
|
||||
((float)temperature_weights[temperature]);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
FaultModel::fault_prob(int routerID,
|
||||
int temperature_input,
|
||||
float *aggregate_fault_prob)
|
||||
{
|
||||
*aggregate_fault_prob = 1.0;
|
||||
bool ok = true;
|
||||
|
||||
// is the routerID recorded?
|
||||
if (routerID < 0 || routerID >= ((int) routers.size())){
|
||||
warn("Fault Model: ERROR! unknown router ID argument.");
|
||||
fatal("Fault Model: Did you enable the fault model flag)?");
|
||||
}
|
||||
|
||||
// is the temperature too high/too low?
|
||||
int temperature = temperature_input;
|
||||
if (temperature_input >= ((int) temperature_weights.size()) ){
|
||||
ok = false;
|
||||
warn_once("Fault Model: Temperature exceeded simulated upper bound.");
|
||||
warn_once("Fault Model: The fault model is not accurate any more.");
|
||||
temperature = (temperature_weights.size()-1);
|
||||
} else if (temperature_input < 0){
|
||||
ok = false;
|
||||
warn_once("Fault Model: Temperature exceeded simulated lower bound.");
|
||||
warn_once("Fault Model: The fault model is not accurate any more.");
|
||||
temperature = 0;
|
||||
}
|
||||
|
||||
// recover the router record and return its aggregate fault probability
|
||||
for (int i = 0; i < number_of_fault_types; i++){
|
||||
*aggregate_fault_prob= *aggregate_fault_prob *
|
||||
( 1.0 - (routers[routerID].fault_type[i] *
|
||||
((float)temperature_weights[temperature])) );
|
||||
}
|
||||
*aggregate_fault_prob = 1.0 - *aggregate_fault_prob;
|
||||
return ok;
|
||||
}
|
||||
|
||||
// this function is used only for debugging purposes
|
||||
void
|
||||
FaultModel::print(void)
|
||||
{
|
||||
cout << "--- PRINTING configurations ---\n";
|
||||
for (int record = 0; record < configurations.size(); record++){
|
||||
cout << "(" << record << ") ";
|
||||
cout << "VCs=" << configurations[record].vcs << " ";
|
||||
cout << "Buff/VC=" << configurations[record].buff_per_vc << " [";
|
||||
for (int fault_type_num = 0;
|
||||
fault_type_num < number_of_fault_types;
|
||||
fault_type_num++){
|
||||
cout << (100 * configurations[record].fault_type[fault_type_num]);
|
||||
cout << "% ";
|
||||
}
|
||||
cout << "]\n";
|
||||
}
|
||||
cout << "--- PRINTING temperature weights ---\n";
|
||||
for (int record = 0; record < temperature_weights.size(); record++){
|
||||
cout << "temperature=" << record << " => ";
|
||||
cout << "weight=" << temperature_weights[record];
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
FaultModel *
|
||||
FaultModelParams::create()
|
||||
{
|
||||
return new FaultModel(this);
|
||||
}
|
||||
141
simulators/gem5/src/mem/ruby/network/fault_model/FaultModel.hh
Normal file
141
simulators/gem5/src/mem/ruby/network/fault_model/FaultModel.hh
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Massachusetts Institute of Technology
|
||||
* 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.
|
||||
*
|
||||
* Authors: Konstantinos Aisopos
|
||||
*/
|
||||
|
||||
/*
|
||||
* Official Tool Website: www.mit.edu/~kaisopos/FaultModel
|
||||
*
|
||||
* If you use our tool for academic research, we request that you cite:
|
||||
* Konstantinos Aisopos, Chia-Hsin Owen Chen, and Li-Shiuan Peh. Enabling
|
||||
* System-Level Modeling of Variation-Induced Faults in Networks-on-Chip.
|
||||
* Proceedings of the 48th Design Automation Conference (DAC'11)
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_FAULT_MODEL_HH__
|
||||
#define __MEM_RUBY_NETWORK_FAULT_MODEL_HH__
|
||||
|
||||
// tool limitations and fixed inputs
|
||||
#define MAX_VCs 40
|
||||
#define MAX_BUFFERS_per_VC 5
|
||||
#define BASELINE_TEMPERATURE_CELCIUS 71
|
||||
|
||||
// C++ includes
|
||||
#include <string>
|
||||
|
||||
// GEM5 includes
|
||||
#include "params/FaultModel.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
|
||||
class FaultModel : public SimObject
|
||||
{
|
||||
public:
|
||||
typedef FaultModelParams Params;
|
||||
FaultModel(const Params *p);
|
||||
const Params *params() const { return (const Params *)_params; }
|
||||
|
||||
/************************************************************************/
|
||||
/********** THE FAULT TYPES SUPPORTED BY THE FAULT MODEL ***************/
|
||||
/************************************************************************/
|
||||
|
||||
enum fault_type
|
||||
{
|
||||
data_corruption__few_bits,
|
||||
data_corruption__all_bits,
|
||||
flit_conservation__flit_duplication,
|
||||
flit_conservation__flit_loss_or_split,
|
||||
misrouting,
|
||||
credit_conservation__credit_generation,
|
||||
credit_conservation__credit_loss,
|
||||
erroneous_allocation__VC,
|
||||
erroneous_allocation__switch,
|
||||
unfair_arbitration,
|
||||
number_of_fault_types
|
||||
};
|
||||
|
||||
/************************************************************************/
|
||||
/******************** INTERFACE OF THE FAULT MODEL *********************/
|
||||
/************************************************************************/
|
||||
|
||||
enum conf_record_format
|
||||
{
|
||||
conf_record_buff_per_vc,
|
||||
conf_record_vcs,
|
||||
conf_record_first_fault_type,
|
||||
conf_record_last_fault_type = conf_record_first_fault_type + number_of_fault_types - 1,
|
||||
fields_per_conf_record
|
||||
};
|
||||
|
||||
enum temperature_record_format
|
||||
{
|
||||
temperature_record_temp,
|
||||
temperature_record_weight,
|
||||
fields_per_temperature_record
|
||||
};
|
||||
|
||||
struct system_conf
|
||||
{
|
||||
int vcs;
|
||||
int buff_per_vc;
|
||||
float fault_type[number_of_fault_types];
|
||||
};
|
||||
|
||||
int declare_router(int number_of_inputs,
|
||||
int number_of_outputs,
|
||||
int number_of_vcs_per_vnet,
|
||||
int number_of_buff_per_data_vc,
|
||||
int number_of_buff_per_ctrl_vc);
|
||||
|
||||
std::string fault_type_to_string(int fault_type_index);
|
||||
|
||||
// the following 2 functions are called at runtime, to get the probability
|
||||
// of each fault type (fault_vector) or the aggregate fault probability
|
||||
// (fault_prob). Note: the probability values are provided by reference
|
||||
// (in the variables fault_vector[] & aggregate_fault_prob respectively).
|
||||
// Both functions also return a success flag (which is always true if
|
||||
// temperature ranges from 0C to 125C)
|
||||
|
||||
bool fault_vector(int routerID,
|
||||
int temperature,
|
||||
float fault_vector[]);
|
||||
|
||||
bool fault_prob(int routerID,
|
||||
int temperature,
|
||||
float *aggregate_fault_prob);
|
||||
|
||||
// for debugging purposes
|
||||
|
||||
void print(void);
|
||||
|
||||
private:
|
||||
std::vector <system_conf> configurations;
|
||||
std::vector <system_conf> routers;
|
||||
std::vector <int> temperature_weights;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_FAULT_MODEL_HH__
|
||||
302
simulators/gem5/src/mem/ruby/network/fault_model/FaultModel.py
Normal file
302
simulators/gem5/src/mem/ruby/network/fault_model/FaultModel.py
Normal file
@ -0,0 +1,302 @@
|
||||
# Copyright (c) 2011 Massachusetts Institute of Technology
|
||||
# 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.
|
||||
#
|
||||
# Authors: Konstantinos Aisopos
|
||||
|
||||
# Official Tool Website: www.mit.edu/~kaisopos/FaultModel
|
||||
#
|
||||
# If you use our tool for academic research, we request that you cite:
|
||||
# Konstantinos Aisopos, Chia-Hsin Owen Chen, and Li-Shiuan Peh. Enabling
|
||||
# System-Level Modeling of Variation-Induced Faults in Networks-on-Chip.
|
||||
# Proceedings of the 48th Design Automation Conference (DAC'11)
|
||||
|
||||
from m5.params import *
|
||||
from m5.SimObject import SimObject
|
||||
|
||||
class FaultModel(SimObject):
|
||||
type = 'FaultModel'
|
||||
cxx_class = 'FaultModel'
|
||||
|
||||
baseline_fault_vector_database = VectorParam.Float([
|
||||
5, 40, 0.080892, 0.109175, 0.018864, 0.130408, 0.059724, 0.077571, 0.034830, 0.083430, 0.067500, 0.121500,
|
||||
5, 39, 0.062640, 0.089100, 0.016821, 0.109620, 0.051462, 0.060210, 0.029700, 0.076140, 0.062100, 0.116100,
|
||||
5, 38, 0.050490, 0.076950, 0.015782, 0.091530, 0.044550, 0.046170, 0.025920, 0.070200, 0.057294, 0.110700,
|
||||
5, 37, 0.042120, 0.067770, 0.014191, 0.082890, 0.040986, 0.037800, 0.023760, 0.065880, 0.053568, 0.104490,
|
||||
5, 36, 0.035910, 0.061020, 0.013211, 0.075600, 0.035100, 0.030240, 0.021060, 0.061560, 0.049815, 0.100710,
|
||||
5, 35, 0.032130, 0.054810, 0.011964, 0.071550, 0.031860, 0.026730, 0.019710, 0.057510, 0.047169, 0.094230,
|
||||
5, 34, 0.028890, 0.051030, 0.011054, 0.067500, 0.030510, 0.023450, 0.018630, 0.054000, 0.045900, 0.088290,
|
||||
5, 33, 0.026460, 0.047250, 0.010160, 0.062640, 0.028971, 0.021600, 0.017280, 0.049410, 0.042903, 0.082080,
|
||||
5, 32, 0.024300, 0.042930, 0.009312, 0.057780, 0.027000, 0.019710, 0.016470, 0.045360, 0.041310, 0.075600,
|
||||
5, 31, 0.022410, 0.037260, 0.008910, 0.054540, 0.024732, 0.018171, 0.015660, 0.043470, 0.039447, 0.070740,
|
||||
5, 30, 0.021870, 0.032130, 0.008162, 0.050220, 0.023625, 0.016762, 0.013770, 0.039150, 0.037557, 0.065880,
|
||||
5, 29, 0.020790, 0.028080, 0.007657, 0.042660, 0.020061, 0.016043, 0.012690, 0.036720, 0.035451, 0.062370,
|
||||
5, 28, 0.019440, 0.025650, 0.007123, 0.037800, 0.018900, 0.015363, 0.011880, 0.033480, 0.032400, 0.057780,
|
||||
5, 27, 0.018473, 0.023760, 0.006737, 0.034830, 0.018036, 0.014153, 0.011232, 0.030240, 0.030645, 0.055890,
|
||||
5, 26, 0.017550, 0.021330, 0.006440, 0.032130, 0.016497, 0.013511, 0.010031, 0.027621, 0.028242, 0.051030,
|
||||
5, 25, 0.016462, 0.020520, 0.006210, 0.028890, 0.015822, 0.013095, 0.009442, 0.021600, 0.026379, 0.046170,
|
||||
5, 24, 0.015930, 0.018360, 0.005940, 0.026730, 0.015047, 0.012377, 0.008918, 0.018360, 0.023193, 0.037800,
|
||||
5, 23, 0.015390, 0.017931, 0.005594, 0.025488, 0.013365, 0.012037, 0.008775, 0.015120, 0.018657, 0.031590,
|
||||
5, 22, 0.014804, 0.017167, 0.005338, 0.023976, 0.012258, 0.011734, 0.008087, 0.013500, 0.015444, 0.026190,
|
||||
5, 21, 0.014180, 0.016548, 0.004995, 0.022194, 0.011807, 0.011073, 0.007236, 0.011070, 0.013500, 0.021870,
|
||||
5, 20, 0.013743, 0.016176, 0.004613, 0.020414, 0.011070, 0.010415, 0.006220, 0.010415, 0.010800, 0.019077,
|
||||
5, 19, 0.011877, 0.015412, 0.003861, 0.016659, 0.008235, 0.008640, 0.005400, 0.009720, 0.008532, 0.013770,
|
||||
5, 18, 0.011097, 0.014310, 0.003483, 0.014526, 0.006912, 0.007560, 0.003780, 0.008640, 0.006885, 0.010260,
|
||||
5, 17, 0.010419, 0.011939, 0.002700, 0.011394, 0.005400, 0.006318, 0.003038, 0.008100, 0.005400, 0.009450,
|
||||
5, 16, 0.009887, 0.009720, 0.002395, 0.010152, 0.004023, 0.005400, 0.002743, 0.007020, 0.004590, 0.008370,
|
||||
5, 15, 0.009617, 0.007825, 0.002079, 0.008289, 0.003780, 0.004806, 0.002236, 0.006480, 0.003996, 0.008127,
|
||||
5, 14, 0.008710, 0.006820, 0.001817, 0.007749, 0.003240, 0.004185, 0.001760, 0.005400, 0.002538, 0.006615,
|
||||
5, 13, 0.008116, 0.006566, 0.001566, 0.006426, 0.002741, 0.003564, 0.001299, 0.004590, 0.001917, 0.005994,
|
||||
5, 12, 0.007908, 0.006151, 0.001350, 0.005400, 0.002471, 0.003132, 0.000794, 0.004050, 0.001323, 0.005940,
|
||||
5, 11, 0.007690, 0.005627, 0.001094, 0.005076, 0.002363, 0.002052, 0.000567, 0.003510, 0.001188, 0.004860,
|
||||
5, 10, 0.007560, 0.005038, 0.000805, 0.004536, 0.001985, 0.000540, 0.000000, 0.002430, 0.000999, 0.003240,
|
||||
5, 9, 0.007314, 0.004193, 0.000540, 0.003834, 0.001715, 0.000000, 0.000000, 0.002160, 0.000945, 0.002700,
|
||||
5, 8, 0.006750, 0.003240, 0.000000, 0.003240, 0.001323, 0.000000, 0.000000, 0.001350, 0.000837, 0.002646,
|
||||
5, 7, 0.006461, 0.002700, 0.000000, 0.002700, 0.001215, 0.000000, 0.000000, 0.000000, 0.000810, 0.001809,
|
||||
5, 6, 0.006240, 0.001796, 0.000000, 0.002052, 0.001013, 0.000000, 0.000000, 0.000000, 0.000756, 0.001620,
|
||||
5, 5, 0.005430, 0.000675, 0.000000, 0.000864, 0.000864, 0.000000, 0.000000, 0.000000, 0.000729, 0.001593,
|
||||
5, 4, 0.003780, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.001080,
|
||||
5, 3, 0.001350, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000540,
|
||||
5, 2, 0.000540, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000270,
|
||||
5, 1, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
4, 40, 0.079484, 0.106785, 0.018198, 0.122699, 0.057538, 0.076974, 0.034813, 0.079276, 0.061426, 0.112509,
|
||||
4, 39, 0.062146, 0.088671, 0.016205, 0.108082, 0.050454, 0.059905, 0.029600, 0.075465, 0.057362, 0.106596,
|
||||
4, 38, 0.050047, 0.076478, 0.014924, 0.090994, 0.043475, 0.045808, 0.025794, 0.069220, 0.054351, 0.101993,
|
||||
4, 37, 0.041712, 0.067272, 0.013551, 0.082516, 0.040026, 0.037390, 0.023580, 0.064897, 0.051395, 0.097511,
|
||||
4, 36, 0.035384, 0.060487, 0.012434, 0.075287, 0.034229, 0.029784, 0.020859, 0.060167, 0.048222, 0.094055,
|
||||
4, 35, 0.031455, 0.054259, 0.011290, 0.071141, 0.031259, 0.026055, 0.019560, 0.055478, 0.045887, 0.088965,
|
||||
4, 34, 0.028307, 0.050427, 0.010342, 0.067048, 0.029835, 0.022525, 0.018495, 0.052523, 0.044253, 0.083727,
|
||||
4, 33, 0.025847, 0.046687, 0.009384, 0.062196, 0.028000, 0.020646, 0.017102, 0.048735, 0.041837, 0.079286,
|
||||
4, 32, 0.023688, 0.042449, 0.008645, 0.057303, 0.026070, 0.018765, 0.016315, 0.045001, 0.040163, 0.073143,
|
||||
4, 31, 0.021905, 0.036781, 0.008235, 0.054011, 0.024200, 0.017496, 0.015528, 0.042795, 0.038273, 0.068675,
|
||||
4, 30, 0.021195, 0.031563, 0.007456, 0.049545, 0.022757, 0.016081, 0.013646, 0.038817, 0.036410, 0.063086,
|
||||
4, 29, 0.020115, 0.027494, 0.006992, 0.042302, 0.019517, 0.015096, 0.012562, 0.035562, 0.034223, 0.059954,
|
||||
4, 28, 0.018889, 0.025040, 0.006472, 0.037295, 0.018383, 0.014540, 0.011760, 0.032949, 0.032022, 0.055782,
|
||||
4, 27, 0.017630, 0.023150, 0.006055, 0.034262, 0.017183, 0.013759, 0.010949, 0.029876, 0.030294, 0.053339,
|
||||
4, 26, 0.016875, 0.020762, 0.005743, 0.031664, 0.016002, 0.013123, 0.009740, 0.026487, 0.027824, 0.048681,
|
||||
4, 25, 0.015930, 0.019660, 0.005516, 0.028215, 0.015147, 0.012420, 0.009311, 0.020643, 0.025988, 0.043443,
|
||||
4, 24, 0.015425, 0.017790, 0.005211, 0.026190, 0.014530, 0.011838, 0.008783, 0.017314, 0.022518, 0.035681,
|
||||
4, 23, 0.014947, 0.017314, 0.004878, 0.024813, 0.012897, 0.011507, 0.008451, 0.014445, 0.017982, 0.029673,
|
||||
4, 22, 0.014430, 0.016278, 0.004610, 0.023077, 0.011945, 0.011148, 0.007918, 0.012825, 0.015107, 0.023814,
|
||||
4, 21, 0.013643, 0.015699, 0.004320, 0.021686, 0.011598, 0.010383, 0.007113, 0.010395, 0.013176, 0.019197,
|
||||
4, 20, 0.013023, 0.015244, 0.003995, 0.019155, 0.010935, 0.009227, 0.005914, 0.009227, 0.010665, 0.016234,
|
||||
4, 19, 0.011185, 0.014467, 0.003186, 0.015718, 0.007822, 0.007965, 0.005273, 0.008374, 0.008262, 0.012623,
|
||||
4, 18, 0.010399, 0.013419, 0.002808, 0.013696, 0.006681, 0.006885, 0.003579, 0.007579, 0.006197, 0.009315,
|
||||
4, 17, 0.009773, 0.011089, 0.002025, 0.010882, 0.005054, 0.005881, 0.002928, 0.007101, 0.004914, 0.008100,
|
||||
4, 16, 0.009054, 0.009054, 0.001743, 0.009477, 0.003799, 0.005081, 0.002365, 0.006345, 0.003942, 0.007061,
|
||||
4, 15, 0.008575, 0.006882, 0.001404, 0.007792, 0.003449, 0.004131, 0.001793, 0.005327, 0.002903, 0.006264,
|
||||
4, 14, 0.008069, 0.005655, 0.001169, 0.006920, 0.002808, 0.003510, 0.001277, 0.004307, 0.001782, 0.005184,
|
||||
4, 13, 0.007668, 0.005173, 0.000986, 0.005751, 0.002336, 0.002889, 0.000919, 0.003609, 0.001283, 0.004631,
|
||||
4, 12, 0.007403, 0.004563, 0.000675, 0.004852, 0.002066, 0.002457, 0.000532, 0.003083, 0.000662, 0.004374,
|
||||
4, 11, 0.007152, 0.004127, 0.000547, 0.004401, 0.001937, 0.001377, 0.000284, 0.002473, 0.000594, 0.003456,
|
||||
4, 10, 0.006885, 0.003530, 0.000402, 0.003920, 0.001613, 0.000405, 0.000000, 0.001755, 0.000500, 0.002565,
|
||||
4, 9, 0.006746, 0.002920, 0.000270, 0.003159, 0.001404, 0.000000, 0.000000, 0.001485, 0.000473, 0.002025,
|
||||
4, 8, 0.006257, 0.002290, 0.000000, 0.002565, 0.001107, 0.000000, 0.000000, 0.000675, 0.000419, 0.001971,
|
||||
4, 7, 0.005931, 0.001825, 0.000000, 0.002025, 0.000999, 0.000000, 0.000000, 0.000000, 0.000405, 0.001134,
|
||||
4, 6, 0.005585, 0.001199, 0.000000, 0.001463, 0.000844, 0.000000, 0.000000, 0.000000, 0.000378, 0.000945,
|
||||
4, 5, 0.004967, 0.000545, 0.000000, 0.000637, 0.000695, 0.000000, 0.000000, 0.000000, 0.000405, 0.000864,
|
||||
4, 4, 0.003105, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000540,
|
||||
4, 3, 0.000888, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000270,
|
||||
4, 2, 0.000270, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000135,
|
||||
4, 1, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
3, 40, 0.078075, 0.104396, 0.017531, 0.114991, 0.055352, 0.076378, 0.034795, 0.075122, 0.055352, 0.103518,
|
||||
3, 39, 0.061652, 0.088241, 0.015590, 0.106545, 0.049445, 0.059600, 0.029500, 0.074790, 0.052623, 0.097092,
|
||||
3, 38, 0.049604, 0.076005, 0.014067, 0.090458, 0.042401, 0.045446, 0.025669, 0.068240, 0.051408, 0.093285,
|
||||
3, 37, 0.041305, 0.066774, 0.012911, 0.082142, 0.039066, 0.036979, 0.023401, 0.063914, 0.049221, 0.090531,
|
||||
3, 36, 0.034857, 0.059954, 0.011656, 0.074974, 0.033359, 0.029327, 0.020658, 0.058774, 0.046629, 0.087399,
|
||||
3, 35, 0.030780, 0.053708, 0.010616, 0.070732, 0.030659, 0.025380, 0.019410, 0.053447, 0.044604, 0.083700,
|
||||
3, 34, 0.027724, 0.049823, 0.009631, 0.066596, 0.029160, 0.021600, 0.018360, 0.051046, 0.042606, 0.079164,
|
||||
3, 33, 0.025234, 0.046124, 0.008608, 0.061752, 0.027030, 0.019691, 0.016924, 0.048060, 0.040770, 0.076491,
|
||||
3, 32, 0.023077, 0.041969, 0.007979, 0.056827, 0.025140, 0.017820, 0.016160, 0.044642, 0.039015, 0.070686,
|
||||
3, 31, 0.021400, 0.036302, 0.007560, 0.053482, 0.023668, 0.016821, 0.015395, 0.042120, 0.037098, 0.066609,
|
||||
3, 30, 0.020520, 0.030996, 0.006750, 0.048870, 0.021889, 0.015401, 0.013522, 0.038483, 0.035262, 0.060291,
|
||||
3, 29, 0.019440, 0.026908, 0.006326, 0.041945, 0.018973, 0.014148, 0.012434, 0.034403, 0.032994, 0.057537,
|
||||
3, 28, 0.018338, 0.024430, 0.005821, 0.036790, 0.017866, 0.013716, 0.011640, 0.032419, 0.031644, 0.053784,
|
||||
3, 27, 0.016786, 0.022540, 0.005373, 0.033693, 0.016330, 0.013365, 0.010665, 0.029511, 0.029943, 0.050787,
|
||||
3, 26, 0.016200, 0.020193, 0.005046, 0.031199, 0.015506, 0.012736, 0.009450, 0.025353, 0.027405, 0.046332,
|
||||
3, 25, 0.015398, 0.018800, 0.004822, 0.027540, 0.014472, 0.011745, 0.009180, 0.019686, 0.025596, 0.040716,
|
||||
3, 24, 0.014920, 0.017221, 0.004482, 0.025650, 0.014013, 0.011300, 0.008648, 0.016268, 0.021843, 0.033561,
|
||||
3, 23, 0.014504, 0.016697, 0.004161, 0.024138, 0.012428, 0.010978, 0.008127, 0.013770, 0.017307, 0.027756,
|
||||
3, 22, 0.014056, 0.015390, 0.003883, 0.022178, 0.011632, 0.010562, 0.007749, 0.012150, 0.014769, 0.021438,
|
||||
3, 21, 0.013106, 0.014850, 0.003645, 0.021179, 0.011389, 0.009693, 0.006990, 0.009720, 0.012852, 0.016524,
|
||||
3, 20, 0.012304, 0.014313, 0.003378, 0.017896, 0.010800, 0.008039, 0.005608, 0.008039, 0.010530, 0.013392,
|
||||
3, 19, 0.010492, 0.013522, 0.002511, 0.014777, 0.007409, 0.007290, 0.005146, 0.007028, 0.007992, 0.011475,
|
||||
3, 18, 0.009701, 0.012528, 0.002133, 0.012866, 0.006450, 0.006210, 0.003378, 0.006518, 0.005508, 0.008370,
|
||||
3, 17, 0.009126, 0.010238, 0.001350, 0.010371, 0.004709, 0.005443, 0.002819, 0.006102, 0.004428, 0.006750,
|
||||
3, 16, 0.008222, 0.008389, 0.001091, 0.008802, 0.003575, 0.004763, 0.001987, 0.005670, 0.003294, 0.005751,
|
||||
3, 15, 0.007533, 0.005940, 0.000729, 0.007295, 0.003119, 0.003456, 0.001350, 0.004174, 0.001809, 0.004401,
|
||||
3, 14, 0.007428, 0.004490, 0.000521, 0.006091, 0.002376, 0.002835, 0.000794, 0.003213, 0.001026, 0.003753,
|
||||
3, 13, 0.007220, 0.003780, 0.000405, 0.005076, 0.001931, 0.002214, 0.000540, 0.002627, 0.000648, 0.003267,
|
||||
3, 12, 0.006899, 0.002975, 0.000000, 0.004304, 0.001661, 0.001782, 0.000270, 0.002117, 0.000000, 0.002808,
|
||||
3, 11, 0.006615, 0.002627, 0.000000, 0.003726, 0.001512, 0.000702, 0.000000, 0.001436, 0.000000, 0.002052,
|
||||
3, 10, 0.006210, 0.002022, 0.000000, 0.003305, 0.001242, 0.000270, 0.000000, 0.001080, 0.000000, 0.001890,
|
||||
3, 9, 0.006178, 0.001647, 0.000000, 0.002484, 0.001094, 0.000000, 0.000000, 0.000810, 0.000000, 0.001350,
|
||||
3, 8, 0.005765, 0.001339, 0.000000, 0.001890, 0.000891, 0.000000, 0.000000, 0.000000, 0.000000, 0.001296,
|
||||
3, 7, 0.005400, 0.000950, 0.000000, 0.001350, 0.000783, 0.000000, 0.000000, 0.000000, 0.000000, 0.000459,
|
||||
3, 6, 0.004930, 0.000602, 0.000000, 0.000875, 0.000675, 0.000000, 0.000000, 0.000000, 0.000000, 0.000270,
|
||||
3, 5, 0.004504, 0.000416, 0.000000, 0.000410, 0.000527, 0.000000, 0.000000, 0.000000, 0.000081, 0.000135,
|
||||
3, 4, 0.002430, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
3, 3, 0.000427, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
3, 2, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
3, 1, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
2, 40, 0.077418, 0.103451, 0.016828, 0.109064, 0.054341, 0.075962, 0.034795, 0.075122, 0.051976, 0.081459,
|
||||
2, 39, 0.060720, 0.087215, 0.014756, 0.103532, 0.048041, 0.059297, 0.029376, 0.074115, 0.050193, 0.077382,
|
||||
2, 38, 0.048859, 0.074947, 0.013362, 0.089180, 0.041598, 0.045021, 0.025537, 0.066803, 0.048722, 0.074655,
|
||||
2, 37, 0.040158, 0.065781, 0.012126, 0.080282, 0.038175, 0.036686, 0.023178, 0.062884, 0.047088, 0.072630,
|
||||
2, 36, 0.033881, 0.058774, 0.011001, 0.072895, 0.032542, 0.028434, 0.020461, 0.057424, 0.045225, 0.069728,
|
||||
2, 35, 0.030294, 0.052831, 0.009800, 0.069422, 0.029587, 0.024311, 0.019232, 0.052294, 0.043254, 0.067311,
|
||||
2, 34, 0.026957, 0.048824, 0.008847, 0.065224, 0.028054, 0.020655, 0.018095, 0.049876, 0.041553, 0.064112,
|
||||
2, 33, 0.024349, 0.045159, 0.007976, 0.060371, 0.026226, 0.018652, 0.016776, 0.047385, 0.039704, 0.061695,
|
||||
2, 32, 0.022078, 0.040951, 0.007202, 0.055330, 0.024365, 0.017145, 0.016065, 0.043944, 0.037719, 0.057699,
|
||||
2, 31, 0.020733, 0.035223, 0.006791, 0.052327, 0.022850, 0.015790, 0.015233, 0.041124, 0.035964, 0.054810,
|
||||
2, 30, 0.019626, 0.029984, 0.006021, 0.046551, 0.021086, 0.014673, 0.013133, 0.037757, 0.034007, 0.049923,
|
||||
2, 29, 0.018765, 0.025923, 0.005677, 0.039731, 0.018291, 0.013707, 0.011973, 0.033543, 0.031847, 0.047048,
|
||||
2, 28, 0.017539, 0.023491, 0.005192, 0.035180, 0.017033, 0.013349, 0.011092, 0.031296, 0.029970, 0.044240,
|
||||
2, 27, 0.016270, 0.021488, 0.004753, 0.032258, 0.015628, 0.012909, 0.010419, 0.028179, 0.028202, 0.041756,
|
||||
2, 26, 0.015525, 0.019557, 0.004390, 0.029942, 0.014652, 0.012207, 0.009339, 0.024975, 0.025745, 0.037679,
|
||||
2, 25, 0.014638, 0.018036, 0.004146, 0.026314, 0.013797, 0.011314, 0.009099, 0.018864, 0.023517, 0.032832,
|
||||
2, 24, 0.014075, 0.016575, 0.003788, 0.024444, 0.013045, 0.010780, 0.008541, 0.015587, 0.019710, 0.028013,
|
||||
2, 23, 0.013597, 0.015638, 0.003430, 0.022970, 0.011632, 0.010471, 0.008031, 0.012675, 0.015296, 0.023004,
|
||||
2, 22, 0.012968, 0.014715, 0.003089, 0.021096, 0.010990, 0.009929, 0.007642, 0.010846, 0.012825, 0.017253,
|
||||
2, 21, 0.012088, 0.014175, 0.002884, 0.020046, 0.010148, 0.009032, 0.006813, 0.008261, 0.010449, 0.013500,
|
||||
2, 20, 0.010976, 0.013381, 0.002693, 0.016732, 0.009381, 0.007742, 0.005400, 0.006437, 0.008100, 0.010841,
|
||||
2, 19, 0.009566, 0.012631, 0.001836, 0.013686, 0.007125, 0.006782, 0.003923, 0.005431, 0.005589, 0.008613,
|
||||
2, 18, 0.008982, 0.011349, 0.001458, 0.011744, 0.005708, 0.005742, 0.002724, 0.004884, 0.003618, 0.006764,
|
||||
2, 17, 0.008273, 0.009439, 0.000845, 0.009291, 0.004250, 0.004857, 0.002327, 0.004469, 0.002673, 0.004847,
|
||||
2, 16, 0.007679, 0.007704, 0.000545, 0.007737, 0.003394, 0.003988, 0.001534, 0.004045, 0.001742, 0.003834,
|
||||
2, 15, 0.007236, 0.005265, 0.000365, 0.006442, 0.002565, 0.003089, 0.000675, 0.003023, 0.000959, 0.002808,
|
||||
2, 14, 0.007090, 0.003787, 0.000261, 0.004990, 0.001802, 0.002400, 0.000397, 0.002249, 0.000608, 0.002457,
|
||||
2, 13, 0.006877, 0.003029, 0.000203, 0.004076, 0.001404, 0.001835, 0.000270, 0.001814, 0.000324, 0.002012,
|
||||
2, 12, 0.006575, 0.002311, 0.000000, 0.003502, 0.001249, 0.001458, 0.000135, 0.001436, 0.000000, 0.001850,
|
||||
2, 11, 0.006314, 0.001836, 0.000000, 0.003051, 0.001114, 0.000597, 0.000000, 0.000841, 0.000000, 0.001350,
|
||||
2, 10, 0.005971, 0.001434, 0.000000, 0.002570, 0.000945, 0.000230, 0.000000, 0.000540, 0.000000, 0.001215,
|
||||
2, 9, 0.005627, 0.001172, 0.000000, 0.001809, 0.000783, 0.000019, 0.000000, 0.000405, 0.000000, 0.000675,
|
||||
2, 8, 0.005144, 0.000940, 0.000000, 0.001276, 0.000668, 0.000038, 0.000000, 0.000000, 0.000000, 0.000648,
|
||||
2, 7, 0.004686, 0.000622, 0.000000, 0.000890, 0.000581, 0.000009, 0.000000, 0.000000, 0.000000, 0.000230,
|
||||
2, 6, 0.004247, 0.000428, 0.000000, 0.000541, 0.000473, 0.000019, 0.000000, 0.000000, 0.000000, 0.000135,
|
||||
2, 5, 0.003857, 0.000269, 0.000000, 0.000320, 0.000419, 0.000000, 0.000000, 0.000000, 0.000041, 0.000068,
|
||||
2, 4, 0.001459, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
2, 3, 0.000213, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
2, 2, 0.000011, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
2, 1, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
1, 40, 0.076761, 0.102506, 0.016124, 0.103138, 0.053330, 0.075546, 0.034795, 0.075122, 0.048600, 0.059400,
|
||||
1, 39, 0.059789, 0.086189, 0.013921, 0.100518, 0.046637, 0.058995, 0.029252, 0.073440, 0.047763, 0.057672,
|
||||
1, 38, 0.048114, 0.073888, 0.012658, 0.087901, 0.040794, 0.044596, 0.025404, 0.065367, 0.046035, 0.056025,
|
||||
1, 37, 0.039012, 0.064789, 0.011340, 0.078422, 0.037284, 0.036393, 0.022955, 0.061854, 0.044955, 0.054729,
|
||||
1, 36, 0.032905, 0.057594, 0.010346, 0.070816, 0.031725, 0.027540, 0.020264, 0.056074, 0.043821, 0.052056,
|
||||
1, 35, 0.029808, 0.051953, 0.008983, 0.068113, 0.028515, 0.023242, 0.019054, 0.051141, 0.041904, 0.050922,
|
||||
1, 34, 0.026190, 0.047825, 0.008062, 0.063852, 0.026949, 0.019710, 0.017831, 0.048705, 0.040500, 0.049059,
|
||||
1, 33, 0.023463, 0.044194, 0.007344, 0.058990, 0.025423, 0.017612, 0.016629, 0.046710, 0.038637, 0.046899,
|
||||
1, 32, 0.021079, 0.039933, 0.006426, 0.053833, 0.023590, 0.016470, 0.015971, 0.043246, 0.036423, 0.044712,
|
||||
1, 31, 0.020066, 0.034144, 0.006021, 0.051173, 0.022032, 0.014758, 0.015071, 0.040127, 0.034830, 0.043011,
|
||||
1, 30, 0.018733, 0.028971, 0.005292, 0.044231, 0.020282, 0.013946, 0.012744, 0.037031, 0.032751, 0.039555,
|
||||
1, 29, 0.018090, 0.024937, 0.005027, 0.037517, 0.017609, 0.013265, 0.011513, 0.032684, 0.030699, 0.036558,
|
||||
1, 28, 0.016740, 0.022553, 0.004563, 0.033569, 0.016200, 0.012982, 0.010544, 0.030173, 0.028296, 0.034695,
|
||||
1, 27, 0.015755, 0.020436, 0.004134, 0.030823, 0.014926, 0.012452, 0.010174, 0.026846, 0.026460, 0.032724,
|
||||
1, 26, 0.014850, 0.018922, 0.003734, 0.028685, 0.013797, 0.011678, 0.009229, 0.024597, 0.024084, 0.029025,
|
||||
1, 25, 0.013878, 0.017272, 0.003470, 0.025088, 0.013122, 0.010884, 0.009018, 0.018041, 0.021438, 0.024948,
|
||||
1, 24, 0.013230, 0.015930, 0.003094, 0.023239, 0.012077, 0.010260, 0.008435, 0.014907, 0.017577, 0.022464,
|
||||
1, 23, 0.012690, 0.014580, 0.002700, 0.021803, 0.010835, 0.009963, 0.007935, 0.011580, 0.013284, 0.018252,
|
||||
1, 22, 0.011880, 0.014040, 0.002295, 0.020015, 0.010349, 0.009296, 0.007536, 0.009542, 0.010881, 0.013068,
|
||||
1, 21, 0.011070, 0.013500, 0.002122, 0.018914, 0.008907, 0.008370, 0.006637, 0.006801, 0.008046, 0.010476,
|
||||
1, 20, 0.009647, 0.012450, 0.002009, 0.015568, 0.007962, 0.007444, 0.005192, 0.004836, 0.005670, 0.008289,
|
||||
1, 19, 0.008640, 0.011740, 0.001161, 0.012596, 0.006842, 0.006275, 0.002700, 0.003834, 0.003186, 0.005751,
|
||||
1, 18, 0.008262, 0.010171, 0.000783, 0.010622, 0.004965, 0.005273, 0.002071, 0.003251, 0.001728, 0.005157,
|
||||
1, 17, 0.007420, 0.008640, 0.000340, 0.008211, 0.003791, 0.004271, 0.001836, 0.002835, 0.000918, 0.002943,
|
||||
1, 16, 0.007136, 0.007020, 0.000000, 0.006672, 0.003213, 0.003213, 0.001080, 0.002419, 0.000189, 0.001917,
|
||||
1, 15, 0.006939, 0.004590, 0.000000, 0.005589, 0.002012, 0.002722, 0.000000, 0.001871, 0.000108, 0.001215,
|
||||
1, 14, 0.006753, 0.003083, 0.000000, 0.003888, 0.001229, 0.001966, 0.000000, 0.001285, 0.000189, 0.001161,
|
||||
1, 13, 0.006534, 0.002279, 0.000000, 0.003075, 0.000878, 0.001455, 0.000000, 0.001002, 0.000000, 0.000756,
|
||||
1, 12, 0.006251, 0.001647, 0.000000, 0.002700, 0.000837, 0.001134, 0.000000, 0.000756, 0.000000, 0.000891,
|
||||
1, 11, 0.006013, 0.001045, 0.000000, 0.002376, 0.000716, 0.000491, 0.000000, 0.000246, 0.000000, 0.000648,
|
||||
1, 10, 0.005732, 0.000845, 0.000000, 0.001836, 0.000648, 0.000189, 0.000000, 0.000000, 0.000000, 0.000540,
|
||||
1, 9, 0.005076, 0.000697, 0.000000, 0.001134, 0.000473, 0.000038, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
1, 8, 0.004523, 0.000540, 0.000000, 0.000662, 0.000446, 0.000076, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
1, 7, 0.003972, 0.000294, 0.000000, 0.000429, 0.000378, 0.000019, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
1, 6, 0.003564, 0.000254, 0.000000, 0.000208, 0.000270, 0.000038, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
1, 5, 0.003210, 0.000122, 0.000000, 0.000230, 0.000311, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
1, 4, 0.000489, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
1, 3, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
1, 2, 0.000022, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
1, 1, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
-1], "");
|
||||
|
||||
temperature_weights_database = VectorParam.Int([
|
||||
71, 1,
|
||||
72, 2,
|
||||
73, 3,
|
||||
74, 4,
|
||||
75, 5,
|
||||
76, 5,
|
||||
77, 6,
|
||||
78, 7,
|
||||
79, 8,
|
||||
80, 10,
|
||||
81, 11,
|
||||
82, 12,
|
||||
83, 12,
|
||||
84, 13,
|
||||
85, 14,
|
||||
86, 16,
|
||||
87, 17,
|
||||
88, 18,
|
||||
89, 19,
|
||||
90, 20,
|
||||
91, 22,
|
||||
92, 24,
|
||||
93, 26,
|
||||
94, 27,
|
||||
95, 29,
|
||||
96, 30,
|
||||
97, 32,
|
||||
98, 35,
|
||||
99, 37,
|
||||
100, 39,
|
||||
101, 42,
|
||||
102, 45,
|
||||
103, 47,
|
||||
104, 50,
|
||||
105, 53,
|
||||
106, 56,
|
||||
107, 61,
|
||||
108, 65,
|
||||
109, 70,
|
||||
110, 74,
|
||||
111, 78,
|
||||
112, 82,
|
||||
113, 89,
|
||||
114, 95,
|
||||
115, 100,
|
||||
116, 106,
|
||||
117, 115,
|
||||
118, 122,
|
||||
119, 130,
|
||||
120, 139,
|
||||
121, 147,
|
||||
122, 156,
|
||||
123, 169,
|
||||
124, 178,
|
||||
125, 190,
|
||||
-1], "");
|
||||
43
simulators/gem5/src/mem/ruby/network/fault_model/SConscript
Normal file
43
simulators/gem5/src/mem/ruby/network/fault_model/SConscript
Normal file
@ -0,0 +1,43 @@
|
||||
# Copyright (c) 2011 Massachusetts Institute of Technology
|
||||
# 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.
|
||||
#
|
||||
# Authors: Konstantinos Aisopos
|
||||
|
||||
# Official Tool Website: www.mit.edu/~kaisopos/FaultModel
|
||||
#
|
||||
# If you use our tool for academic research, we request that you cite:
|
||||
# Konstantinos Aisopos, Chia-Hsin Owen Chen, and Li-Shiuan Peh. Enabling
|
||||
# System-Level Modeling of Variation-Induced Faults in Networks-on-Chip.
|
||||
# Proceedings of the 48th Design Automation Conference (DAC'11)
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['PROTOCOL'] == 'None':
|
||||
Return()
|
||||
|
||||
SimObject('FaultModel.py')
|
||||
Source('FaultModel.cc')
|
||||
|
||||
193
simulators/gem5/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc
Normal file
193
simulators/gem5/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc
Normal file
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "mem/ruby/buffers/MessageBuffer.hh"
|
||||
#include "mem/ruby/network/BasicLink.hh"
|
||||
#include "mem/ruby/network/Topology.hh"
|
||||
#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
BaseGarnetNetwork::BaseGarnetNetwork(const Params *p)
|
||||
: Network(p)
|
||||
{
|
||||
m_ni_flit_size = p->ni_flit_size;
|
||||
m_vcs_per_vnet = p->vcs_per_vnet;
|
||||
m_enable_fault_model = p->enable_fault_model;
|
||||
if (m_enable_fault_model)
|
||||
fault_model = p->fault_model;
|
||||
|
||||
m_ruby_start = 0;
|
||||
|
||||
// Currently Garnet only supports uniform bandwidth for all
|
||||
// links and network interfaces.
|
||||
for (std::vector<BasicExtLink*>::const_iterator i =
|
||||
m_topology_ptr->params()->ext_links.begin();
|
||||
i != m_topology_ptr->params()->ext_links.end(); ++i) {
|
||||
BasicExtLink* ext_link = (*i);
|
||||
if (ext_link->params()->bandwidth_factor != m_ni_flit_size) {
|
||||
fatal("Garnet only supports uniform bw across all links and NIs\n");
|
||||
}
|
||||
}
|
||||
for (std::vector<BasicIntLink*>::const_iterator i =
|
||||
m_topology_ptr->params()->int_links.begin();
|
||||
i != m_topology_ptr->params()->int_links.end(); ++i) {
|
||||
BasicIntLink* int_link = (*i);
|
||||
if (int_link->params()->bandwidth_factor != m_ni_flit_size) {
|
||||
fatal("Garnet only supports uniform bw across all links and NIs\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate to and from queues
|
||||
|
||||
// Queues that are getting messages from protocol
|
||||
m_toNetQueues.resize(m_nodes);
|
||||
|
||||
// Queues that are feeding the protocol
|
||||
m_fromNetQueues.resize(m_nodes);
|
||||
|
||||
m_in_use.resize(m_virtual_networks);
|
||||
m_ordered.resize(m_virtual_networks);
|
||||
m_flits_received.resize(m_virtual_networks);
|
||||
m_flits_injected.resize(m_virtual_networks);
|
||||
m_network_latency.resize(m_virtual_networks);
|
||||
m_queueing_latency.resize(m_virtual_networks);
|
||||
for (int i = 0; i < m_virtual_networks; i++) {
|
||||
m_in_use[i] = false;
|
||||
m_ordered[i] = false;
|
||||
m_flits_received[i] = 0;
|
||||
m_flits_injected[i] = 0;
|
||||
m_network_latency[i] = 0.0;
|
||||
m_queueing_latency[i] = 0.0;
|
||||
}
|
||||
|
||||
for (int node = 0; node < m_nodes; node++) {
|
||||
// Setting number of virtual message buffers per Network Queue
|
||||
m_toNetQueues[node].resize(m_virtual_networks);
|
||||
m_fromNetQueues[node].resize(m_virtual_networks);
|
||||
|
||||
// Instantiating the Message Buffers that
|
||||
// interact with the coherence protocol
|
||||
for (int j = 0; j < m_virtual_networks; j++) {
|
||||
m_toNetQueues[node][j] = new MessageBuffer();
|
||||
m_fromNetQueues[node][j] = new MessageBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BaseGarnetNetwork::init()
|
||||
{
|
||||
Network::init();
|
||||
}
|
||||
|
||||
MessageBuffer*
|
||||
BaseGarnetNetwork::getToNetQueue(NodeID id, bool ordered, int network_num,
|
||||
string vnet_type)
|
||||
{
|
||||
checkNetworkAllocation(id, ordered, network_num, vnet_type);
|
||||
return m_toNetQueues[id][network_num];
|
||||
}
|
||||
|
||||
MessageBuffer*
|
||||
BaseGarnetNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num,
|
||||
string vnet_type)
|
||||
{
|
||||
checkNetworkAllocation(id, ordered, network_num, vnet_type);
|
||||
return m_fromNetQueues[id][network_num];
|
||||
}
|
||||
|
||||
void
|
||||
BaseGarnetNetwork::clearStats()
|
||||
{
|
||||
m_ruby_start = g_eventQueue_ptr->getTime();
|
||||
}
|
||||
|
||||
Time
|
||||
BaseGarnetNetwork::getRubyStartTime()
|
||||
{
|
||||
return m_ruby_start;
|
||||
}
|
||||
|
||||
void
|
||||
BaseGarnetNetwork::printStats(ostream& out) const
|
||||
{
|
||||
out << endl;
|
||||
out << "Network Stats" << endl;
|
||||
out << "-------------" << endl;
|
||||
out << endl;
|
||||
printPerformanceStats(out);
|
||||
printLinkStats(out);
|
||||
printPowerStats(out);
|
||||
m_topology_ptr->printStats(out);
|
||||
}
|
||||
|
||||
void
|
||||
BaseGarnetNetwork::printPerformanceStats(ostream& out) const
|
||||
{
|
||||
int total_flits_injected = 0;
|
||||
int total_flits_received = 0;
|
||||
int total_network_latency = 0.0;
|
||||
int total_queueing_latency = 0.0;
|
||||
|
||||
for (int i = 0; i < m_virtual_networks; i++) {
|
||||
if (!m_in_use[i])
|
||||
continue;
|
||||
|
||||
out << "[Vnet " << i << "]: flits injected = "
|
||||
<< m_flits_injected[i] << endl;
|
||||
out << "[Vnet " << i << "]: flits received = "
|
||||
<< m_flits_received[i] << endl;
|
||||
out << "[Vnet " << i << "]: average network latency = "
|
||||
<< ((double) m_network_latency[i] / (double) m_flits_received[i])
|
||||
<< endl;
|
||||
out << "[Vnet " << i << "]: average queueing (at source NI) latency = "
|
||||
<< ((double) m_queueing_latency[i] / (double) m_flits_received[i])
|
||||
<< endl;
|
||||
|
||||
out << endl;
|
||||
total_flits_injected += m_flits_injected[i];
|
||||
total_flits_received += m_flits_received[i];
|
||||
total_network_latency += m_network_latency[i];
|
||||
total_queueing_latency += m_queueing_latency[i];
|
||||
}
|
||||
out << "Total flits injected = " << total_flits_injected << endl;
|
||||
out << "Total flits received = " << total_flits_received << endl;
|
||||
out << "Average network latency = "
|
||||
<< ((double) total_network_latency/ (double) total_flits_received) << endl;
|
||||
out << "Average queueing (at source NI) latency = "
|
||||
<< ((double) total_queueing_latency/ (double) total_flits_received) << endl;
|
||||
out << "Average latency = "
|
||||
<< ((double) (total_queueing_latency + total_network_latency) /
|
||||
(double) total_flits_received)<< endl;
|
||||
out << "-------------" << endl;
|
||||
out << endl;
|
||||
}
|
||||
|
||||
110
simulators/gem5/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh
Normal file
110
simulators/gem5/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
/*
|
||||
* This header file is used to define all configuration parameters
|
||||
* required by the interconnection network.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_BASEGARNETNETWORK_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_BASEGARNETNETWORK_HH__
|
||||
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
#include "mem/ruby/network/Network.hh"
|
||||
#include "mem/ruby/network/fault_model/FaultModel.hh"
|
||||
#include "params/BaseGarnetNetwork.hh"
|
||||
#include "math.h"
|
||||
|
||||
class BaseGarnetNetwork : public Network
|
||||
{
|
||||
public:
|
||||
typedef BaseGarnetNetworkParams Params;
|
||||
BaseGarnetNetwork(const Params *p);
|
||||
|
||||
void init();
|
||||
int getNiFlitSize() {return m_ni_flit_size; }
|
||||
int getVCsPerVnet() {return m_vcs_per_vnet; }
|
||||
bool isFaultModelEnabled() {return m_enable_fault_model;}
|
||||
FaultModel* fault_model;
|
||||
|
||||
void increment_injected_flits(int vnet) { m_flits_injected[vnet]++; }
|
||||
void increment_received_flits(int vnet) { m_flits_received[vnet]++; }
|
||||
|
||||
void
|
||||
increment_network_latency(Time latency, int vnet)
|
||||
{
|
||||
m_network_latency[vnet] += latency;
|
||||
}
|
||||
|
||||
void
|
||||
increment_queueing_latency(Time latency, int vnet)
|
||||
{
|
||||
m_queueing_latency[vnet] += latency;
|
||||
}
|
||||
|
||||
// returns the queue requested for the given component
|
||||
MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num,
|
||||
std::string vnet_type);
|
||||
MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num,
|
||||
std::string vnet_type);
|
||||
|
||||
|
||||
bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
|
||||
bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
|
||||
virtual void checkNetworkAllocation(NodeID id, bool ordered,
|
||||
int network_num, std::string vnet_type) = 0;
|
||||
|
||||
Time getRubyStartTime();
|
||||
void clearStats();
|
||||
void printStats(std::ostream& out) const;
|
||||
void printPerformanceStats(std::ostream& out) const;
|
||||
virtual void printLinkStats(std::ostream& out) const = 0;
|
||||
virtual void printPowerStats(std::ostream& out) const = 0;
|
||||
|
||||
protected:
|
||||
int m_ni_flit_size;
|
||||
int m_vcs_per_vnet;
|
||||
bool m_enable_fault_model;
|
||||
|
||||
std::vector<int> m_flits_received;
|
||||
std::vector<int> m_flits_injected;
|
||||
std::vector<double> m_network_latency;
|
||||
std::vector<double> m_queueing_latency;
|
||||
|
||||
std::vector<bool> m_in_use;
|
||||
std::vector<bool> m_ordered;
|
||||
|
||||
std::vector<std::vector<MessageBuffer*> > m_toNetQueues;
|
||||
std::vector<std::vector<MessageBuffer*> > m_fromNetQueues;
|
||||
|
||||
Time m_ruby_start;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_BASEGARNETNETWORK_HH__
|
||||
@ -0,0 +1,40 @@
|
||||
# Copyright (c) 2008 Princeton University
|
||||
# Copyright (c) 2009 Advanced Micro Devices, Inc.
|
||||
# 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.
|
||||
#
|
||||
# Authors: Steve Reinhardt
|
||||
# Brad Beckmann
|
||||
|
||||
from m5.params import *
|
||||
from Network import RubyNetwork
|
||||
|
||||
class BaseGarnetNetwork(RubyNetwork):
|
||||
type = 'BaseGarnetNetwork'
|
||||
abstract = True
|
||||
ni_flit_size = Param.Int(16, "network interface flit size in bytes")
|
||||
vcs_per_vnet = Param.Int(4, "virtual channels per virtual network");
|
||||
enable_fault_model = Param.Bool(False, "enable network fault model");
|
||||
fault_model = Param.FaultModel(NULL, "network fault model");
|
||||
41
simulators/gem5/src/mem/ruby/network/garnet/NetworkHeader.hh
Normal file
41
simulators/gem5/src/mem/ruby/network/garnet/NetworkHeader.hh
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_NETWORKHEADER_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_NETWORKHEADER_HH__
|
||||
|
||||
enum flit_type {HEAD_, BODY_, TAIL_, HEAD_TAIL_, NUM_FLIT_TYPE_};
|
||||
enum VC_state_type {IDLE_, VC_AB_, ACTIVE_, NUM_VC_STATE_TYPE_};
|
||||
enum VNET_type {CTRL_VNET_, DATA_VNET_, NULL_VNET_, NUM_VNET_TYPE_};
|
||||
enum flit_stage {I_, VA_, SA_, ST_, LT_, NUM_FLIT_STAGE_};
|
||||
|
||||
#define INFINITE_ 10000
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_NETWORKHEADER_HH__
|
||||
39
simulators/gem5/src/mem/ruby/network/garnet/SConscript
Normal file
39
simulators/gem5/src/mem/ruby/network/garnet/SConscript
Normal file
@ -0,0 +1,39 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
||||
# 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.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['PROTOCOL'] == 'None':
|
||||
Return()
|
||||
|
||||
SimObject('BaseGarnetNetwork.py')
|
||||
|
||||
Source('BaseGarnetNetwork.cc')
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_CREDIT_LINK_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_CREDIT_LINK_D_HH__
|
||||
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
||||
#include "params/CreditLink_d.hh"
|
||||
|
||||
class CreditLink_d : public NetworkLink_d
|
||||
{
|
||||
public:
|
||||
typedef CreditLink_dParams Params;
|
||||
CreditLink_d(const Params *p) : NetworkLink_d(p) {}
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_CREDIT_LINK_D_HH__
|
||||
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Advanced Micro Devices, Inc.
|
||||
* 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/network/garnet/fixed-pipeline/CreditLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
||||
|
||||
GarnetIntLink_d::GarnetIntLink_d(const Params *p)
|
||||
: BasicLink(p)
|
||||
{
|
||||
m_network_links[0] = p->network_links[0];
|
||||
m_credit_links[0] = p->credit_links[0];
|
||||
m_network_links[1] = p->network_links[1];
|
||||
m_credit_links[1] = p->credit_links[1];
|
||||
}
|
||||
|
||||
void
|
||||
GarnetIntLink_d::init()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
GarnetIntLink_d::print(std::ostream& out) const
|
||||
{
|
||||
out << name();
|
||||
}
|
||||
|
||||
GarnetIntLink_d *
|
||||
GarnetIntLink_dParams::create()
|
||||
{
|
||||
return new GarnetIntLink_d(this);
|
||||
}
|
||||
|
||||
GarnetExtLink_d::GarnetExtLink_d(const Params *p)
|
||||
: BasicLink(p)
|
||||
{
|
||||
m_network_links[0] = p->network_links[0];
|
||||
m_credit_links[0] = p->credit_links[0];
|
||||
m_network_links[1] = p->network_links[1];
|
||||
m_credit_links[1] = p->credit_links[1];
|
||||
}
|
||||
|
||||
void
|
||||
GarnetExtLink_d::init()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
GarnetExtLink_d::print(std::ostream& out) const
|
||||
{
|
||||
out << name();
|
||||
}
|
||||
|
||||
GarnetExtLink_d *
|
||||
GarnetExtLink_dParams::create()
|
||||
{
|
||||
return new GarnetExtLink_d(this);
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Advanced Micro Devices, Inc.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_LINK_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_LINK_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/network/BasicLink.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
||||
#include "params/GarnetIntLink_d.hh"
|
||||
#include "params/GarnetExtLink_d.hh"
|
||||
|
||||
class GarnetIntLink_d : public BasicLink
|
||||
{
|
||||
public:
|
||||
typedef GarnetIntLink_dParams Params;
|
||||
GarnetIntLink_d(const Params *p);
|
||||
|
||||
void init();
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
friend class GarnetNetwork_d;
|
||||
|
||||
protected:
|
||||
NetworkLink_d* m_network_links[2];
|
||||
CreditLink_d* m_credit_links[2];
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const GarnetIntLink_d& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
class GarnetExtLink_d : public BasicLink
|
||||
{
|
||||
public:
|
||||
typedef GarnetExtLink_dParams Params;
|
||||
GarnetExtLink_d(const Params *p);
|
||||
|
||||
void init();
|
||||
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
friend class GarnetNetwork_d;
|
||||
|
||||
protected:
|
||||
NetworkLink_d* m_network_links[2];
|
||||
CreditLink_d* m_credit_links[2];
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const GarnetExtLink_d& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_LINK_HH__
|
||||
@ -0,0 +1,86 @@
|
||||
# Copyright (c) 2008 Princeton University
|
||||
# Copyright (c) 2009 Advanced Micro Devices, Inc.
|
||||
# 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.
|
||||
#
|
||||
# Authors: Steve Reinhardt
|
||||
# Brad Beckmann
|
||||
|
||||
from m5.params import *
|
||||
from m5.proxy import *
|
||||
from m5.SimObject import SimObject
|
||||
from BasicLink import BasicIntLink, BasicExtLink
|
||||
|
||||
class NetworkLink_d(SimObject):
|
||||
type = 'NetworkLink_d'
|
||||
link_id = Param.Int(Parent.link_id, "link id")
|
||||
link_latency = Param.Int(Parent.latency, "link latency")
|
||||
vcs_per_vnet = Param.Int(Parent.vcs_per_vnet,
|
||||
"virtual channels per virtual network")
|
||||
virt_nets = Param.Int(Parent.number_of_virtual_networks,
|
||||
"number of virtual networks")
|
||||
channel_width = Param.Int(Parent.bandwidth_factor,
|
||||
"channel width == bw factor")
|
||||
|
||||
class CreditLink_d(NetworkLink_d):
|
||||
type = 'CreditLink_d'
|
||||
|
||||
# Interior fixed pipeline links between routers
|
||||
class GarnetIntLink_d(BasicIntLink):
|
||||
type = 'GarnetIntLink_d'
|
||||
# The detailed fixed pipeline bi-directional link include two main
|
||||
# forward links and two backward flow-control links, one per direction
|
||||
nls = []
|
||||
# In uni-directional link
|
||||
nls.append(NetworkLink_d());
|
||||
# Out uni-directional link
|
||||
nls.append(NetworkLink_d());
|
||||
network_links = VectorParam.NetworkLink_d(nls, "forward links")
|
||||
|
||||
cls = []
|
||||
# In uni-directional link
|
||||
cls.append(CreditLink_d());
|
||||
# Out uni-directional link
|
||||
cls.append(CreditLink_d());
|
||||
credit_links = VectorParam.CreditLink_d(cls, "backward flow-control links")
|
||||
|
||||
# Exterior fixed pipeline links between a router and a controller
|
||||
class GarnetExtLink_d(BasicExtLink):
|
||||
type = 'GarnetExtLink_d'
|
||||
# The detailed fixed pipeline bi-directional link include two main
|
||||
# forward links and two backward flow-control links, one per direction
|
||||
nls = []
|
||||
# In uni-directional link
|
||||
nls.append(NetworkLink_d());
|
||||
# Out uni-directional link
|
||||
nls.append(NetworkLink_d());
|
||||
network_links = VectorParam.NetworkLink_d(nls, "forward links")
|
||||
|
||||
cls = []
|
||||
# In uni-directional link
|
||||
cls.append(CreditLink_d());
|
||||
# Out uni-directional link
|
||||
cls.append(CreditLink_d());
|
||||
credit_links = VectorParam.CreditLink_d(cls, "backward flow-control links")
|
||||
@ -0,0 +1,382 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "base/cast.hh"
|
||||
#include "base/stl_helpers.hh"
|
||||
#include "mem/protocol/MachineType.hh"
|
||||
#include "mem/ruby/buffers/MessageBuffer.hh"
|
||||
#include "mem/ruby/common/NetDest.hh"
|
||||
#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
|
||||
#include "mem/ruby/network/Topology.hh"
|
||||
|
||||
using namespace std;
|
||||
using m5::stl_helpers::deletePointers;
|
||||
|
||||
GarnetNetwork_d::GarnetNetwork_d(const Params *p)
|
||||
: BaseGarnetNetwork(p)
|
||||
{
|
||||
m_buffers_per_data_vc = p->buffers_per_data_vc;
|
||||
m_buffers_per_ctrl_vc = p->buffers_per_ctrl_vc;
|
||||
|
||||
m_vnet_type.resize(m_virtual_networks);
|
||||
for (int i = 0; i < m_vnet_type.size(); i++) {
|
||||
m_vnet_type[i] = NULL_VNET_; // default
|
||||
}
|
||||
|
||||
// record the routers
|
||||
for (vector<BasicRouter*>::const_iterator i =
|
||||
m_topology_ptr->params()->routers.begin();
|
||||
i != m_topology_ptr->params()->routers.end(); ++i) {
|
||||
Router_d* router = safe_cast<Router_d*>(*i);
|
||||
m_router_ptr_vector.push_back(router);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GarnetNetwork_d::init()
|
||||
{
|
||||
BaseGarnetNetwork::init();
|
||||
|
||||
// initialize the router's network pointers
|
||||
for (vector<Router_d*>::const_iterator i = m_router_ptr_vector.begin();
|
||||
i != m_router_ptr_vector.end(); ++i) {
|
||||
Router_d* router = safe_cast<Router_d*>(*i);
|
||||
router->init_net_ptr(this);
|
||||
}
|
||||
|
||||
// The topology pointer should have already been initialized in the
|
||||
// parent network constructor
|
||||
assert(m_topology_ptr != NULL);
|
||||
|
||||
for (int i=0; i < m_nodes; i++) {
|
||||
NetworkInterface_d *ni = new NetworkInterface_d(i, m_virtual_networks,
|
||||
this);
|
||||
ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]);
|
||||
m_ni_ptr_vector.push_back(ni);
|
||||
}
|
||||
// false because this isn't a reconfiguration
|
||||
m_topology_ptr->createLinks(this, false);
|
||||
|
||||
// initialize the link's network pointers
|
||||
for (vector<NetworkLink_d*>::const_iterator i = m_link_ptr_vector.begin();
|
||||
i != m_link_ptr_vector.end(); ++i) {
|
||||
NetworkLink_d* net_link = safe_cast<NetworkLink_d*>(*i);
|
||||
net_link->init_net_ptr(this);
|
||||
}
|
||||
|
||||
// FaultModel: declare each router to the fault model
|
||||
if(isFaultModelEnabled()){
|
||||
for (vector<Router_d*>::const_iterator i= m_router_ptr_vector.begin();
|
||||
i != m_router_ptr_vector.end(); ++i) {
|
||||
Router_d* router = safe_cast<Router_d*>(*i);
|
||||
int router_id M5_VAR_USED =
|
||||
fault_model->declare_router(router->get_num_inports(),
|
||||
router->get_num_outports(),
|
||||
router->get_vc_per_vnet(),
|
||||
getBuffersPerDataVC(),
|
||||
getBuffersPerCtrlVC());
|
||||
assert(router_id == router->get_id());
|
||||
router->printAggregateFaultProbability(cout);
|
||||
router->printFaultVector(cout);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GarnetNetwork_d::~GarnetNetwork_d()
|
||||
{
|
||||
for (int i = 0; i < m_nodes; i++) {
|
||||
deletePointers(m_toNetQueues[i]);
|
||||
deletePointers(m_fromNetQueues[i]);
|
||||
}
|
||||
deletePointers(m_router_ptr_vector);
|
||||
deletePointers(m_ni_ptr_vector);
|
||||
deletePointers(m_link_ptr_vector);
|
||||
deletePointers(m_creditlink_ptr_vector);
|
||||
delete m_topology_ptr;
|
||||
}
|
||||
|
||||
void
|
||||
GarnetNetwork_d::reset()
|
||||
{
|
||||
for (int node = 0; node < m_nodes; node++) {
|
||||
for (int j = 0; j < m_virtual_networks; j++) {
|
||||
m_toNetQueues[node][j]->clear();
|
||||
m_fromNetQueues[node][j]->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function creates a link from the Network Interface (NI)
|
||||
* into the Network.
|
||||
* It creates a Network Link from the NI to a Router and a Credit Link from
|
||||
* the Router to the NI
|
||||
*/
|
||||
|
||||
void
|
||||
GarnetNetwork_d::makeInLink(NodeID src, SwitchID dest, BasicLink* link,
|
||||
LinkDirection direction,
|
||||
const NetDest& routing_table_entry,
|
||||
bool isReconfiguration)
|
||||
{
|
||||
assert(src < m_nodes);
|
||||
|
||||
GarnetExtLink_d* garnet_link = safe_cast<GarnetExtLink_d*>(link);
|
||||
|
||||
if (!isReconfiguration) {
|
||||
NetworkLink_d* net_link = garnet_link->m_network_links[direction];
|
||||
CreditLink_d* credit_link = garnet_link->m_credit_links[direction];
|
||||
|
||||
m_link_ptr_vector.push_back(net_link);
|
||||
m_creditlink_ptr_vector.push_back(credit_link);
|
||||
|
||||
m_router_ptr_vector[dest]->addInPort(net_link, credit_link);
|
||||
m_ni_ptr_vector[src]->addOutPort(net_link, credit_link);
|
||||
} else {
|
||||
panic("Fatal Error:: Reconfiguration not allowed here");
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function creates a link from the Network to a NI.
|
||||
* It creates a Network Link from a Router to the NI and
|
||||
* a Credit Link from NI to the Router
|
||||
*/
|
||||
|
||||
void
|
||||
GarnetNetwork_d::makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
|
||||
LinkDirection direction,
|
||||
const NetDest& routing_table_entry,
|
||||
bool isReconfiguration)
|
||||
{
|
||||
assert(dest < m_nodes);
|
||||
assert(src < m_router_ptr_vector.size());
|
||||
assert(m_router_ptr_vector[src] != NULL);
|
||||
|
||||
GarnetExtLink_d* garnet_link = safe_cast<GarnetExtLink_d*>(link);
|
||||
|
||||
if (!isReconfiguration) {
|
||||
NetworkLink_d* net_link = garnet_link->m_network_links[direction];
|
||||
CreditLink_d* credit_link = garnet_link->m_credit_links[direction];
|
||||
|
||||
m_link_ptr_vector.push_back(net_link);
|
||||
m_creditlink_ptr_vector.push_back(credit_link);
|
||||
|
||||
m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry,
|
||||
link->m_weight,
|
||||
credit_link);
|
||||
m_ni_ptr_vector[dest]->addInPort(net_link, credit_link);
|
||||
} else {
|
||||
fatal("Fatal Error:: Reconfiguration not allowed here");
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function creates an internal network link
|
||||
*/
|
||||
|
||||
void
|
||||
GarnetNetwork_d::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
|
||||
LinkDirection direction,
|
||||
const NetDest& routing_table_entry,
|
||||
bool isReconfiguration)
|
||||
{
|
||||
GarnetIntLink_d* garnet_link = safe_cast<GarnetIntLink_d*>(link);
|
||||
|
||||
if (!isReconfiguration) {
|
||||
NetworkLink_d* net_link = garnet_link->m_network_links[direction];
|
||||
CreditLink_d* credit_link = garnet_link->m_credit_links[direction];
|
||||
|
||||
m_link_ptr_vector.push_back(net_link);
|
||||
m_creditlink_ptr_vector.push_back(credit_link);
|
||||
|
||||
m_router_ptr_vector[dest]->addInPort(net_link, credit_link);
|
||||
m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry,
|
||||
link->m_weight,
|
||||
credit_link);
|
||||
} else {
|
||||
fatal("Fatal Error:: Reconfiguration not allowed here");
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GarnetNetwork_d::checkNetworkAllocation(NodeID id, bool ordered,
|
||||
int network_num,
|
||||
string vnet_type)
|
||||
{
|
||||
assert(id < m_nodes);
|
||||
assert(network_num < m_virtual_networks);
|
||||
|
||||
if (ordered) {
|
||||
m_ordered[network_num] = true;
|
||||
}
|
||||
m_in_use[network_num] = true;
|
||||
|
||||
if (vnet_type == "response")
|
||||
m_vnet_type[network_num] = DATA_VNET_; // carries data (and ctrl) packets
|
||||
else
|
||||
m_vnet_type[network_num] = CTRL_VNET_; // carries only ctrl packets
|
||||
}
|
||||
|
||||
void
|
||||
GarnetNetwork_d::printLinkStats(ostream& out) const
|
||||
{
|
||||
double average_link_utilization = 0;
|
||||
vector<double> average_vc_load;
|
||||
average_vc_load.resize(m_virtual_networks*m_vcs_per_vnet);
|
||||
|
||||
for (int i = 0; i < m_virtual_networks*m_vcs_per_vnet; i++) {
|
||||
average_vc_load[i] = 0;
|
||||
}
|
||||
|
||||
out << endl;
|
||||
for (int i = 0; i < m_link_ptr_vector.size(); i++) {
|
||||
average_link_utilization +=
|
||||
(double(m_link_ptr_vector[i]->getLinkUtilization())) /
|
||||
(double(g_eventQueue_ptr->getTime()-m_ruby_start));
|
||||
|
||||
vector<int> vc_load = m_link_ptr_vector[i]->getVcLoad();
|
||||
for (int j = 0; j < vc_load.size(); j++) {
|
||||
assert(vc_load.size() == m_vcs_per_vnet*m_virtual_networks);
|
||||
average_vc_load[j] += vc_load[j];
|
||||
}
|
||||
}
|
||||
average_link_utilization =
|
||||
average_link_utilization/m_link_ptr_vector.size();
|
||||
out << "Average Link Utilization :: " << average_link_utilization
|
||||
<< " flits/cycle" << endl;
|
||||
out << "-------------" << endl;
|
||||
|
||||
for (int i = 0; i < m_vcs_per_vnet*m_virtual_networks; i++) {
|
||||
if (!m_in_use[i/m_vcs_per_vnet])
|
||||
continue;
|
||||
|
||||
average_vc_load[i] = (double(average_vc_load[i]) /
|
||||
(double(g_eventQueue_ptr->getTime()) - m_ruby_start));
|
||||
out << "Average VC Load [" << i << "] = " << average_vc_load[i]
|
||||
<< " flits/cycle " << endl;
|
||||
}
|
||||
out << "-------------" << endl;
|
||||
out << endl;
|
||||
}
|
||||
|
||||
void
|
||||
GarnetNetwork_d::printPowerStats(ostream& out) const
|
||||
{
|
||||
out << "Network Power" << endl;
|
||||
out << "-------------" << endl;
|
||||
double m_total_link_power = 0.0;
|
||||
double m_dynamic_link_power = 0.0;
|
||||
double m_static_link_power = 0.0;
|
||||
double m_total_router_power = 0.0;
|
||||
double m_dynamic_router_power = 0.0;
|
||||
double m_static_router_power = 0.0;
|
||||
double m_clk_power = 0.0;
|
||||
|
||||
for (int i = 0; i < m_link_ptr_vector.size(); i++) {
|
||||
m_total_link_power += m_link_ptr_vector[i]->calculate_power();
|
||||
m_dynamic_link_power += m_link_ptr_vector[i]->get_dynamic_power();
|
||||
m_static_link_power += m_link_ptr_vector[i]->get_static_power();
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_router_ptr_vector.size(); i++) {
|
||||
m_total_router_power += m_router_ptr_vector[i]->calculate_power();
|
||||
m_dynamic_router_power += m_router_ptr_vector[i]->get_dynamic_power();
|
||||
m_static_router_power += m_router_ptr_vector[i]->get_static_power();
|
||||
m_clk_power += m_router_ptr_vector[i]->get_clk_power();
|
||||
}
|
||||
out << "Link Dynamic Power = " << m_dynamic_link_power << " W" << endl;
|
||||
out << "Link Static Power = " << m_static_link_power << " W" << endl;
|
||||
out << "Total Link Power = " << m_total_link_power << " W " << endl;
|
||||
out << "Router Dynamic Power = " << m_dynamic_router_power << " W" << endl;
|
||||
out << "Router Clock Power = " << m_clk_power << " W" << endl;
|
||||
out << "Router Static Power = " << m_static_router_power << " W" << endl;
|
||||
out << "Total Router Power = " << m_total_router_power << " W " <<endl;
|
||||
out << "-------------" << endl;
|
||||
out << endl;
|
||||
}
|
||||
|
||||
void
|
||||
GarnetNetwork_d::printConfig(ostream& out) const
|
||||
{
|
||||
out << endl;
|
||||
out << "Network Configuration" << endl;
|
||||
out << "---------------------" << endl;
|
||||
out << "network: Garnet Fixed Pipeline" << endl;
|
||||
out << "topology: " << m_topology_ptr->getName() << endl;
|
||||
out << endl;
|
||||
|
||||
for (int i = 0; i < m_virtual_networks; i++) {
|
||||
out << "virtual_net_" << i << ": ";
|
||||
if (m_in_use[i]) {
|
||||
out << "active, ";
|
||||
if (m_ordered[i]) {
|
||||
out << "ordered" << endl;
|
||||
} else {
|
||||
out << "unordered" << endl;
|
||||
}
|
||||
} else {
|
||||
out << "inactive" << endl;
|
||||
}
|
||||
}
|
||||
out << endl;
|
||||
|
||||
for (int i = 0; i < m_ni_ptr_vector.size(); i++) {
|
||||
m_ni_ptr_vector[i]->printConfig(out);
|
||||
}
|
||||
for (int i = 0; i < m_router_ptr_vector.size(); i++) {
|
||||
m_router_ptr_vector[i]->printConfig(out);
|
||||
}
|
||||
m_topology_ptr->printConfig(out);
|
||||
}
|
||||
|
||||
void
|
||||
GarnetNetwork_d::print(ostream& out) const
|
||||
{
|
||||
out << "[GarnetNetwork_d]";
|
||||
}
|
||||
|
||||
GarnetNetwork_d *
|
||||
GarnetNetwork_dParams::create()
|
||||
{
|
||||
return new GarnetNetwork_d(this);
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
#include "mem/ruby/network/Network.hh"
|
||||
#include "params/GarnetNetwork_d.hh"
|
||||
|
||||
class FaultModel;
|
||||
class NetworkInterface_d;
|
||||
class MessageBuffer;
|
||||
class Router_d;
|
||||
class Topology;
|
||||
class NetDest;
|
||||
class NetworkLink_d;
|
||||
class CreditLink_d;
|
||||
|
||||
class GarnetNetwork_d : public BaseGarnetNetwork
|
||||
{
|
||||
public:
|
||||
typedef GarnetNetwork_dParams Params;
|
||||
GarnetNetwork_d(const Params *p);
|
||||
|
||||
~GarnetNetwork_d();
|
||||
|
||||
void init();
|
||||
|
||||
int getNumNodes() { return m_nodes; }
|
||||
|
||||
int getBuffersPerDataVC() {return m_buffers_per_data_vc; }
|
||||
int getBuffersPerCtrlVC() {return m_buffers_per_ctrl_vc; }
|
||||
|
||||
void printLinkStats(std::ostream& out) const;
|
||||
void printPowerStats(std::ostream& out) const;
|
||||
void printConfig(std::ostream& out) const;
|
||||
void print(std::ostream& out) const;
|
||||
|
||||
VNET_type
|
||||
get_vnet_type(int vc)
|
||||
{
|
||||
int vnet = vc/getVCsPerVnet();
|
||||
return m_vnet_type[vnet];
|
||||
}
|
||||
|
||||
void reset();
|
||||
|
||||
// Methods used by Topology to setup the network
|
||||
void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
|
||||
LinkDirection direction,
|
||||
const NetDest& routing_table_entry,
|
||||
bool isReconfiguration);
|
||||
void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
|
||||
LinkDirection direction,
|
||||
const NetDest& routing_table_entry,
|
||||
bool isReconfiguration);
|
||||
void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
|
||||
LinkDirection direction,
|
||||
const NetDest& routing_table_entry,
|
||||
bool isReconfiguration);
|
||||
|
||||
private:
|
||||
void checkNetworkAllocation(NodeID id, bool ordered, int network_num,
|
||||
std::string vnet_type);
|
||||
|
||||
GarnetNetwork_d(const GarnetNetwork_d& obj);
|
||||
GarnetNetwork_d& operator=(const GarnetNetwork_d& obj);
|
||||
|
||||
std::vector<VNET_type > m_vnet_type;
|
||||
|
||||
std::vector<Router_d *> m_router_ptr_vector; // All Routers in Network
|
||||
std::vector<NetworkLink_d *> m_link_ptr_vector; // All links in the network
|
||||
std::vector<CreditLink_d *> m_creditlink_ptr_vector; // All links in net
|
||||
std::vector<NetworkInterface_d *> m_ni_ptr_vector; // All NI's in Network
|
||||
|
||||
int m_buffers_per_data_vc;
|
||||
int m_buffers_per_ctrl_vc;
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& out, const GarnetNetwork_d& obj)
|
||||
{
|
||||
obj.print(out);
|
||||
out << std::flush;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__
|
||||
@ -0,0 +1,37 @@
|
||||
# Copyright (c) 2008 Princeton University
|
||||
# Copyright (c) 2009 Advanced Micro Devices, Inc.
|
||||
# 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.
|
||||
#
|
||||
# Authors: Steve Reinhardt
|
||||
# Brad Beckmann
|
||||
|
||||
from m5.params import *
|
||||
from BaseGarnetNetwork import BaseGarnetNetwork
|
||||
|
||||
class GarnetNetwork_d(BaseGarnetNetwork):
|
||||
type = 'GarnetNetwork_d'
|
||||
buffers_per_data_vc = Param.Int(4, "buffers per data virtual channel");
|
||||
buffers_per_ctrl_vc = Param.Int(1, "buffers per ctrl virtual channel");
|
||||
@ -0,0 +1,43 @@
|
||||
# Copyright (c) 2008 Princeton University
|
||||
# Copyright (c) 2009 Advanced Micro Devices, Inc.
|
||||
# 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.
|
||||
#
|
||||
# Authors: Steve Reinhardt
|
||||
# Brad Beckmann
|
||||
|
||||
from m5.params import *
|
||||
from m5.proxy import *
|
||||
from BasicRouter import BasicRouter
|
||||
|
||||
class GarnetRouter_d(BasicRouter):
|
||||
type = 'GarnetRouter_d'
|
||||
cxx_class = 'Router_d'
|
||||
vcs_per_vnet = Param.Int(Parent.vcs_per_vnet,
|
||||
"virtual channels per virtual network")
|
||||
virt_nets = Param.Int(Parent.number_of_virtual_networks,
|
||||
"number of virtual networks")
|
||||
|
||||
|
||||
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "base/stl_helpers.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
|
||||
|
||||
using namespace std;
|
||||
using m5::stl_helpers::deletePointers;
|
||||
|
||||
InputUnit_d::InputUnit_d(int id, Router_d *router)
|
||||
{
|
||||
m_id = id;
|
||||
m_router = router;
|
||||
m_num_vcs = m_router->get_num_vcs();
|
||||
m_vc_per_vnet = m_router->get_vc_per_vnet();
|
||||
|
||||
m_num_buffer_reads.resize(m_num_vcs/m_vc_per_vnet);
|
||||
m_num_buffer_writes.resize(m_num_vcs/m_vc_per_vnet);
|
||||
for (int i = 0; i < m_num_buffer_reads.size(); i++) {
|
||||
m_num_buffer_reads[i] = 0;
|
||||
m_num_buffer_writes[i] = 0;
|
||||
}
|
||||
|
||||
creditQueue = new flitBuffer_d();
|
||||
// Instantiating the virtual channels
|
||||
m_vcs.resize(m_num_vcs);
|
||||
for (int i=0; i < m_num_vcs; i++) {
|
||||
m_vcs[i] = new VirtualChannel_d(i);
|
||||
}
|
||||
}
|
||||
|
||||
InputUnit_d::~InputUnit_d()
|
||||
{
|
||||
delete creditQueue;
|
||||
deletePointers(m_vcs);
|
||||
}
|
||||
|
||||
void
|
||||
InputUnit_d::wakeup()
|
||||
{
|
||||
flit_d *t_flit;
|
||||
if (m_in_link->isReady()) {
|
||||
|
||||
t_flit = m_in_link->consumeLink();
|
||||
int vc = t_flit->get_vc();
|
||||
|
||||
if ((t_flit->get_type() == HEAD_) ||
|
||||
(t_flit->get_type() == HEAD_TAIL_)) {
|
||||
|
||||
assert(m_vcs[vc]->get_state() == IDLE_);
|
||||
// Do the route computation for this vc
|
||||
m_router->route_req(t_flit, this, vc);
|
||||
|
||||
m_vcs[vc]->set_enqueue_time(g_eventQueue_ptr->getTime());
|
||||
} else {
|
||||
t_flit->advance_stage(SA_);
|
||||
m_router->swarb_req();
|
||||
}
|
||||
// write flit into input buffer
|
||||
m_vcs[vc]->insertFlit(t_flit);
|
||||
|
||||
int vnet = vc/m_vc_per_vnet;
|
||||
// number of writes same as reads
|
||||
// any flit that is written will be read only once
|
||||
m_num_buffer_writes[vnet]++;
|
||||
m_num_buffer_reads[vnet]++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InputUnit_d::printConfig(ostream& out)
|
||||
{
|
||||
out << endl;
|
||||
out << "InputUnit Configuration" << endl;
|
||||
out << "---------------------" << endl;
|
||||
out << "id = " << m_id << endl;
|
||||
out << "In link is " << m_in_link->get_id() << endl;
|
||||
}
|
||||
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_INPUT_UNIT_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_INPUT_UNIT_D_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Consumer.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
|
||||
class Router_d;
|
||||
|
||||
class InputUnit_d : public Consumer
|
||||
{
|
||||
public:
|
||||
InputUnit_d(int id, Router_d *router);
|
||||
~InputUnit_d();
|
||||
|
||||
void wakeup();
|
||||
void printConfig(std::ostream& out);
|
||||
flitBuffer_d* getCreditQueue() { return creditQueue; }
|
||||
void print(std::ostream& out) const {};
|
||||
|
||||
inline int get_inlink_id() { return m_in_link->get_id(); }
|
||||
|
||||
inline void
|
||||
set_vc_state(VC_state_type state, int vc)
|
||||
{
|
||||
m_vcs[vc]->set_state(state);
|
||||
}
|
||||
|
||||
inline void
|
||||
set_enqueue_time(int invc, Time time)
|
||||
{
|
||||
m_vcs[invc]->set_enqueue_time(time);
|
||||
}
|
||||
|
||||
inline Time
|
||||
get_enqueue_time(int invc)
|
||||
{
|
||||
return m_vcs[invc]->get_enqueue_time();
|
||||
}
|
||||
|
||||
inline void
|
||||
update_credit(int in_vc, int credit)
|
||||
{
|
||||
m_vcs[in_vc]->update_credit(credit);
|
||||
}
|
||||
|
||||
inline bool
|
||||
has_credits(int vc)
|
||||
{
|
||||
return m_vcs[vc]->has_credits();
|
||||
}
|
||||
|
||||
inline void
|
||||
increment_credit(int in_vc, bool free_signal)
|
||||
{
|
||||
flit_d *t_flit = new flit_d(in_vc, free_signal);
|
||||
creditQueue->insert(t_flit);
|
||||
g_eventQueue_ptr->scheduleEvent(m_credit_link, 1);
|
||||
}
|
||||
|
||||
inline int
|
||||
get_outvc(int invc)
|
||||
{
|
||||
return m_vcs[invc]->get_outvc();
|
||||
}
|
||||
|
||||
inline void
|
||||
updateRoute(int vc, int outport)
|
||||
{
|
||||
m_vcs[vc]->set_outport(outport);
|
||||
m_vcs[vc]->set_state(VC_AB_);
|
||||
}
|
||||
|
||||
inline void
|
||||
grant_vc(int in_vc, int out_vc)
|
||||
{
|
||||
m_vcs[in_vc]->grant_vc(out_vc);
|
||||
}
|
||||
|
||||
inline flit_d*
|
||||
peekTopFlit(int vc)
|
||||
{
|
||||
return m_vcs[vc]->peekTopFlit();
|
||||
}
|
||||
|
||||
inline flit_d*
|
||||
getTopFlit(int vc)
|
||||
{
|
||||
return m_vcs[vc]->getTopFlit();
|
||||
}
|
||||
|
||||
inline bool
|
||||
need_stage(int vc, VC_state_type state, flit_stage stage)
|
||||
{
|
||||
return m_vcs[vc]->need_stage(state, stage);
|
||||
}
|
||||
|
||||
inline bool
|
||||
need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage)
|
||||
{
|
||||
return m_vcs[vc]->need_stage_nextcycle(state, stage);
|
||||
}
|
||||
|
||||
inline bool
|
||||
isReady(int invc)
|
||||
{
|
||||
return m_vcs[invc]->isReady();
|
||||
}
|
||||
|
||||
inline int
|
||||
get_route(int vc)
|
||||
{
|
||||
return m_vcs[vc]->get_route();
|
||||
}
|
||||
|
||||
inline void
|
||||
set_in_link(NetworkLink_d *link)
|
||||
{
|
||||
m_in_link = link;
|
||||
}
|
||||
|
||||
inline void
|
||||
set_credit_link(CreditLink_d *credit_link)
|
||||
{
|
||||
m_credit_link = credit_link;
|
||||
}
|
||||
|
||||
inline double
|
||||
get_buf_read_count(int vnet)
|
||||
{
|
||||
return m_num_buffer_reads[vnet];
|
||||
}
|
||||
|
||||
inline double
|
||||
get_buf_write_count(int vnet)
|
||||
{
|
||||
return m_num_buffer_writes[vnet];
|
||||
}
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
int m_num_vcs;
|
||||
int m_vc_per_vnet;
|
||||
std::vector<double> m_num_buffer_writes;
|
||||
std::vector<double> m_num_buffer_reads;
|
||||
|
||||
Router_d *m_router;
|
||||
NetworkLink_d *m_in_link;
|
||||
CreditLink_d *m_credit_link;
|
||||
flitBuffer_d *creditQueue;
|
||||
|
||||
// Virtual channels
|
||||
std::vector<VirtualChannel_d *> m_vcs;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_INPUT_UNIT_D_HH__
|
||||
@ -0,0 +1,370 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
#include "base/cast.hh"
|
||||
#include "base/stl_helpers.hh"
|
||||
#include "debug/RubyNetwork.hh"
|
||||
#include "mem/ruby/buffers/MessageBuffer.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
|
||||
#include "mem/ruby/slicc_interface/NetworkMessage.hh"
|
||||
|
||||
using namespace std;
|
||||
using m5::stl_helpers::deletePointers;
|
||||
|
||||
NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks,
|
||||
GarnetNetwork_d *network_ptr)
|
||||
{
|
||||
m_id = id;
|
||||
m_net_ptr = network_ptr;
|
||||
m_virtual_networks = virtual_networks;
|
||||
m_vc_per_vnet = m_net_ptr->getVCsPerVnet();
|
||||
m_num_vcs = m_vc_per_vnet*m_virtual_networks;
|
||||
|
||||
m_vc_round_robin = 0;
|
||||
m_ni_buffers.resize(m_num_vcs);
|
||||
m_ni_enqueue_time.resize(m_num_vcs);
|
||||
inNode_ptr.resize(m_virtual_networks);
|
||||
outNode_ptr.resize(m_virtual_networks);
|
||||
creditQueue = new flitBuffer_d();
|
||||
|
||||
// instantiating the NI flit buffers
|
||||
for (int i = 0; i < m_num_vcs; i++) {
|
||||
m_ni_buffers[i] = new flitBuffer_d();
|
||||
m_ni_enqueue_time[i] = INFINITE_;
|
||||
}
|
||||
m_vc_allocator.resize(m_virtual_networks); // 1 allocator per vnet
|
||||
for (int i = 0; i < m_virtual_networks; i++) {
|
||||
m_vc_allocator[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_num_vcs; i++) {
|
||||
m_out_vc_state.push_back(new OutVcState_d(i, m_net_ptr));
|
||||
m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime());
|
||||
}
|
||||
}
|
||||
|
||||
NetworkInterface_d::~NetworkInterface_d()
|
||||
{
|
||||
deletePointers(m_out_vc_state);
|
||||
deletePointers(m_ni_buffers);
|
||||
delete creditQueue;
|
||||
delete outSrcQueue;
|
||||
}
|
||||
|
||||
void
|
||||
NetworkInterface_d::addInPort(NetworkLink_d *in_link,
|
||||
CreditLink_d *credit_link)
|
||||
{
|
||||
inNetLink = in_link;
|
||||
in_link->setLinkConsumer(this);
|
||||
m_ni_credit_link = credit_link;
|
||||
credit_link->setSourceQueue(creditQueue);
|
||||
}
|
||||
|
||||
void
|
||||
NetworkInterface_d::addOutPort(NetworkLink_d *out_link,
|
||||
CreditLink_d *credit_link)
|
||||
{
|
||||
m_credit_link = credit_link;
|
||||
credit_link->setLinkConsumer(this);
|
||||
|
||||
outNetLink = out_link;
|
||||
outSrcQueue = new flitBuffer_d();
|
||||
out_link->setSourceQueue(outSrcQueue);
|
||||
}
|
||||
|
||||
void
|
||||
NetworkInterface_d::addNode(vector<MessageBuffer *>& in,
|
||||
vector<MessageBuffer *>& out)
|
||||
{
|
||||
assert(in.size() == m_virtual_networks);
|
||||
inNode_ptr = in;
|
||||
outNode_ptr = out;
|
||||
for (int j = 0; j < m_virtual_networks; j++) {
|
||||
|
||||
// the protocol injects messages into the NI
|
||||
inNode_ptr[j]->setConsumer(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
NetworkInterface_d::flitisizeMessage(MsgPtr msg_ptr, int vnet)
|
||||
{
|
||||
NetworkMessage *net_msg_ptr = safe_cast<NetworkMessage *>(msg_ptr.get());
|
||||
NetDest net_msg_dest = net_msg_ptr->getInternalDestination();
|
||||
|
||||
// gets all the destinations associated with this message.
|
||||
vector<NodeID> dest_nodes = net_msg_dest.getAllDest();
|
||||
|
||||
// Number of flits is dependent on the link bandwidth available.
|
||||
// This is expressed in terms of bytes/cycle or the flit size
|
||||
int num_flits = (int) ceil((double) m_net_ptr->MessageSizeType_to_int(
|
||||
net_msg_ptr->getMessageSize())/m_net_ptr->getNiFlitSize());
|
||||
|
||||
// loop to convert all multicast messages into unicast messages
|
||||
for (int ctr = 0; ctr < dest_nodes.size(); ctr++) {
|
||||
|
||||
// this will return a free output virtual channel
|
||||
int vc = calculateVC(vnet);
|
||||
|
||||
if (vc == -1) {
|
||||
return false ;
|
||||
}
|
||||
MsgPtr new_msg_ptr = msg_ptr->clone();
|
||||
NodeID destID = dest_nodes[ctr];
|
||||
|
||||
NetworkMessage *new_net_msg_ptr =
|
||||
safe_cast<NetworkMessage *>(new_msg_ptr.get());
|
||||
if (dest_nodes.size() > 1) {
|
||||
NetDest personal_dest;
|
||||
for (int m = 0; m < (int) MachineType_NUM; m++) {
|
||||
if ((destID >= MachineType_base_number((MachineType) m)) &&
|
||||
destID < MachineType_base_number((MachineType) (m+1))) {
|
||||
// calculating the NetDest associated with this destID
|
||||
personal_dest.clear();
|
||||
personal_dest.add((MachineID) {(MachineType) m, (destID -
|
||||
MachineType_base_number((MachineType) m))});
|
||||
new_net_msg_ptr->getInternalDestination() = personal_dest;
|
||||
break;
|
||||
}
|
||||
}
|
||||
net_msg_dest.removeNetDest(personal_dest);
|
||||
// removing the destination from the original message to reflect
|
||||
// that a message with this particular destination has been
|
||||
// flitisized and an output vc is acquired
|
||||
net_msg_ptr->getInternalDestination().removeNetDest(personal_dest);
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_flits; i++) {
|
||||
m_net_ptr->increment_injected_flits(vnet);
|
||||
flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr);
|
||||
fl->set_delay(g_eventQueue_ptr->getTime() - msg_ptr->getTime());
|
||||
m_ni_buffers[vc]->insert(fl);
|
||||
}
|
||||
m_ni_enqueue_time[vc] = g_eventQueue_ptr->getTime();
|
||||
m_out_vc_state[vc]->setState(ACTIVE_, g_eventQueue_ptr->getTime());
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Looking for a free output vc
|
||||
int
|
||||
NetworkInterface_d::calculateVC(int vnet)
|
||||
{
|
||||
for (int i = 0; i < m_vc_per_vnet; i++) {
|
||||
int delta = m_vc_allocator[vnet];
|
||||
m_vc_allocator[vnet]++;
|
||||
if(m_vc_allocator[vnet] == m_vc_per_vnet)
|
||||
m_vc_allocator[vnet] = 0;
|
||||
|
||||
if (m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState(
|
||||
IDLE_, g_eventQueue_ptr->getTime())) {
|
||||
return ((vnet*m_vc_per_vnet) + delta);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* The NI wakeup checks whether there are any ready messages in the protocol
|
||||
* buffer. If yes, it picks that up, flitisizes it into a number of flits and
|
||||
* puts it into an output buffer and schedules the output link. On a wakeup
|
||||
* it also checks whether there are flits in the input link. If yes, it picks
|
||||
* them up and if the flit is a tail, the NI inserts the corresponding message
|
||||
* into the protocol buffer. It also checks for credits being sent by the
|
||||
* downstream router.
|
||||
*/
|
||||
|
||||
void
|
||||
NetworkInterface_d::wakeup()
|
||||
{
|
||||
DPRINTF(RubyNetwork, "m_id: %d woke up at time: %lld",
|
||||
m_id, g_eventQueue_ptr->getTime());
|
||||
|
||||
MsgPtr msg_ptr;
|
||||
|
||||
// Checking for messages coming from the protocol
|
||||
// can pick up a message/cycle for each virtual net
|
||||
for (int vnet = 0; vnet < m_virtual_networks; vnet++) {
|
||||
while (inNode_ptr[vnet]->isReady()) { // Is there a message waiting
|
||||
msg_ptr = inNode_ptr[vnet]->peekMsgPtr();
|
||||
if (flitisizeMessage(msg_ptr, vnet)) {
|
||||
inNode_ptr[vnet]->pop();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scheduleOutputLink();
|
||||
checkReschedule();
|
||||
|
||||
/*********** Picking messages destined for this NI **********/
|
||||
|
||||
if (inNetLink->isReady()) {
|
||||
flit_d *t_flit = inNetLink->consumeLink();
|
||||
bool free_signal = false;
|
||||
if (t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) {
|
||||
free_signal = true;
|
||||
|
||||
outNode_ptr[t_flit->get_vnet()]->enqueue(
|
||||
t_flit->get_msg_ptr(), 1);
|
||||
}
|
||||
// Simply send a credit back since we are not buffering
|
||||
// this flit in the NI
|
||||
flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal);
|
||||
creditQueue->insert(credit_flit);
|
||||
g_eventQueue_ptr->scheduleEvent(m_ni_credit_link, 1);
|
||||
|
||||
int vnet = t_flit->get_vnet();
|
||||
m_net_ptr->increment_received_flits(vnet);
|
||||
int network_delay = g_eventQueue_ptr->getTime() -
|
||||
t_flit->get_enqueue_time();
|
||||
int queueing_delay = t_flit->get_delay();
|
||||
m_net_ptr->increment_network_latency(network_delay, vnet);
|
||||
m_net_ptr->increment_queueing_latency(queueing_delay, vnet);
|
||||
delete t_flit;
|
||||
}
|
||||
|
||||
/****************** Checking for credit link *******/
|
||||
|
||||
if (m_credit_link->isReady()) {
|
||||
flit_d *t_flit = m_credit_link->consumeLink();
|
||||
m_out_vc_state[t_flit->get_vc()]->increment_credit();
|
||||
if (t_flit->is_free_signal()) {
|
||||
m_out_vc_state[t_flit->get_vc()]->setState(IDLE_,
|
||||
g_eventQueue_ptr->getTime());
|
||||
}
|
||||
delete t_flit;
|
||||
}
|
||||
}
|
||||
|
||||
/** This function looks at the NI buffers
|
||||
* if some buffer has flits which are ready to traverse the link in the next
|
||||
* cycle, and the downstream output vc associated with this flit has buffers
|
||||
* left, the link is scheduled for the next cycle
|
||||
*/
|
||||
|
||||
void
|
||||
NetworkInterface_d::scheduleOutputLink()
|
||||
{
|
||||
int vc = m_vc_round_robin;
|
||||
m_vc_round_robin++;
|
||||
if (m_vc_round_robin == m_num_vcs)
|
||||
m_vc_round_robin = 0;
|
||||
|
||||
for (int i = 0; i < m_num_vcs; i++) {
|
||||
vc++;
|
||||
if (vc == m_num_vcs)
|
||||
vc = 0;
|
||||
|
||||
// model buffer backpressure
|
||||
if (m_ni_buffers[vc]->isReady() && m_out_vc_state[vc]->has_credits()) {
|
||||
bool is_candidate_vc = true;
|
||||
int t_vnet = get_vnet(vc);
|
||||
int vc_base = t_vnet * m_vc_per_vnet;
|
||||
|
||||
if (m_net_ptr->isVNetOrdered(t_vnet)) {
|
||||
for (int vc_offset = 0; vc_offset < m_vc_per_vnet;
|
||||
vc_offset++) {
|
||||
int t_vc = vc_base + vc_offset;
|
||||
if (m_ni_buffers[t_vc]->isReady()) {
|
||||
if (m_ni_enqueue_time[t_vc] < m_ni_enqueue_time[vc]) {
|
||||
is_candidate_vc = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_candidate_vc)
|
||||
continue;
|
||||
|
||||
m_out_vc_state[vc]->decrement_credit();
|
||||
// Just removing the flit
|
||||
flit_d *t_flit = m_ni_buffers[vc]->getTopFlit();
|
||||
t_flit->set_time(g_eventQueue_ptr->getTime() + 1);
|
||||
outSrcQueue->insert(t_flit);
|
||||
// schedule the out link
|
||||
g_eventQueue_ptr->scheduleEvent(outNetLink, 1);
|
||||
|
||||
if (t_flit->get_type() == TAIL_ ||
|
||||
t_flit->get_type() == HEAD_TAIL_) {
|
||||
m_ni_enqueue_time[vc] = INFINITE_;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
NetworkInterface_d::get_vnet(int vc)
|
||||
{
|
||||
for (int i = 0; i < m_net_ptr->getNumberOfVirtualNetworks(); i++) {
|
||||
if (vc >= (i*m_vc_per_vnet) && vc < ((i+1)*m_vc_per_vnet)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
fatal("Could not determine vc");
|
||||
}
|
||||
|
||||
void
|
||||
NetworkInterface_d::checkReschedule()
|
||||
{
|
||||
for (int vnet = 0; vnet < m_virtual_networks; vnet++) {
|
||||
if (inNode_ptr[vnet]->isReady()) { // Is there a message waiting
|
||||
g_eventQueue_ptr->scheduleEvent(this, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int vc = 0; vc < m_num_vcs; vc++) {
|
||||
if (m_ni_buffers[vc]->isReadyForNext()) {
|
||||
g_eventQueue_ptr->scheduleEvent(this, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetworkInterface_d::printConfig(std::ostream& out) const
|
||||
{
|
||||
out << "[Network Interface " << m_id << "] - ";
|
||||
out << "[inLink " << inNetLink->get_id() << "] - ";
|
||||
out << "[outLink " << outNetLink->get_id() << "]" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
NetworkInterface_d::print(std::ostream& out) const
|
||||
{
|
||||
out << "[Network Interface]";
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_INTERFACE_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_INTERFACE_D_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Consumer.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
#include "mem/ruby/slicc_interface/Message.hh"
|
||||
|
||||
class NetworkMessage;
|
||||
class MessageBuffer;
|
||||
class flitBuffer_d;
|
||||
|
||||
class NetworkInterface_d : public Consumer
|
||||
{
|
||||
public:
|
||||
NetworkInterface_d(int id, int virtual_networks,
|
||||
GarnetNetwork_d* network_ptr);
|
||||
|
||||
~NetworkInterface_d();
|
||||
|
||||
void addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link);
|
||||
void addOutPort(NetworkLink_d *out_link, CreditLink_d *credit_link);
|
||||
|
||||
void wakeup();
|
||||
void addNode(std::vector<MessageBuffer *> &inNode,
|
||||
std::vector<MessageBuffer *> &outNode);
|
||||
void printConfig(std::ostream& out) const;
|
||||
void print(std::ostream& out) const;
|
||||
int get_vnet(int vc);
|
||||
|
||||
private:
|
||||
GarnetNetwork_d *m_net_ptr;
|
||||
int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
|
||||
NodeID m_id;
|
||||
std::vector<OutVcState_d *> m_out_vc_state;
|
||||
std::vector<int> m_vc_allocator;
|
||||
int m_vc_round_robin; // For round robin scheduling
|
||||
flitBuffer_d *outSrcQueue; // For modelling link contention
|
||||
flitBuffer_d *creditQueue;
|
||||
|
||||
NetworkLink_d *inNetLink;
|
||||
NetworkLink_d *outNetLink;
|
||||
CreditLink_d *m_credit_link;
|
||||
CreditLink_d *m_ni_credit_link;
|
||||
|
||||
// Input Flit Buffers
|
||||
// The flit buffers which will serve the Consumer
|
||||
std::vector<flitBuffer_d *> m_ni_buffers;
|
||||
std::vector<Time> m_ni_enqueue_time;
|
||||
|
||||
// The Message buffers that takes messages from the protocol
|
||||
std::vector<MessageBuffer *> inNode_ptr;
|
||||
// The Message buffers that provides messages to the protocol
|
||||
std::vector<MessageBuffer *> outNode_ptr;
|
||||
|
||||
bool flitisizeMessage(MsgPtr msg_ptr, int vnet);
|
||||
int calculateVC(int vnet);
|
||||
void scheduleOutputLink();
|
||||
void checkReschedule();
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_INTERFACE_D_HH__
|
||||
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
||||
|
||||
NetworkLink_d::NetworkLink_d(const Params *p)
|
||||
: SimObject(p)
|
||||
{
|
||||
m_latency = p->link_latency;
|
||||
channel_width = p->channel_width;
|
||||
m_id = p->link_id;
|
||||
linkBuffer = new flitBuffer_d();
|
||||
m_link_utilized = 0;
|
||||
m_vc_load.resize(p->vcs_per_vnet * p->virt_nets);
|
||||
|
||||
for (int i = 0; i < (p->vcs_per_vnet * p->virt_nets); i++) {
|
||||
m_vc_load[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
NetworkLink_d::~NetworkLink_d()
|
||||
{
|
||||
delete linkBuffer;
|
||||
}
|
||||
|
||||
void
|
||||
NetworkLink_d::setLinkConsumer(Consumer *consumer)
|
||||
{
|
||||
link_consumer = consumer;
|
||||
}
|
||||
|
||||
void
|
||||
NetworkLink_d::setSourceQueue(flitBuffer_d *srcQueue)
|
||||
{
|
||||
link_srcQueue = srcQueue;
|
||||
}
|
||||
|
||||
void
|
||||
NetworkLink_d::wakeup()
|
||||
{
|
||||
if (link_srcQueue->isReady()) {
|
||||
flit_d *t_flit = link_srcQueue->getTopFlit();
|
||||
t_flit->set_time(g_eventQueue_ptr->getTime() + m_latency);
|
||||
linkBuffer->insert(t_flit);
|
||||
g_eventQueue_ptr->scheduleEvent(link_consumer, m_latency);
|
||||
m_link_utilized++;
|
||||
m_vc_load[t_flit->get_vc()]++;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int>
|
||||
NetworkLink_d::getVcLoad()
|
||||
{
|
||||
return m_vc_load;
|
||||
}
|
||||
|
||||
int
|
||||
NetworkLink_d::getLinkUtilization()
|
||||
{
|
||||
return m_link_utilized;
|
||||
}
|
||||
|
||||
NetworkLink_d *
|
||||
NetworkLink_dParams::create()
|
||||
{
|
||||
return new NetworkLink_d(this);
|
||||
}
|
||||
|
||||
CreditLink_d *
|
||||
CreditLink_dParams::create()
|
||||
{
|
||||
return new CreditLink_d(this);
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_LINK_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_LINK_D_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Consumer.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
#include "mem/ruby/network/orion/NetworkPower.hh"
|
||||
#include "params/NetworkLink_d.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
|
||||
class GarnetNetwork_d;
|
||||
|
||||
class NetworkLink_d : public SimObject, public Consumer
|
||||
{
|
||||
public:
|
||||
typedef NetworkLink_dParams Params;
|
||||
NetworkLink_d(const Params *p);
|
||||
~NetworkLink_d();
|
||||
|
||||
void setLinkConsumer(Consumer *consumer);
|
||||
void setSourceQueue(flitBuffer_d *srcQueue);
|
||||
void print(std::ostream& out) const{}
|
||||
int getLinkUtilization();
|
||||
std::vector<int> getVcLoad();
|
||||
int get_id(){return m_id;}
|
||||
double get_dynamic_power(){return m_power_dyn;}
|
||||
double get_static_power(){return m_power_sta;}
|
||||
void wakeup();
|
||||
|
||||
double calculate_power();
|
||||
|
||||
inline bool isReady() { return linkBuffer->isReady(); }
|
||||
inline flit_d* peekLink() { return linkBuffer->peekTopFlit(); }
|
||||
inline flit_d* consumeLink() { return linkBuffer->getTopFlit(); }
|
||||
void init_net_ptr(GarnetNetwork_d* net_ptr)
|
||||
{
|
||||
m_net_ptr = net_ptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_id;
|
||||
int m_latency;
|
||||
int channel_width;
|
||||
|
||||
GarnetNetwork_d *m_net_ptr;
|
||||
flitBuffer_d *linkBuffer;
|
||||
Consumer *link_consumer;
|
||||
flitBuffer_d *link_srcQueue;
|
||||
int m_link_utilized;
|
||||
std::vector<int> m_vc_load;
|
||||
int m_flit_width;
|
||||
|
||||
double m_power_dyn;
|
||||
double m_power_sta;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_LINK_D_HH__
|
||||
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "mem/ruby/common/Global.hh"
|
||||
#include "mem/ruby/eventqueue/RubyEventQueue.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.hh"
|
||||
|
||||
OutVcState_d::OutVcState_d(int id, GarnetNetwork_d *network_ptr)
|
||||
{
|
||||
m_network_ptr = network_ptr;
|
||||
m_id = id;
|
||||
m_vc_state = IDLE_;
|
||||
m_time = g_eventQueue_ptr->getTime();
|
||||
|
||||
if (m_network_ptr->get_vnet_type(id) == DATA_VNET_)
|
||||
m_credit_count = m_network_ptr->getBuffersPerDataVC();
|
||||
else
|
||||
m_credit_count = m_network_ptr->getBuffersPerCtrlVC();
|
||||
|
||||
assert(m_credit_count >= 1);
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUT_VC_STATE_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUT_VC_STATE_D_HH__
|
||||
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
|
||||
class OutVcState_d
|
||||
{
|
||||
public:
|
||||
OutVcState_d(int id, GarnetNetwork_d *network_ptr);
|
||||
|
||||
int get_inport() { return m_in_port; }
|
||||
int get_invc() { return m_in_vc; }
|
||||
int get_credit_count() { return m_credit_count; }
|
||||
|
||||
void set_inport(int port) { m_in_port = port; }
|
||||
void set_invc(int vc) { m_in_vc = vc; }
|
||||
inline bool
|
||||
isInState(VC_state_type state, Time request_time)
|
||||
{
|
||||
return ((m_vc_state == state) && (request_time >= m_time) );
|
||||
}
|
||||
inline void
|
||||
setState(VC_state_type state, Time time)
|
||||
{
|
||||
m_vc_state = state;
|
||||
m_time = time;
|
||||
}
|
||||
inline bool has_credits() { return (m_credit_count > 0); }
|
||||
inline void increment_credit() { m_credit_count++; }
|
||||
inline void decrement_credit() { m_credit_count--; }
|
||||
|
||||
private:
|
||||
GarnetNetwork_d *m_network_ptr;
|
||||
int m_id ;
|
||||
Time m_time;
|
||||
VC_state_type m_vc_state;
|
||||
int m_in_port;
|
||||
int m_in_vc;
|
||||
int m_credit_count;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUT_VC_STATE_D_HH__
|
||||
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "base/stl_helpers.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
|
||||
|
||||
using namespace std;
|
||||
using m5::stl_helpers::deletePointers;
|
||||
|
||||
OutputUnit_d::OutputUnit_d(int id, Router_d *router)
|
||||
{
|
||||
m_id = id;
|
||||
m_router = router;
|
||||
m_num_vcs = m_router->get_num_vcs();
|
||||
m_out_buffer = new flitBuffer_d();
|
||||
|
||||
for (int i = 0; i < m_num_vcs; i++) {
|
||||
m_outvc_state.push_back(new OutVcState_d(i, m_router->get_net_ptr()));
|
||||
}
|
||||
}
|
||||
|
||||
OutputUnit_d::~OutputUnit_d()
|
||||
{
|
||||
delete m_out_buffer;
|
||||
deletePointers(m_outvc_state);
|
||||
}
|
||||
|
||||
void
|
||||
OutputUnit_d::decrement_credit(int out_vc)
|
||||
{
|
||||
m_outvc_state[out_vc]->decrement_credit();
|
||||
m_router->update_incredit(m_outvc_state[out_vc]->get_inport(),
|
||||
m_outvc_state[out_vc]->get_invc(),
|
||||
m_outvc_state[out_vc]->get_credit_count());
|
||||
}
|
||||
|
||||
void
|
||||
OutputUnit_d::wakeup()
|
||||
{
|
||||
if (m_credit_link->isReady()) {
|
||||
flit_d *t_flit = m_credit_link->consumeLink();
|
||||
int out_vc = t_flit->get_vc();
|
||||
m_outvc_state[out_vc]->increment_credit();
|
||||
m_router->update_incredit(m_outvc_state[out_vc]->get_inport(),
|
||||
m_outvc_state[out_vc]->get_invc(),
|
||||
m_outvc_state[out_vc]->get_credit_count());
|
||||
|
||||
if (t_flit->is_free_signal())
|
||||
set_vc_state(IDLE_, out_vc);
|
||||
|
||||
delete t_flit;
|
||||
}
|
||||
}
|
||||
|
||||
flitBuffer_d*
|
||||
OutputUnit_d::getOutQueue()
|
||||
{
|
||||
return m_out_buffer;
|
||||
}
|
||||
|
||||
void
|
||||
OutputUnit_d::set_out_link(NetworkLink_d *link)
|
||||
{
|
||||
m_out_link = link;
|
||||
}
|
||||
|
||||
void
|
||||
OutputUnit_d::set_credit_link(CreditLink_d *credit_link)
|
||||
{
|
||||
m_credit_link = credit_link;
|
||||
}
|
||||
|
||||
void
|
||||
OutputUnit_d::update_vc(int vc, int in_port, int in_vc)
|
||||
{
|
||||
m_outvc_state[vc]->setState(ACTIVE_, g_eventQueue_ptr->getTime() + 1);
|
||||
m_outvc_state[vc]->set_inport(in_port);
|
||||
m_outvc_state[vc]->set_invc(in_vc);
|
||||
m_router->update_incredit(in_port, in_vc,
|
||||
m_outvc_state[vc]->get_credit_count());
|
||||
}
|
||||
|
||||
void
|
||||
OutputUnit_d::printConfig(ostream& out)
|
||||
{
|
||||
out << endl;
|
||||
out << "OutputUnit Configuration" << endl;
|
||||
out << "---------------------" << endl;
|
||||
out << "id = " << m_id << endl;
|
||||
out << "Out link is " << m_out_link->get_id() << endl;
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUTPUT_UNIT_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUTPUT_UNIT_D_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Consumer.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
|
||||
class Router_d;
|
||||
|
||||
class OutputUnit_d : public Consumer
|
||||
{
|
||||
public:
|
||||
OutputUnit_d(int id, Router_d *router);
|
||||
~OutputUnit_d();
|
||||
void set_out_link(NetworkLink_d *link);
|
||||
void set_credit_link(CreditLink_d *credit_link);
|
||||
void wakeup();
|
||||
flitBuffer_d* getOutQueue();
|
||||
void printConfig(std::ostream& out);
|
||||
void update_vc(int vc, int in_port, int in_vc);
|
||||
void print(std::ostream& out) const {};
|
||||
void decrement_credit(int out_vc);
|
||||
|
||||
int
|
||||
get_credit_cnt(int vc)
|
||||
{
|
||||
return m_outvc_state[vc]->get_credit_count();
|
||||
}
|
||||
|
||||
inline int
|
||||
get_outlink_id()
|
||||
{
|
||||
return m_out_link->get_id();
|
||||
}
|
||||
|
||||
inline void
|
||||
set_vc_state(VC_state_type state, int vc)
|
||||
{
|
||||
m_outvc_state[vc]->setState(state, g_eventQueue_ptr->getTime() + 1);
|
||||
}
|
||||
|
||||
inline bool
|
||||
is_vc_idle(int vc)
|
||||
{
|
||||
return (m_outvc_state[vc]->isInState(IDLE_,
|
||||
g_eventQueue_ptr->getTime()));
|
||||
}
|
||||
|
||||
inline void
|
||||
insert_flit(flit_d *t_flit)
|
||||
{
|
||||
m_out_buffer->insert(t_flit);
|
||||
g_eventQueue_ptr->scheduleEvent(m_out_link, 1);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
int m_num_vcs;
|
||||
Router_d *m_router;
|
||||
NetworkLink_d *m_out_link;
|
||||
CreditLink_d *m_credit_link;
|
||||
|
||||
flitBuffer_d *m_out_buffer; // This is for the network link to consume
|
||||
std::vector<OutVcState_d *> m_outvc_state; // vc state of downstream router
|
||||
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUTPUT_UNIT_D_HH__
|
||||
@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "base/stl_helpers.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh"
|
||||
|
||||
using namespace std;
|
||||
using m5::stl_helpers::deletePointers;
|
||||
|
||||
Router_d::Router_d(const Params *p)
|
||||
: BasicRouter(p)
|
||||
{
|
||||
m_virtual_networks = p->virt_nets;
|
||||
m_vc_per_vnet = p->vcs_per_vnet;
|
||||
m_num_vcs = m_virtual_networks * m_vc_per_vnet;
|
||||
|
||||
m_routing_unit = new RoutingUnit_d(this);
|
||||
m_vc_alloc = new VCallocator_d(this);
|
||||
m_sw_alloc = new SWallocator_d(this);
|
||||
m_switch = new Switch_d(this);
|
||||
|
||||
m_input_unit.clear();
|
||||
m_output_unit.clear();
|
||||
|
||||
crossbar_count = 0;
|
||||
sw_local_arbit_count = 0;
|
||||
sw_global_arbit_count = 0;
|
||||
buf_read_count.resize(m_virtual_networks);
|
||||
buf_write_count.resize(m_virtual_networks);
|
||||
vc_local_arbit_count.resize(m_virtual_networks);
|
||||
vc_global_arbit_count.resize(m_virtual_networks);
|
||||
for (int i = 0; i < m_virtual_networks; i++) {
|
||||
buf_read_count[i] = 0;
|
||||
buf_write_count[i] = 0;
|
||||
vc_local_arbit_count[i] = 0;
|
||||
vc_global_arbit_count[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Router_d::~Router_d()
|
||||
{
|
||||
deletePointers(m_input_unit);
|
||||
deletePointers(m_output_unit);
|
||||
delete m_routing_unit;
|
||||
delete m_vc_alloc;
|
||||
delete m_sw_alloc;
|
||||
delete m_switch;
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::init()
|
||||
{
|
||||
BasicRouter::init();
|
||||
|
||||
m_vc_alloc->init();
|
||||
m_sw_alloc->init();
|
||||
m_switch->init();
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link)
|
||||
{
|
||||
int port_num = m_input_unit.size();
|
||||
InputUnit_d *input_unit = new InputUnit_d(port_num, this);
|
||||
|
||||
input_unit->set_in_link(in_link);
|
||||
input_unit->set_credit_link(credit_link);
|
||||
in_link->setLinkConsumer(input_unit);
|
||||
credit_link->setSourceQueue(input_unit->getCreditQueue());
|
||||
|
||||
m_input_unit.push_back(input_unit);
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::addOutPort(NetworkLink_d *out_link,
|
||||
const NetDest& routing_table_entry, int link_weight,
|
||||
CreditLink_d *credit_link)
|
||||
{
|
||||
int port_num = m_output_unit.size();
|
||||
OutputUnit_d *output_unit = new OutputUnit_d(port_num, this);
|
||||
|
||||
output_unit->set_out_link(out_link);
|
||||
output_unit->set_credit_link(credit_link);
|
||||
credit_link->setLinkConsumer(output_unit);
|
||||
out_link->setSourceQueue(output_unit->getOutQueue());
|
||||
|
||||
m_output_unit.push_back(output_unit);
|
||||
|
||||
m_routing_unit->addRoute(routing_table_entry);
|
||||
m_routing_unit->addWeight(link_weight);
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::route_req(flit_d *t_flit, InputUnit_d *in_unit, int invc)
|
||||
{
|
||||
m_routing_unit->RC_stage(t_flit, in_unit, invc);
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::vcarb_req()
|
||||
{
|
||||
g_eventQueue_ptr->scheduleEvent(m_vc_alloc, 1);
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::swarb_req()
|
||||
{
|
||||
g_eventQueue_ptr->scheduleEvent(m_sw_alloc, 1);
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::update_incredit(int in_port, int in_vc, int credit)
|
||||
{
|
||||
m_input_unit[in_port]->update_credit(in_vc, credit);
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::update_sw_winner(int inport, flit_d *t_flit)
|
||||
{
|
||||
m_switch->update_sw_winner(inport, t_flit);
|
||||
g_eventQueue_ptr->scheduleEvent(m_switch, 1);
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::calculate_performance_numbers()
|
||||
{
|
||||
for (int j = 0; j < m_virtual_networks; j++) {
|
||||
for (int i = 0; i < m_input_unit.size(); i++) {
|
||||
buf_read_count[j] += m_input_unit[i]->get_buf_read_count(j);
|
||||
buf_write_count[j] += m_input_unit[i]->get_buf_write_count(j);
|
||||
}
|
||||
|
||||
vc_local_arbit_count[j] = m_vc_alloc->get_local_arbit_count(j);
|
||||
vc_global_arbit_count[j] = m_vc_alloc->get_global_arbit_count(j);
|
||||
}
|
||||
|
||||
sw_local_arbit_count = m_sw_alloc->get_local_arbit_count();
|
||||
sw_global_arbit_count = m_sw_alloc->get_global_arbit_count();
|
||||
crossbar_count = m_switch->get_crossbar_count();
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::printConfig(ostream& out)
|
||||
{
|
||||
out << name() << endl;
|
||||
out << "[inLink - ";
|
||||
for (int i = 0;i < m_input_unit.size(); i++)
|
||||
out << m_input_unit[i]->get_inlink_id() << " - ";
|
||||
out << "]" << endl;
|
||||
out << "[outLink - ";
|
||||
for (int i = 0;i < m_output_unit.size(); i++)
|
||||
out << m_output_unit[i]->get_outlink_id() << " - ";
|
||||
out << "]" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::printFaultVector(ostream& out)
|
||||
{
|
||||
int temperature_celcius = BASELINE_TEMPERATURE_CELCIUS;
|
||||
int num_fault_types = m_network_ptr->fault_model->number_of_fault_types;
|
||||
float fault_vector[num_fault_types];
|
||||
get_fault_vector(temperature_celcius, fault_vector);
|
||||
out << "Router-" << m_id << " fault vector: " << endl;
|
||||
for (int fault_type_index = 0; fault_type_index < num_fault_types;
|
||||
fault_type_index++){
|
||||
out << " - probability of (";
|
||||
out <<
|
||||
m_network_ptr->fault_model->fault_type_to_string(fault_type_index);
|
||||
out << ") = ";
|
||||
out << fault_vector[fault_type_index] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Router_d::printAggregateFaultProbability(std::ostream& out)
|
||||
{
|
||||
int temperature_celcius = BASELINE_TEMPERATURE_CELCIUS;
|
||||
float aggregate_fault_prob;
|
||||
get_aggregate_fault_probability(temperature_celcius,
|
||||
&aggregate_fault_prob);
|
||||
out << "Router-" << m_id << " fault probability: ";
|
||||
out << aggregate_fault_prob << endl;
|
||||
}
|
||||
|
||||
Router_d *
|
||||
GarnetRouter_dParams::create()
|
||||
{
|
||||
return new Router_d(this);
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTER_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTER_D_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/NetDest.hh"
|
||||
#include "mem/ruby/network/BasicRouter.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
#include "mem/ruby/network/orion/NetworkPower.hh"
|
||||
#include "params/GarnetRouter_d.hh"
|
||||
|
||||
class GarnetNetwork_d;
|
||||
class NetworkLink_d;
|
||||
class CreditLink_d;
|
||||
class InputUnit_d;
|
||||
class OutputUnit_d;
|
||||
class RoutingUnit_d;
|
||||
class VCallocator_d;
|
||||
class SWallocator_d;
|
||||
class Switch_d;
|
||||
class FaultModel;
|
||||
|
||||
class Router_d : public BasicRouter
|
||||
{
|
||||
public:
|
||||
typedef GarnetRouter_dParams Params;
|
||||
Router_d(const Params *p);
|
||||
|
||||
~Router_d();
|
||||
|
||||
void init();
|
||||
void addInPort(NetworkLink_d *link, CreditLink_d *credit_link);
|
||||
void addOutPort(NetworkLink_d *link, const NetDest& routing_table_entry,
|
||||
int link_weight, CreditLink_d *credit_link);
|
||||
|
||||
int get_num_vcs() { return m_num_vcs; }
|
||||
int get_num_vnets() { return m_virtual_networks; }
|
||||
int get_vc_per_vnet() { return m_vc_per_vnet; }
|
||||
int get_num_inports() { return m_input_unit.size(); }
|
||||
int get_num_outports() { return m_output_unit.size(); }
|
||||
int get_id() { return m_id; }
|
||||
|
||||
void init_net_ptr(GarnetNetwork_d* net_ptr)
|
||||
{
|
||||
m_network_ptr = net_ptr;
|
||||
}
|
||||
|
||||
GarnetNetwork_d* get_net_ptr() { return m_network_ptr; }
|
||||
std::vector<InputUnit_d *>& get_inputUnit_ref() { return m_input_unit; }
|
||||
std::vector<OutputUnit_d *>& get_outputUnit_ref() { return m_output_unit; }
|
||||
|
||||
void update_sw_winner(int inport, flit_d *t_flit);
|
||||
void update_incredit(int in_port, int in_vc, int credit);
|
||||
void route_req(flit_d *t_flit, InputUnit_d* in_unit, int invc);
|
||||
void vcarb_req();
|
||||
void swarb_req();
|
||||
void printConfig(std::ostream& out);
|
||||
void printFaultVector(std::ostream& out);
|
||||
void printAggregateFaultProbability(std::ostream& out);
|
||||
|
||||
double calculate_power();
|
||||
void calculate_performance_numbers();
|
||||
|
||||
double get_dynamic_power(){return m_power_dyn;}
|
||||
double get_static_power(){return m_power_sta;}
|
||||
double get_clk_power(){return m_clk_power;}
|
||||
bool get_fault_vector(int temperature, float fault_vector[]){
|
||||
return m_network_ptr->fault_model->fault_vector(m_id, temperature,
|
||||
fault_vector);
|
||||
}
|
||||
bool get_aggregate_fault_probability(int temperature,
|
||||
float *aggregate_fault_prob){
|
||||
return m_network_ptr->fault_model->fault_prob(m_id, temperature,
|
||||
aggregate_fault_prob);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
|
||||
GarnetNetwork_d *m_network_ptr;
|
||||
|
||||
std::vector<double> buf_read_count;
|
||||
std::vector<double> buf_write_count;
|
||||
std::vector<double> vc_local_arbit_count;
|
||||
std::vector<double> vc_global_arbit_count;
|
||||
double sw_local_arbit_count, sw_global_arbit_count;
|
||||
double crossbar_count;
|
||||
|
||||
std::vector<InputUnit_d *> m_input_unit;
|
||||
std::vector<OutputUnit_d *> m_output_unit;
|
||||
RoutingUnit_d *m_routing_unit;
|
||||
VCallocator_d *m_vc_alloc;
|
||||
SWallocator_d *m_sw_alloc;
|
||||
Switch_d *m_switch;
|
||||
|
||||
double m_power_dyn;
|
||||
double m_power_sta;
|
||||
double m_clk_power;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTER_D_HH__
|
||||
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "base/cast.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.hh"
|
||||
#include "mem/ruby/slicc_interface/NetworkMessage.hh"
|
||||
|
||||
RoutingUnit_d::RoutingUnit_d(Router_d *router)
|
||||
{
|
||||
m_router = router;
|
||||
m_routing_table.clear();
|
||||
m_weight_table.clear();
|
||||
}
|
||||
|
||||
void
|
||||
RoutingUnit_d::addRoute(const NetDest& routing_table_entry)
|
||||
{
|
||||
m_routing_table.push_back(routing_table_entry);
|
||||
}
|
||||
|
||||
void
|
||||
RoutingUnit_d::addWeight(int link_weight)
|
||||
{
|
||||
m_weight_table.push_back(link_weight);
|
||||
}
|
||||
|
||||
void
|
||||
RoutingUnit_d::RC_stage(flit_d *t_flit, InputUnit_d *in_unit, int invc)
|
||||
{
|
||||
int outport = routeCompute(t_flit);
|
||||
in_unit->updateRoute(invc, outport);
|
||||
t_flit->advance_stage(VA_);
|
||||
m_router->vcarb_req();
|
||||
}
|
||||
|
||||
int
|
||||
RoutingUnit_d::routeCompute(flit_d *t_flit)
|
||||
{
|
||||
MsgPtr msg_ptr = t_flit->get_msg_ptr();
|
||||
NetworkMessage* net_msg_ptr = safe_cast<NetworkMessage *>(msg_ptr.get());
|
||||
NetDest msg_destination = net_msg_ptr->getInternalDestination();
|
||||
|
||||
int output_link = -1;
|
||||
int min_weight = INFINITE_;
|
||||
|
||||
for (int link = 0; link < m_routing_table.size(); link++) {
|
||||
if (msg_destination.intersectionIsNotEmpty(m_routing_table[link])) {
|
||||
if (m_weight_table[link] >= min_weight)
|
||||
continue;
|
||||
output_link = link;
|
||||
min_weight = m_weight_table[link];
|
||||
}
|
||||
}
|
||||
|
||||
if (output_link == -1) {
|
||||
fatal("Fatal Error:: No Route exists from this Router.");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return output_link;
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTING_UNIT_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTING_UNIT_D_HH__
|
||||
|
||||
#include "mem/ruby/common/Consumer.hh"
|
||||
#include "mem/ruby/common/NetDest.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
|
||||
class InputUnit_d;
|
||||
class Router_d;
|
||||
|
||||
class RoutingUnit_d
|
||||
{
|
||||
public:
|
||||
RoutingUnit_d(Router_d *router);
|
||||
void addRoute(const NetDest& routing_table_entry);
|
||||
int routeCompute(flit_d *t_flit);
|
||||
void addWeight(int link_weight);
|
||||
void RC_stage(flit_d *t_flit, InputUnit_d *in_unit, int invc);
|
||||
|
||||
private:
|
||||
Router_d *m_router;
|
||||
std::vector<NetDest> m_routing_table;
|
||||
std::vector<int> m_weight_table;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTING_UNIT_D_HH__
|
||||
@ -0,0 +1,54 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2009 The Hewlett-Packard Development Company
|
||||
# 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.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['PROTOCOL'] == 'None':
|
||||
Return()
|
||||
|
||||
SimObject('GarnetLink_d.py')
|
||||
SimObject('GarnetNetwork_d.py')
|
||||
SimObject('GarnetRouter_d.py')
|
||||
|
||||
Source('GarnetLink_d.cc')
|
||||
Source('GarnetNetwork_d.cc')
|
||||
Source('InputUnit_d.cc')
|
||||
Source('NetworkInterface_d.cc')
|
||||
Source('NetworkLink_d.cc')
|
||||
Source('OutVcState_d.cc')
|
||||
Source('OutputUnit_d.cc')
|
||||
Source('Router_d.cc')
|
||||
Source('RoutingUnit_d.cc')
|
||||
Source('SWallocator_d.cc')
|
||||
Source('Switch_d.cc')
|
||||
Source('VCallocator_d.cc')
|
||||
Source('VirtualChannel_d.cc')
|
||||
Source('flitBuffer_d.cc')
|
||||
Source('flit_d.cc')
|
||||
@ -0,0 +1,235 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh"
|
||||
|
||||
SWallocator_d::SWallocator_d(Router_d *router)
|
||||
{
|
||||
m_router = router;
|
||||
m_num_vcs = m_router->get_num_vcs();
|
||||
m_vc_per_vnet = m_router->get_vc_per_vnet();
|
||||
|
||||
m_local_arbiter_activity = 0;
|
||||
m_global_arbiter_activity = 0;
|
||||
}
|
||||
|
||||
void
|
||||
SWallocator_d::init()
|
||||
{
|
||||
m_input_unit = m_router->get_inputUnit_ref();
|
||||
m_output_unit = m_router->get_outputUnit_ref();
|
||||
|
||||
m_num_inports = m_router->get_num_inports();
|
||||
m_num_outports = m_router->get_num_outports();
|
||||
m_round_robin_outport.resize(m_num_outports);
|
||||
m_round_robin_inport.resize(m_num_inports);
|
||||
m_port_req.resize(m_num_outports);
|
||||
m_vc_winners.resize(m_num_outports);
|
||||
|
||||
for (int i = 0; i < m_num_inports; i++) {
|
||||
m_round_robin_inport[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_num_outports; i++) {
|
||||
m_port_req[i].resize(m_num_inports);
|
||||
m_vc_winners[i].resize(m_num_inports);
|
||||
|
||||
m_round_robin_outport[i] = 0;
|
||||
|
||||
for (int j = 0; j < m_num_inports; j++) {
|
||||
m_port_req[i][j] = false; // [outport][inport]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWallocator_d::wakeup()
|
||||
{
|
||||
arbitrate_inports(); // First stage of allocation
|
||||
arbitrate_outports(); // Second stage of allocation
|
||||
|
||||
clear_request_vector();
|
||||
check_for_wakeup();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SWallocator_d::arbitrate_inports()
|
||||
{
|
||||
// First do round robin arbitration on a set of input vc requests
|
||||
for (int inport = 0; inport < m_num_inports; inport++) {
|
||||
int invc = m_round_robin_inport[inport];
|
||||
|
||||
// Select next round robin vc candidate within valid vnet
|
||||
int next_round_robin_invc = invc;
|
||||
do {
|
||||
next_round_robin_invc++;
|
||||
|
||||
if (next_round_robin_invc >= m_num_vcs)
|
||||
next_round_robin_invc = 0;
|
||||
} while (!((m_router->get_net_ptr())->validVirtualNetwork(
|
||||
get_vnet(next_round_robin_invc))));
|
||||
|
||||
m_round_robin_inport[inport] = next_round_robin_invc;
|
||||
|
||||
for (int invc_iter = 0; invc_iter < m_num_vcs; invc_iter++) {
|
||||
invc++;
|
||||
if (invc >= m_num_vcs)
|
||||
invc = 0;
|
||||
|
||||
if (!((m_router->get_net_ptr())->validVirtualNetwork(
|
||||
get_vnet(invc))))
|
||||
continue;
|
||||
|
||||
if (m_input_unit[inport]->need_stage(invc, ACTIVE_, SA_) &&
|
||||
m_input_unit[inport]->has_credits(invc)) {
|
||||
if (is_candidate_inport(inport, invc)) {
|
||||
int outport = m_input_unit[inport]->get_route(invc);
|
||||
m_local_arbiter_activity++;
|
||||
m_port_req[outport][inport] = true;
|
||||
m_vc_winners[outport][inport]= invc;
|
||||
break; // got one vc winner for this port
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
SWallocator_d::is_candidate_inport(int inport, int invc)
|
||||
{
|
||||
int outport = m_input_unit[inport]->get_route(invc);
|
||||
int t_enqueue_time = m_input_unit[inport]->get_enqueue_time(invc);
|
||||
int t_vnet = get_vnet(invc);
|
||||
int vc_base = t_vnet*m_vc_per_vnet;
|
||||
if ((m_router->get_net_ptr())->isVNetOrdered(t_vnet)) {
|
||||
for (int vc_offset = 0; vc_offset < m_vc_per_vnet; vc_offset++) {
|
||||
int temp_vc = vc_base + vc_offset;
|
||||
if (m_input_unit[inport]->need_stage(temp_vc, ACTIVE_, SA_) &&
|
||||
(m_input_unit[inport]->get_route(temp_vc) == outport) &&
|
||||
(m_input_unit[inport]->get_enqueue_time(temp_vc) <
|
||||
t_enqueue_time)) {
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SWallocator_d::arbitrate_outports()
|
||||
{
|
||||
// Now there are a set of input vc requests for output vcs.
|
||||
// Again do round robin arbitration on these requests
|
||||
for (int outport = 0; outport < m_num_outports; outport++) {
|
||||
int inport = m_round_robin_outport[outport];
|
||||
m_round_robin_outport[outport]++;
|
||||
|
||||
if (m_round_robin_outport[outport] >= m_num_outports)
|
||||
m_round_robin_outport[outport] = 0;
|
||||
|
||||
for (int inport_iter = 0; inport_iter < m_num_inports; inport_iter++) {
|
||||
inport++;
|
||||
if (inport >= m_num_inports)
|
||||
inport = 0;
|
||||
|
||||
// inport has a request this cycle for outport:
|
||||
if (m_port_req[outport][inport]) {
|
||||
m_port_req[outport][inport] = false;
|
||||
int invc = m_vc_winners[outport][inport];
|
||||
int outvc = m_input_unit[inport]->get_outvc(invc);
|
||||
|
||||
// remove flit from Input Unit
|
||||
flit_d *t_flit = m_input_unit[inport]->getTopFlit(invc);
|
||||
t_flit->advance_stage(ST_);
|
||||
t_flit->set_vc(outvc);
|
||||
t_flit->set_outport(outport);
|
||||
t_flit->set_time(g_eventQueue_ptr->getTime() + 1);
|
||||
m_output_unit[outport]->decrement_credit(outvc);
|
||||
m_router->update_sw_winner(inport, t_flit);
|
||||
m_global_arbiter_activity++;
|
||||
|
||||
if ((t_flit->get_type() == TAIL_) ||
|
||||
t_flit->get_type() == HEAD_TAIL_) {
|
||||
// Send a credit back
|
||||
// along with the information that this VC is now idle
|
||||
m_input_unit[inport]->increment_credit(invc, true);
|
||||
// This Input VC should now be empty
|
||||
assert(m_input_unit[inport]->isReady(invc) == false);
|
||||
|
||||
m_input_unit[inport]->set_vc_state(IDLE_, invc);
|
||||
m_input_unit[inport]->set_enqueue_time(invc, INFINITE_);
|
||||
} else {
|
||||
// Send a credit back
|
||||
// but do not indicate that the VC is idle
|
||||
m_input_unit[inport]->increment_credit(invc, false);
|
||||
}
|
||||
break; // got a in request for this outport
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SWallocator_d::check_for_wakeup()
|
||||
{
|
||||
for (int i = 0; i < m_num_inports; i++) {
|
||||
for (int j = 0; j < m_num_vcs; j++) {
|
||||
if (m_input_unit[i]->need_stage_nextcycle(j, ACTIVE_, SA_)) {
|
||||
g_eventQueue_ptr->scheduleEvent(this, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SWallocator_d::get_vnet(int invc)
|
||||
{
|
||||
int vnet = invc/m_vc_per_vnet;
|
||||
assert(vnet < m_router->get_num_vnets());
|
||||
return vnet;
|
||||
}
|
||||
|
||||
void
|
||||
SWallocator_d::clear_request_vector()
|
||||
{
|
||||
for (int i = 0; i < m_num_outports; i++) {
|
||||
for (int j = 0; j < m_num_inports; j++) {
|
||||
m_port_req[i][j] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SW_ALLOCATOR_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SW_ALLOCATOR_D_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Consumer.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
|
||||
class Router_d;
|
||||
class InputUnit_d;
|
||||
class OutputUnit_d;
|
||||
|
||||
class SWallocator_d : public Consumer
|
||||
{
|
||||
public:
|
||||
SWallocator_d(Router_d *router);
|
||||
void wakeup();
|
||||
void init();
|
||||
void clear_request_vector();
|
||||
void check_for_wakeup();
|
||||
int get_vnet (int invc);
|
||||
void print(std::ostream& out) const {};
|
||||
void arbitrate_inports();
|
||||
void arbitrate_outports();
|
||||
bool is_candidate_inport(int inport, int invc);
|
||||
|
||||
inline double
|
||||
get_local_arbit_count()
|
||||
{
|
||||
return m_local_arbiter_activity;
|
||||
}
|
||||
inline double
|
||||
get_global_arbit_count()
|
||||
{
|
||||
return m_global_arbiter_activity;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_num_inports, m_num_outports;
|
||||
int m_num_vcs, m_vc_per_vnet;
|
||||
|
||||
double m_local_arbiter_activity, m_global_arbiter_activity;
|
||||
|
||||
Router_d *m_router;
|
||||
std::vector<int> m_round_robin_outport;
|
||||
std::vector<int> m_round_robin_inport;
|
||||
std::vector<std::vector<bool> > m_port_req;
|
||||
std::vector<std::vector<int> > m_vc_winners; // a list for each outport
|
||||
std::vector<InputUnit_d *> m_input_unit;
|
||||
std::vector<OutputUnit_d *> m_output_unit;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SW_ALLOCATOR_D_HH__
|
||||
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "base/stl_helpers.hh"
|
||||
#include "debug/RubyNetwork.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh"
|
||||
|
||||
using m5::stl_helpers::deletePointers;
|
||||
|
||||
Switch_d::Switch_d(Router_d *router)
|
||||
{
|
||||
m_router = router;
|
||||
m_num_vcs = m_router->get_num_vcs();
|
||||
m_crossbar_activity = 0;
|
||||
}
|
||||
|
||||
Switch_d::~Switch_d()
|
||||
{
|
||||
deletePointers(m_switch_buffer);
|
||||
}
|
||||
|
||||
void
|
||||
Switch_d::init()
|
||||
{
|
||||
m_output_unit = m_router->get_outputUnit_ref();
|
||||
|
||||
m_num_inports = m_router->get_num_inports();
|
||||
m_switch_buffer.resize(m_num_inports);
|
||||
for (int i = 0; i < m_num_inports; i++) {
|
||||
m_switch_buffer[i] = new flitBuffer_d();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Switch_d::wakeup()
|
||||
{
|
||||
DPRINTF(RubyNetwork, "Switch woke up at time: %lld\n",
|
||||
g_eventQueue_ptr->getTime());
|
||||
|
||||
for (int inport = 0; inport < m_num_inports; inport++) {
|
||||
if (!m_switch_buffer[inport]->isReady())
|
||||
continue;
|
||||
flit_d *t_flit = m_switch_buffer[inport]->peekTopFlit();
|
||||
if (t_flit->is_stage(ST_)) {
|
||||
int outport = t_flit->get_outport();
|
||||
t_flit->advance_stage(LT_);
|
||||
t_flit->set_time(g_eventQueue_ptr->getTime() + 1);
|
||||
|
||||
// This will take care of waking up the Network Link
|
||||
m_output_unit[outport]->insert_flit(t_flit);
|
||||
m_switch_buffer[inport]->getTopFlit();
|
||||
m_crossbar_activity++;
|
||||
}
|
||||
}
|
||||
check_for_wakeup();
|
||||
}
|
||||
|
||||
void
|
||||
Switch_d::check_for_wakeup()
|
||||
{
|
||||
for (int inport = 0; inport < m_num_inports; inport++) {
|
||||
if (m_switch_buffer[inport]->isReadyForNext()) {
|
||||
g_eventQueue_ptr->scheduleEvent(this, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SWITCH_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SWITCH_D_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Consumer.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
|
||||
class Router_d;
|
||||
class OutputUnit_d;
|
||||
|
||||
class Switch_d : public Consumer
|
||||
{
|
||||
public:
|
||||
Switch_d(Router_d *router);
|
||||
~Switch_d();
|
||||
void wakeup();
|
||||
void init();
|
||||
void check_for_wakeup();
|
||||
void print(std::ostream& out) const {};
|
||||
|
||||
inline void
|
||||
update_sw_winner(int inport, flit_d *t_flit)
|
||||
{
|
||||
m_switch_buffer[inport]->insert(t_flit);
|
||||
}
|
||||
|
||||
inline double
|
||||
get_crossbar_count()
|
||||
{
|
||||
return m_crossbar_activity;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_num_vcs;
|
||||
int m_num_inports;
|
||||
double m_crossbar_activity;
|
||||
Router_d *m_router;
|
||||
std::vector<flitBuffer_d *> m_switch_buffer;
|
||||
std::vector<OutputUnit_d *> m_output_unit;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SWITCH_D_HH__
|
||||
@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh"
|
||||
|
||||
VCallocator_d::VCallocator_d(Router_d *router)
|
||||
{
|
||||
m_router = router;
|
||||
m_num_vcs = m_router->get_num_vcs();
|
||||
m_vc_per_vnet = m_router->get_vc_per_vnet();
|
||||
|
||||
m_local_arbiter_activity.resize(m_num_vcs/m_vc_per_vnet);
|
||||
m_global_arbiter_activity.resize(m_num_vcs/m_vc_per_vnet);
|
||||
for (int i = 0; i < m_local_arbiter_activity.size(); i++) {
|
||||
m_local_arbiter_activity[i] = 0;
|
||||
m_global_arbiter_activity[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VCallocator_d::init()
|
||||
{
|
||||
m_input_unit = m_router->get_inputUnit_ref();
|
||||
m_output_unit = m_router->get_outputUnit_ref();
|
||||
|
||||
m_num_inports = m_router->get_num_inports();
|
||||
m_num_outports = m_router->get_num_outports();
|
||||
m_round_robin_invc.resize(m_num_inports);
|
||||
m_round_robin_outvc.resize(m_num_outports);
|
||||
m_outvc_req.resize(m_num_outports);
|
||||
m_outvc_is_req.resize(m_num_outports);
|
||||
|
||||
for (int i = 0; i < m_num_inports; i++) {
|
||||
m_round_robin_invc[i].resize(m_num_vcs);
|
||||
|
||||
for (int j = 0; j < m_num_vcs; j++) {
|
||||
m_round_robin_invc[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_num_outports; i++) {
|
||||
m_round_robin_outvc[i].resize(m_num_vcs);
|
||||
m_outvc_req[i].resize(m_num_vcs);
|
||||
m_outvc_is_req[i].resize(m_num_vcs);
|
||||
|
||||
for (int j = 0; j < m_num_vcs; j++) {
|
||||
m_round_robin_outvc[i][j].first = 0;
|
||||
m_round_robin_outvc[i][j].second = 0;
|
||||
m_outvc_is_req[i][j] = false;
|
||||
|
||||
m_outvc_req[i][j].resize(m_num_inports);
|
||||
|
||||
for (int k = 0; k < m_num_inports; k++) {
|
||||
m_outvc_req[i][j][k].resize(m_num_vcs);
|
||||
for (int l = 0; l < m_num_vcs; l++) {
|
||||
m_outvc_req[i][j][k][l] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VCallocator_d::clear_request_vector()
|
||||
{
|
||||
for (int i = 0; i < m_num_outports; i++) {
|
||||
for (int j = 0; j < m_num_vcs; j++) {
|
||||
if (!m_outvc_is_req[i][j])
|
||||
continue;
|
||||
m_outvc_is_req[i][j] = false;
|
||||
for (int k = 0; k < m_num_inports; k++) {
|
||||
for (int l = 0; l < m_num_vcs; l++) {
|
||||
m_outvc_req[i][j][k][l] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VCallocator_d::wakeup()
|
||||
{
|
||||
arbitrate_invcs(); // First stage of allocation
|
||||
arbitrate_outvcs(); // Second stage of allocation
|
||||
|
||||
clear_request_vector();
|
||||
check_for_wakeup();
|
||||
}
|
||||
|
||||
bool
|
||||
VCallocator_d::is_invc_candidate(int inport_iter, int invc_iter)
|
||||
{
|
||||
int outport = m_input_unit[inport_iter]->get_route(invc_iter);
|
||||
int vnet = get_vnet(invc_iter);
|
||||
int t_enqueue_time =
|
||||
m_input_unit[inport_iter]->get_enqueue_time(invc_iter);
|
||||
|
||||
int invc_base = vnet*m_vc_per_vnet;
|
||||
|
||||
if ((m_router->get_net_ptr())->isVNetOrdered(vnet)) {
|
||||
for (int vc_offset = 0; vc_offset < m_vc_per_vnet; vc_offset++) {
|
||||
int temp_vc = invc_base + vc_offset;
|
||||
if (m_input_unit[inport_iter]->need_stage(temp_vc, VC_AB_, VA_) &&
|
||||
(m_input_unit[inport_iter]->get_route(temp_vc) == outport) &&
|
||||
(m_input_unit[inport_iter]->get_enqueue_time(temp_vc) <
|
||||
t_enqueue_time)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
VCallocator_d::select_outvc(int inport_iter, int invc_iter)
|
||||
{
|
||||
int outport = m_input_unit[inport_iter]->get_route(invc_iter);
|
||||
int vnet = get_vnet(invc_iter);
|
||||
int outvc_base = vnet*m_vc_per_vnet;
|
||||
int num_vcs_per_vnet = m_vc_per_vnet;
|
||||
|
||||
int outvc_offset = m_round_robin_invc[inport_iter][invc_iter];
|
||||
m_round_robin_invc[inport_iter][invc_iter]++;
|
||||
|
||||
if (m_round_robin_invc[inport_iter][invc_iter] >= num_vcs_per_vnet)
|
||||
m_round_robin_invc[inport_iter][invc_iter] = 0;
|
||||
|
||||
for (int outvc_offset_iter = 0; outvc_offset_iter < num_vcs_per_vnet;
|
||||
outvc_offset_iter++) {
|
||||
outvc_offset++;
|
||||
if (outvc_offset >= num_vcs_per_vnet)
|
||||
outvc_offset = 0;
|
||||
int outvc = outvc_base + outvc_offset;
|
||||
if (m_output_unit[outport]->is_vc_idle(outvc)) {
|
||||
m_local_arbiter_activity[vnet]++;
|
||||
m_outvc_req[outport][outvc][inport_iter][invc_iter] = true;
|
||||
if (!m_outvc_is_req[outport][outvc])
|
||||
m_outvc_is_req[outport][outvc] = true;
|
||||
return; // out vc acquired
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VCallocator_d::arbitrate_invcs()
|
||||
{
|
||||
for (int inport_iter = 0; inport_iter < m_num_inports; inport_iter++) {
|
||||
for (int invc_iter = 0; invc_iter < m_num_vcs; invc_iter++) {
|
||||
if (!((m_router->get_net_ptr())->validVirtualNetwork(
|
||||
get_vnet(invc_iter))))
|
||||
continue;
|
||||
|
||||
if (m_input_unit[inport_iter]->need_stage(
|
||||
invc_iter, VC_AB_, VA_)) {
|
||||
if (!is_invc_candidate(inport_iter, invc_iter))
|
||||
continue;
|
||||
|
||||
select_outvc(inport_iter, invc_iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VCallocator_d::arbitrate_outvcs()
|
||||
{
|
||||
for (int outport_iter = 0; outport_iter < m_num_outports; outport_iter++) {
|
||||
for (int outvc_iter = 0; outvc_iter < m_num_vcs; outvc_iter++) {
|
||||
if (!m_outvc_is_req[outport_iter][outvc_iter]) {
|
||||
// No requests for this outvc in this cycle
|
||||
continue;
|
||||
}
|
||||
|
||||
int inport = m_round_robin_outvc[outport_iter][outvc_iter].first;
|
||||
int invc_offset =
|
||||
m_round_robin_outvc[outport_iter][outvc_iter].second;
|
||||
int vnet = get_vnet(outvc_iter);
|
||||
int invc_base = vnet*m_vc_per_vnet;
|
||||
int num_vcs_per_vnet = m_vc_per_vnet;
|
||||
|
||||
m_round_robin_outvc[outport_iter][outvc_iter].second++;
|
||||
if (m_round_robin_outvc[outport_iter][outvc_iter].second >=
|
||||
num_vcs_per_vnet) {
|
||||
m_round_robin_outvc[outport_iter][outvc_iter].second = 0;
|
||||
m_round_robin_outvc[outport_iter][outvc_iter].first++;
|
||||
if (m_round_robin_outvc[outport_iter][outvc_iter].first >=
|
||||
m_num_inports)
|
||||
m_round_robin_outvc[outport_iter][outvc_iter].first = 0;
|
||||
}
|
||||
for (int in_iter = 0; in_iter < m_num_inports*num_vcs_per_vnet;
|
||||
in_iter++) {
|
||||
invc_offset++;
|
||||
if (invc_offset >= num_vcs_per_vnet) {
|
||||
invc_offset = 0;
|
||||
inport++;
|
||||
if (inport >= m_num_inports)
|
||||
inport = 0;
|
||||
}
|
||||
int invc = invc_base + invc_offset;
|
||||
if (m_outvc_req[outport_iter][outvc_iter][inport][invc]) {
|
||||
m_global_arbiter_activity[vnet]++;
|
||||
m_input_unit[inport]->grant_vc(invc, outvc_iter);
|
||||
m_output_unit[outport_iter]->update_vc(
|
||||
outvc_iter, inport, invc);
|
||||
m_router->swarb_req();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
VCallocator_d::get_vnet(int invc)
|
||||
{
|
||||
int vnet = invc/m_vc_per_vnet;
|
||||
assert(vnet < m_router->get_num_vnets());
|
||||
|
||||
return vnet;
|
||||
}
|
||||
|
||||
void
|
||||
VCallocator_d::check_for_wakeup()
|
||||
{
|
||||
for (int i = 0; i < m_num_inports; i++) {
|
||||
for (int j = 0; j < m_num_vcs; j++) {
|
||||
if (m_input_unit[i]->need_stage_nextcycle(j, VC_AB_, VA_)) {
|
||||
g_eventQueue_ptr->scheduleEvent(this, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VC_ALLOCATOR_D_HH__
|
||||
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VC_ALLOCATOR_D_HH__
|
||||
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "mem/ruby/common/Consumer.hh"
|
||||
#include "mem/ruby/network/garnet/NetworkHeader.hh"
|
||||
|
||||
class Router_d;
|
||||
class InputUnit_d;
|
||||
class OutputUnit_d;
|
||||
|
||||
class VCallocator_d : public Consumer
|
||||
{
|
||||
public:
|
||||
VCallocator_d(Router_d *router);
|
||||
void init();
|
||||
void wakeup();
|
||||
void check_for_wakeup();
|
||||
void clear_request_vector();
|
||||
int get_vnet(int invc);
|
||||
void print(std::ostream& out) const {}
|
||||
void arbitrate_invcs();
|
||||
void arbitrate_outvcs();
|
||||
bool is_invc_candidate(int inport_iter, int invc_iter);
|
||||
void select_outvc(int inport_iter, int invc_iter);
|
||||
|
||||
inline double
|
||||
get_local_arbit_count(int vnet)
|
||||
{
|
||||
return m_local_arbiter_activity[vnet];
|
||||
}
|
||||
|
||||
inline double
|
||||
get_global_arbit_count(int vnet)
|
||||
{
|
||||
return m_global_arbiter_activity[vnet];
|
||||
}
|
||||
|
||||
private:
|
||||
int m_num_vcs, m_vc_per_vnet;
|
||||
int m_num_inports;
|
||||
int m_num_outports;
|
||||
|
||||
std::vector<double > m_local_arbiter_activity;
|
||||
std::vector<double > m_global_arbiter_activity;
|
||||
|
||||
Router_d *m_router;
|
||||
|
||||
// First stage of arbitration
|
||||
// where all vcs select an output vc to contend for
|
||||
std::vector<std::vector<int> > m_round_robin_invc;
|
||||
|
||||
// Arbiter for every output vc
|
||||
std::vector<std::vector<std::pair<int, int> > > m_round_robin_outvc;
|
||||
|
||||
// [outport][outvc][inport][invc]
|
||||
// set true in the first phase of allocation
|
||||
std::vector<std::vector<std::vector<std::vector<bool> > > > m_outvc_req;
|
||||
|
||||
std::vector<std::vector<bool> > m_outvc_is_req;
|
||||
|
||||
std::vector<InputUnit_d *> m_input_unit;
|
||||
std::vector<OutputUnit_d *> m_output_unit;
|
||||
};
|
||||
|
||||
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VC_ALLOCATOR_D_HH__
|
||||
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Princeton University
|
||||
* 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.
|
||||
*
|
||||
* Authors: Niket Agarwal
|
||||
*/
|
||||
|
||||
#include "mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh"
|
||||
|
||||
VirtualChannel_d::VirtualChannel_d(int id)
|
||||
{
|
||||
m_id = id;
|
||||
m_input_buffer = new flitBuffer_d();
|
||||
m_vc_state.first = IDLE_;
|
||||
m_vc_state.second = g_eventQueue_ptr->getTime();
|
||||
m_enqueue_time = INFINITE_;
|
||||
}
|
||||
|
||||
VirtualChannel_d::~VirtualChannel_d()
|
||||
{
|
||||
delete m_input_buffer;
|
||||
}
|
||||
|
||||
void
|
||||
VirtualChannel_d::set_outport(int outport)
|
||||
{
|
||||
route = outport;
|
||||
}
|
||||
|
||||
void
|
||||
VirtualChannel_d::grant_vc(int out_vc)
|
||||
{
|
||||
m_output_vc = out_vc;
|
||||
m_vc_state.first = ACTIVE_;
|
||||
m_vc_state.second = g_eventQueue_ptr->getTime() + 1;
|
||||
flit_d *t_flit = m_input_buffer->peekTopFlit();
|
||||
t_flit->advance_stage(SA_);
|
||||
}
|
||||
|
||||
bool
|
||||
VirtualChannel_d::need_stage(VC_state_type state, flit_stage stage)
|
||||
{
|
||||
if ((m_vc_state.first == state) &&
|
||||
(g_eventQueue_ptr->getTime() >= m_vc_state.second)) {
|
||||
if (m_input_buffer->isReady()) {
|
||||
flit_d *t_flit = m_input_buffer->peekTopFlit();
|
||||
return(t_flit->is_stage(stage)) ;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
VirtualChannel_d::need_stage_nextcycle(VC_state_type state, flit_stage stage)
|
||||
{
|
||||
if ((m_vc_state.first == state) &&
|
||||
((g_eventQueue_ptr->getTime()+1) >= m_vc_state.second)) {
|
||||
if (m_input_buffer->isReadyForNext()) {
|
||||
flit_d *t_flit = m_input_buffer->peekTopFlit();
|
||||
return(t_flit->is_next_stage(stage)) ;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user