2009-05-11 19:38:43 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2009-07-07 00:49:47 +02:00
|
|
|
* RubySystem.cc
|
2009-05-11 19:38:43 +02:00
|
|
|
*
|
2009-07-07 00:49:47 +02:00
|
|
|
* Description: See System.hh
|
2009-05-11 19:38:43 +02:00
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-05-11 19:38:45 +02:00
|
|
|
#include "mem/ruby/system/System.hh"
|
2009-07-07 00:49:47 +02:00
|
|
|
#include "mem/ruby/common/Address.hh"
|
2009-05-11 19:38:45 +02:00
|
|
|
#include "mem/ruby/profiler/Profiler.hh"
|
|
|
|
#include "mem/ruby/network/Network.hh"
|
2009-07-07 00:49:47 +02:00
|
|
|
#include "mem/ruby/recorder/Tracer.hh"
|
2009-05-11 19:38:45 +02:00
|
|
|
#include "mem/protocol/Protocol.hh"
|
2009-07-07 00:49:47 +02:00
|
|
|
#include "mem/ruby/buffers/MessageBuffer.hh"
|
|
|
|
#include "mem/ruby/system/Sequencer.hh"
|
|
|
|
#include "mem/ruby/system/DMASequencer.hh"
|
|
|
|
#include "mem/ruby/system/MemoryVector.hh"
|
|
|
|
#include "mem/ruby/slicc_interface/AbstractController.hh"
|
|
|
|
#include "mem/ruby/system/CacheMemory.hh"
|
|
|
|
#include "mem/ruby/system/DirectoryMemory.hh"
|
|
|
|
#include "mem/ruby/network/simple/Topology.hh"
|
|
|
|
#include "mem/ruby/network/simple/SimpleNetwork.hh"
|
|
|
|
#include "mem/ruby/system/RubyPort.hh"
|
2010-01-30 05:29:17 +01:00
|
|
|
//#include "mem/ruby/network/garnet-flexible-pipeline/GarnetNetwork.hh"
|
|
|
|
//#include "mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh"
|
2009-07-07 00:49:47 +02:00
|
|
|
#include "mem/ruby/system/MemoryControl.hh"
|
|
|
|
|
|
|
|
int RubySystem::m_random_seed;
|
|
|
|
bool RubySystem::m_randomization;
|
2010-01-30 05:29:19 +01:00
|
|
|
Tick RubySystem::m_clock;
|
2009-07-07 00:49:47 +02:00
|
|
|
int RubySystem::m_block_size_bytes;
|
|
|
|
int RubySystem::m_block_size_bits;
|
|
|
|
uint64 RubySystem::m_memory_size_bytes;
|
|
|
|
int RubySystem::m_memory_size_bits;
|
|
|
|
|
|
|
|
map< string, RubyPort* > RubySystem::m_ports;
|
|
|
|
map< string, CacheMemory* > RubySystem::m_caches;
|
|
|
|
map< string, DirectoryMemory* > RubySystem::m_directories;
|
|
|
|
map< string, Sequencer* > RubySystem::m_sequencers;
|
|
|
|
map< string, DMASequencer* > RubySystem::m_dma_sequencers;
|
|
|
|
map< string, AbstractController* > RubySystem::m_controllers;
|
|
|
|
map< string, MemoryControl* > RubySystem::m_memorycontrols;
|
|
|
|
|
|
|
|
|
|
|
|
Network* RubySystem::m_network_ptr;
|
|
|
|
map< string, Topology*> RubySystem::m_topologies;
|
|
|
|
Profiler* RubySystem::m_profiler_ptr;
|
|
|
|
Tracer* RubySystem::m_tracer_ptr;
|
|
|
|
|
|
|
|
MemoryVector* RubySystem::m_mem_vec_ptr;
|
|
|
|
|
|
|
|
|
2010-01-30 05:29:17 +01:00
|
|
|
RubySystem::RubySystem(const Params *p)
|
|
|
|
: SimObject(p)
|
2009-05-11 19:38:46 +02:00
|
|
|
{
|
2010-01-30 05:29:17 +01:00
|
|
|
if (g_system_ptr != NULL)
|
|
|
|
fatal("Only one RubySystem object currently allowed.\n");
|
|
|
|
|
|
|
|
m_random_seed = p->random_seed;
|
|
|
|
srandom(m_random_seed);
|
|
|
|
m_randomization = p->randomization;
|
2010-01-30 05:29:19 +01:00
|
|
|
m_clock = p->clock;
|
2010-01-30 05:29:18 +01:00
|
|
|
|
2010-01-30 05:29:17 +01:00
|
|
|
m_block_size_bytes = p->block_size_bytes;
|
|
|
|
assert(is_power_of_2(m_block_size_bytes));
|
|
|
|
m_block_size_bits = log_int(m_block_size_bytes);
|
2010-01-30 05:29:18 +01:00
|
|
|
|
|
|
|
m_memory_size_bytes = (uint64_t)p->mem_size_mb * 1024 * 1024;
|
|
|
|
m_memory_size_bits = log_int(m_memory_size_bytes);
|
|
|
|
|
2010-01-30 05:29:17 +01:00
|
|
|
m_network_ptr = p->network;
|
|
|
|
g_debug_ptr = p->debug;
|
|
|
|
m_profiler_ptr = p->profiler;
|
|
|
|
m_tracer_ptr = p->tracer;
|
|
|
|
|
2010-01-30 05:29:19 +01:00
|
|
|
g_eventQueue_ptr = new RubyEventQueue(p->eventq, m_clock);
|
2010-01-30 05:29:17 +01:00
|
|
|
g_system_ptr = this;
|
|
|
|
m_mem_vec_ptr = new MemoryVector;
|
2010-01-30 05:29:18 +01:00
|
|
|
m_mem_vec_ptr->setSize(m_memory_size_bytes);
|
2009-05-11 19:38:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-30 05:29:17 +01:00
|
|
|
void RubySystem::init()
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2010-01-30 05:29:20 +01:00
|
|
|
m_profiler_ptr->clearStats();
|
2009-05-11 19:38:46 +02:00
|
|
|
}
|
2009-05-11 19:38:43 +02:00
|
|
|
|
2010-01-30 05:29:17 +01:00
|
|
|
|
2009-07-07 00:49:47 +02:00
|
|
|
RubySystem::~RubySystem()
|
2009-05-11 19:38:46 +02:00
|
|
|
{
|
2009-07-19 01:20:03 +02:00
|
|
|
|
2009-07-07 00:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RubySystem::printSystemConfig(ostream & out)
|
|
|
|
{
|
|
|
|
out << "RubySystem config:" << endl;
|
|
|
|
out << " random_seed: " << m_random_seed << endl;
|
|
|
|
out << " randomization: " << m_randomization << endl;
|
2010-01-30 05:29:19 +01:00
|
|
|
out << " cycle_period: " << m_clock << endl;
|
2009-07-07 00:49:47 +02:00
|
|
|
out << " block_size_bytes: " << m_block_size_bytes << endl;
|
|
|
|
out << " block_size_bits: " << m_block_size_bits << endl;
|
|
|
|
out << " memory_size_bytes: " << m_memory_size_bytes << endl;
|
|
|
|
out << " memory_size_bits: " << m_memory_size_bits << endl;
|
|
|
|
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2009-07-07 00:49:47 +02:00
|
|
|
void RubySystem::printConfig(ostream& out)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2009-05-11 19:38:44 +02:00
|
|
|
out << "\n================ Begin RubySystem Configuration Print ================\n\n";
|
2009-07-07 00:49:47 +02:00
|
|
|
printSystemConfig(out);
|
|
|
|
for (map<string, AbstractController*>::const_iterator it = m_controllers.begin();
|
|
|
|
it != m_controllers.end(); it++) {
|
|
|
|
(*it).second->printConfig(out);
|
|
|
|
}
|
|
|
|
for (map<string, CacheMemory*>::const_iterator it = m_caches.begin();
|
|
|
|
it != m_caches.end(); it++) {
|
|
|
|
(*it).second->printConfig(out);
|
|
|
|
}
|
|
|
|
DirectoryMemory::printGlobalConfig(out);
|
|
|
|
for (map<string, DirectoryMemory*>::const_iterator it = m_directories.begin();
|
|
|
|
it != m_directories.end(); it++) {
|
|
|
|
(*it).second->printConfig(out);
|
|
|
|
}
|
|
|
|
for (map<string, Sequencer*>::const_iterator it = m_sequencers.begin();
|
|
|
|
it != m_sequencers.end(); it++) {
|
|
|
|
(*it).second->printConfig(out);
|
|
|
|
}
|
|
|
|
|
2009-05-11 19:38:43 +02:00
|
|
|
m_network_ptr->printConfig(out);
|
|
|
|
m_profiler_ptr->printConfig(out);
|
2009-07-07 00:49:47 +02:00
|
|
|
|
2009-05-11 19:38:44 +02:00
|
|
|
out << "\n================ End RubySystem Configuration Print ================\n\n";
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2009-05-11 19:38:44 +02:00
|
|
|
void RubySystem::printStats(ostream& out)
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2009-07-07 00:49:47 +02:00
|
|
|
|
2009-05-11 19:38:43 +02:00
|
|
|
const time_t T = time(NULL);
|
|
|
|
tm *localTime = localtime(&T);
|
|
|
|
char buf[100];
|
|
|
|
strftime(buf, 100, "%b/%d/%Y %H:%M:%S", localTime);
|
|
|
|
|
|
|
|
out << "Real time: " << buf << endl;
|
|
|
|
|
|
|
|
m_profiler_ptr->printStats(out);
|
|
|
|
m_network_ptr->printStats(out);
|
2009-11-18 18:55:30 +01:00
|
|
|
for (map<string, Sequencer*>::const_iterator it = m_sequencers.begin();
|
|
|
|
it != m_sequencers.end(); it++) {
|
|
|
|
(*it).second->printStats(out);
|
|
|
|
}
|
2009-07-20 16:40:43 +02:00
|
|
|
for (map<string, CacheMemory*>::const_iterator it = m_caches.begin();
|
|
|
|
it != m_caches.end(); it++) {
|
|
|
|
(*it).second->printStats(out);
|
|
|
|
}
|
2009-07-07 00:49:47 +02:00
|
|
|
for (map<string, AbstractController*>::const_iterator it = m_controllers.begin();
|
|
|
|
it != m_controllers.end(); it++) {
|
|
|
|
(*it).second->printStats(out);
|
|
|
|
}
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2009-05-11 19:38:44 +02:00
|
|
|
void RubySystem::clearStats() const
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
|
|
|
m_profiler_ptr->clearStats();
|
|
|
|
m_network_ptr->clearStats();
|
2009-07-29 20:46:58 +02:00
|
|
|
for (map<string, CacheMemory*>::const_iterator it = m_caches.begin();
|
|
|
|
it != m_caches.end(); it++) {
|
|
|
|
(*it).second->clearStats();
|
|
|
|
}
|
|
|
|
for (map<string, AbstractController*>::const_iterator it = m_controllers.begin();
|
|
|
|
it != m_controllers.end(); it++) {
|
|
|
|
(*it).second->clearStats();
|
|
|
|
}
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
2009-05-11 19:38:44 +02:00
|
|
|
void RubySystem::recordCacheContents(CacheRecorder& tr) const
|
2009-05-11 19:38:43 +02:00
|
|
|
{
|
2009-07-19 01:20:03 +02:00
|
|
|
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CHECK_COHERENCE
|
|
|
|
// This code will check for cases if the given cache block is exclusive in
|
|
|
|
// one node and shared in another-- a coherence violation
|
|
|
|
//
|
|
|
|
// To use, the SLICC specification must call sequencer.checkCoherence(address)
|
|
|
|
// when the controller changes to a state with new permissions. Do this
|
|
|
|
// in setState. The SLICC spec must also define methods "isBlockShared"
|
|
|
|
// and "isBlockExclusive" that are specific to that protocol
|
|
|
|
//
|
2009-05-11 19:38:44 +02:00
|
|
|
void RubySystem::checkGlobalCoherenceInvariant(const Address& addr ) {
|
2009-07-07 00:49:47 +02:00
|
|
|
/*
|
2009-05-11 19:38:43 +02:00
|
|
|
NodeID exclusive = -1;
|
|
|
|
bool sharedDetected = false;
|
|
|
|
NodeID lastShared = -1;
|
|
|
|
|
|
|
|
for (int i = 0; i < m_chip_vector.size(); i++) {
|
|
|
|
|
|
|
|
if (m_chip_vector[i]->isBlockExclusive(addr)) {
|
|
|
|
if (exclusive != -1) {
|
|
|
|
// coherence violation
|
|
|
|
WARN_EXPR(exclusive);
|
|
|
|
WARN_EXPR(m_chip_vector[i]->getID());
|
|
|
|
WARN_EXPR(addr);
|
|
|
|
WARN_EXPR(g_eventQueue_ptr->getTime());
|
|
|
|
ERROR_MSG("Coherence Violation Detected -- 2 exclusive chips");
|
|
|
|
}
|
|
|
|
else if (sharedDetected) {
|
|
|
|
WARN_EXPR(lastShared);
|
|
|
|
WARN_EXPR(m_chip_vector[i]->getID());
|
|
|
|
WARN_EXPR(addr);
|
|
|
|
WARN_EXPR(g_eventQueue_ptr->getTime());
|
|
|
|
ERROR_MSG("Coherence Violation Detected -- exclusive chip with >=1 shared");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
exclusive = m_chip_vector[i]->getID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_chip_vector[i]->isBlockShared(addr)) {
|
|
|
|
sharedDetected = true;
|
|
|
|
lastShared = m_chip_vector[i]->getID();
|
|
|
|
|
|
|
|
if (exclusive != -1) {
|
|
|
|
WARN_EXPR(lastShared);
|
|
|
|
WARN_EXPR(exclusive);
|
|
|
|
WARN_EXPR(addr);
|
|
|
|
WARN_EXPR(g_eventQueue_ptr->getTime());
|
|
|
|
ERROR_MSG("Coherence Violation Detected -- exclusive chip with >=1 shared");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-07 00:49:47 +02:00
|
|
|
*/
|
2009-05-11 19:38:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-01-30 05:29:17 +01:00
|
|
|
RubySystem *
|
|
|
|
RubySystemParams::create()
|
|
|
|
{
|
|
|
|
return new RubySystem(this);
|
|
|
|
}
|