SeriesRequestGenerator.cc revision 6145
112855Sgabeblack@google.com 212855Sgabeblack@google.com/* 312855Sgabeblack@google.com * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 412855Sgabeblack@google.com * All rights reserved. 512855Sgabeblack@google.com * 612855Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 712855Sgabeblack@google.com * modification, are permitted provided that the following conditions are 812855Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 912855Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 1012855Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1112855Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1212855Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1312855Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1412855Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1512855Sgabeblack@google.com * this software without specific prior written permission. 1612855Sgabeblack@google.com * 1712855Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1812855Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1912855Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2012855Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2112855Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2212855Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2312855Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2412855Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2512855Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2612855Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2712855Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2812855Sgabeblack@google.com */ 2912855Sgabeblack@google.com 3012855Sgabeblack@google.com/* 3112855Sgabeblack@google.com * $Id$ 3212855Sgabeblack@google.com * 3312855Sgabeblack@google.com */ 3412855Sgabeblack@google.com 3512855Sgabeblack@google.com// This Deterministic Generator generates GETX requests for all nodes in the system 3612855Sgabeblack@google.com// The GETX requests are generated one at a time in round-robin fashion 0...1...2...etc. 3712855Sgabeblack@google.com 3812855Sgabeblack@google.com#include "DetermGETXGenerator.hh" 3912855Sgabeblack@google.com#include "DetermGETXGeneratorStatus.hh" 4012855Sgabeblack@google.com#include "LockStatus.hh" 4112855Sgabeblack@google.com#include "Sequencer.hh" 4212855Sgabeblack@google.com#include "System.hh" 4312855Sgabeblack@google.com#include "RubyConfig.hh" 4412855Sgabeblack@google.com#include "SubBlock.hh" 4512855Sgabeblack@google.com#include "DeterministicDriver.hh" 4612855Sgabeblack@google.com#include "Chip.hh" 4712855Sgabeblack@google.com 4812855Sgabeblack@google.comDetermGETXGenerator::DetermGETXGenerator(NodeID node, DeterministicDriver& driver) : 4912855Sgabeblack@google.com m_driver(driver) 5012855Sgabeblack@google.com{ 5112855Sgabeblack@google.com m_status = DetermGETXGeneratorStatus_Thinking; 5212855Sgabeblack@google.com m_last_transition = 0; 5312855Sgabeblack@google.com m_node = node; 5412855Sgabeblack@google.com m_address = Address(9999); // initialize to null value 5512855Sgabeblack@google.com m_counter = 0; 5612855Sgabeblack@google.com 5712855Sgabeblack@google.com // don't know exactly when this node needs to request so just guess randomly 5812855Sgabeblack@google.com g_eventQueue_ptr->scheduleEvent(this, 1+(random() % 200)); 5912855Sgabeblack@google.com} 6012855Sgabeblack@google.com 6112855Sgabeblack@google.comDetermGETXGenerator::~DetermGETXGenerator() 6212855Sgabeblack@google.com{ 6312855Sgabeblack@google.com} 6412855Sgabeblack@google.com 6512855Sgabeblack@google.comvoid DetermGETXGenerator::wakeup() 6612855Sgabeblack@google.com{ 6712855Sgabeblack@google.com DEBUG_EXPR(TESTER_COMP, MedPrio, m_node); 6812855Sgabeblack@google.com DEBUG_EXPR(TESTER_COMP, MedPrio, m_status); 6912855Sgabeblack@google.com 7012855Sgabeblack@google.com // determine if this node is next for the GETX round robin request 7112855Sgabeblack@google.com if (m_status == DetermGETXGeneratorStatus_Thinking) { 7212855Sgabeblack@google.com if (m_driver.isStoreReady(m_node)) { 7312855Sgabeblack@google.com pickAddress(); 7412855Sgabeblack@google.com m_status = DetermGETXGeneratorStatus_Store_Pending; // Store Pending 7512855Sgabeblack@google.com m_last_transition = g_eventQueue_ptr->getTime(); 7612855Sgabeblack@google.com initiateStore(); // GETX 7712855Sgabeblack@google.com } else { // I'll check again later 7812855Sgabeblack@google.com g_eventQueue_ptr->scheduleEvent(this, thinkTime()); 7912855Sgabeblack@google.com } 8012855Sgabeblack@google.com } else { 8112855Sgabeblack@google.com WARN_EXPR(m_status); 8212855Sgabeblack@google.com ERROR_MSG("Invalid status"); 8312855Sgabeblack@google.com } 8412855Sgabeblack@google.com 8512855Sgabeblack@google.com} 8612855Sgabeblack@google.com 8712855Sgabeblack@google.comvoid DetermGETXGenerator::performCallback(NodeID proc, SubBlock& data) 8812855Sgabeblack@google.com{ 8912855Sgabeblack@google.com Address address = data.getAddress(); 9012855Sgabeblack@google.com assert(proc == m_node); 9112855Sgabeblack@google.com assert(address == m_address); 9212855Sgabeblack@google.com 9312855Sgabeblack@google.com DEBUG_EXPR(TESTER_COMP, LowPrio, proc); 9412855Sgabeblack@google.com DEBUG_EXPR(TESTER_COMP, LowPrio, m_status); 9512855Sgabeblack@google.com DEBUG_EXPR(TESTER_COMP, LowPrio, address); 9612855Sgabeblack@google.com DEBUG_EXPR(TESTER_COMP, LowPrio, data); 9712855Sgabeblack@google.com 9812855Sgabeblack@google.com if (m_status == DetermGETXGeneratorStatus_Store_Pending) { 9912855Sgabeblack@google.com m_driver.recordStoreLatency(g_eventQueue_ptr->getTime() - m_last_transition); 10012855Sgabeblack@google.com data.writeByte(m_node); 10112855Sgabeblack@google.com m_driver.storeCompleted(m_node, data.getAddress()); // advance the store queue 10212855Sgabeblack@google.com 10312855Sgabeblack@google.com m_counter++; 10412855Sgabeblack@google.com if (m_counter < g_tester_length) { 10512855Sgabeblack@google.com m_status = DetermGETXGeneratorStatus_Thinking; 10612855Sgabeblack@google.com m_last_transition = g_eventQueue_ptr->getTime(); 10712855Sgabeblack@google.com g_eventQueue_ptr->scheduleEvent(this, waitTime()); 10812855Sgabeblack@google.com } else { 10912855Sgabeblack@google.com m_driver.reportDone(); 11012855Sgabeblack@google.com m_status = DetermGETXGeneratorStatus_Done; 11112855Sgabeblack@google.com m_last_transition = g_eventQueue_ptr->getTime(); 11212855Sgabeblack@google.com } 11312855Sgabeblack@google.com 11412855Sgabeblack@google.com } else { 11512855Sgabeblack@google.com WARN_EXPR(m_status); 11612855Sgabeblack@google.com ERROR_MSG("Invalid status"); 11712855Sgabeblack@google.com } 11812855Sgabeblack@google.com} 11912855Sgabeblack@google.com 12012855Sgabeblack@google.comint DetermGETXGenerator::thinkTime() const 12112855Sgabeblack@google.com{ 12212855Sgabeblack@google.com return g_think_time; 12312855Sgabeblack@google.com} 12412855Sgabeblack@google.com 12512855Sgabeblack@google.comint DetermGETXGenerator::waitTime() const 12612855Sgabeblack@google.com{ 12712855Sgabeblack@google.com return g_wait_time; 12812855Sgabeblack@google.com} 12912855Sgabeblack@google.com 13012855Sgabeblack@google.comvoid DetermGETXGenerator::pickAddress() 13112855Sgabeblack@google.com{ 13212855Sgabeblack@google.com assert(m_status == DetermGETXGeneratorStatus_Thinking); 13312855Sgabeblack@google.com 13412855Sgabeblack@google.com m_address = m_driver.getNextStoreAddr(m_node); 13512855Sgabeblack@google.com} 13612855Sgabeblack@google.com 13712855Sgabeblack@google.comvoid DetermGETXGenerator::initiateStore() 13812855Sgabeblack@google.com{ 13912855Sgabeblack@google.com DEBUG_MSG(TESTER_COMP, MedPrio, "initiating Store"); 14012855Sgabeblack@google.com sequencer()->makeRequest(CacheMsg(m_address, m_address, CacheRequestType_ST, Address(3), AccessModeType_UserMode, 1, PrefetchBit_No, 0, Address(0), 0 /* only 1 SMT thread */, 0, false)); 14112855Sgabeblack@google.com} 14212855Sgabeblack@google.com 14312855Sgabeblack@google.comSequencer* DetermGETXGenerator::sequencer() const 14412855Sgabeblack@google.com{ 14512855Sgabeblack@google.com return g_system_ptr->getChip(m_node/RubyConfig::numberOfProcsPerChip())->getSequencer(m_node%RubyConfig::numberOfProcsPerChip()); 14612855Sgabeblack@google.com} 14712855Sgabeblack@google.com 14812855Sgabeblack@google.comvoid DetermGETXGenerator::print(ostream& out) const 14912855Sgabeblack@google.com{ 15012855Sgabeblack@google.com} 15112855Sgabeblack@google.com 15212855Sgabeblack@google.com