CheckTable.cc revision 8232
16145Snate@binkert.org/* 26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36145Snate@binkert.org * Copyright (c) 2009 Advanced Micro Devices, Inc. 46145Snate@binkert.org * All rights reserved. 56145Snate@binkert.org * 66145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 76145Snate@binkert.org * modification, are permitted provided that the following conditions are 86145Snate@binkert.org * met: redistributions of source code must retain the above copyright 96145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 106145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 116145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 126145Snate@binkert.org * documentation and/or other materials provided with the distribution; 136145Snate@binkert.org * neither the name of the copyright holders nor the names of its 146145Snate@binkert.org * contributors may be used to endorse or promote products derived from 156145Snate@binkert.org * this software without specific prior written permission. 166145Snate@binkert.org * 176145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286145Snate@binkert.org */ 296145Snate@binkert.org 307039Snate@binkert.org#include "base/intmath.hh" 317039Snate@binkert.org#include "cpu/testers/rubytest/Check.hh" 327039Snate@binkert.org#include "cpu/testers/rubytest/CheckTable.hh" 336145Snate@binkert.org#include "debug/RubyTest.hh" 346145Snate@binkert.org 357039Snate@binkert.orgCheckTable::CheckTable(int _num_cpu_sequencers, RubyTester* _tester) 367039Snate@binkert.org : m_num_cpu_sequencers(_num_cpu_sequencers), m_tester_ptr(_tester) 376145Snate@binkert.org{ 387002Snate@binkert.org physical_address_t physical = 0; 397021Stushar@csail.mit.edu Address address; 407002Snate@binkert.org 419465Snilay@cs.wisc.edu const int size1 = 32; 426145Snate@binkert.org const int size2 = 100; 437039Snate@binkert.org 447039Snate@binkert.org // The first set is to get some false sharing 457039Snate@binkert.org physical = 1000; 469465Snilay@cs.wisc.edu for (int i = 0; i < size1; i++) { 479557Sandreas.hansson@arm.com // Setup linear addresses 487039Snate@binkert.org address.setAddress(physical); 497039Snate@binkert.org addCheck(address); 506145Snate@binkert.org physical += CHECK_SIZE; 517039Snate@binkert.org } 527039Snate@binkert.org 537039Snate@binkert.org // The next two sets are to get some limited false sharing and 546145Snate@binkert.org // cache conflicts 557039Snate@binkert.org physical = 1000; 567039Snate@binkert.org for (int i = 0; i < size2; i++) { 577973Snilay@cs.wisc.edu // Setup linear addresses 586145Snate@binkert.org address.setAddress(physical); 599171Snilay@cs.wisc.edu addCheck(address); 607039Snate@binkert.org physical += 256; 617039Snate@binkert.org } 627039Snate@binkert.org 637039Snate@binkert.org physical = 1000 + CHECK_SIZE; 647039Snate@binkert.org for (int i = 0; i < size2; i++) { 657039Snate@binkert.org // Setup linear addresses 669171Snilay@cs.wisc.edu address.setAddress(physical); 677039Snate@binkert.org addCheck(address); 687039Snate@binkert.org physical += 256; 697039Snate@binkert.org } 707039Snate@binkert.org} 717039Snate@binkert.org 729171Snilay@cs.wisc.eduCheckTable::~CheckTable() 737039Snate@binkert.org{ 747039Snate@binkert.org int size = m_check_vector.size(); 757039Snate@binkert.org for (int i = 0; i < size; i++) 767039Snate@binkert.org delete m_check_vector[i]; 777039Snate@binkert.org} 789171Snilay@cs.wisc.edu 797039Snate@binkert.orgvoid 807039Snate@binkert.orgCheckTable::addCheck(const Address& address) 817039Snate@binkert.org{ 827039Snate@binkert.org if (floorLog2(CHECK_SIZE) != 0) { 837039Snate@binkert.org if (address.bitSelect(0, CHECK_SIZE_BITS - 1) != 0) { 849171Snilay@cs.wisc.edu panic("Check not aligned"); 857039Snate@binkert.org } 867039Snate@binkert.org } 877039Snate@binkert.org 887039Snate@binkert.org for (int i = 0; i < CHECK_SIZE; i++) { 897039Snate@binkert.org if (m_lookup_map.count(Address(address.getAddress()+i))) { 909600Snilay@cs.wisc.edu // A mapping for this byte already existed, discard the 919600Snilay@cs.wisc.edu // entire check 929600Snilay@cs.wisc.edu return; 939499Snilay@cs.wisc.edu } 949171Snilay@cs.wisc.edu } 957039Snate@binkert.org 969171Snilay@cs.wisc.edu Check* check_ptr = new Check(address, Address(100 + m_check_vector.size()), 979171Snilay@cs.wisc.edu m_num_cpu_sequencers, m_tester_ptr); 989465Snilay@cs.wisc.edu for (int i = 0; i < CHECK_SIZE; i++) { 999171Snilay@cs.wisc.edu // Insert it once per byte 1009171Snilay@cs.wisc.edu m_lookup_map[Address(address.getAddress() + i)] = check_ptr; 1019171Snilay@cs.wisc.edu } 1029171Snilay@cs.wisc.edu m_check_vector.push_back(check_ptr); 1039171Snilay@cs.wisc.edu} 1049171Snilay@cs.wisc.edu 1059171Snilay@cs.wisc.eduCheck* 1069171Snilay@cs.wisc.eduCheckTable::getRandomCheck() 1079171Snilay@cs.wisc.edu{ 1089171Snilay@cs.wisc.edu return m_check_vector[random() % m_check_vector.size()]; 1099171Snilay@cs.wisc.edu} 1109171Snilay@cs.wisc.edu 1119171Snilay@cs.wisc.eduCheck* 1129171Snilay@cs.wisc.eduCheckTable::getCheck(const Address& address) 1139171Snilay@cs.wisc.edu{ 1149171Snilay@cs.wisc.edu DPRINTF(RubyTest, "Looking for check by address: %s", address); 1159171Snilay@cs.wisc.edu 1169171Snilay@cs.wisc.edu m5::hash_map<Address, Check*>::iterator i = m_lookup_map.find(address); 1176145Snate@binkert.org 1186145Snate@binkert.org if (i == m_lookup_map.end()) 1197039Snate@binkert.org return NULL; 1207039Snate@binkert.org 1216145Snate@binkert.org Check* check = i->second; 1227039Snate@binkert.org assert(check != NULL); 1237039Snate@binkert.org return check; 1247039Snate@binkert.org} 1256145Snate@binkert.org 1266145Snate@binkert.orgvoid 1277039Snate@binkert.orgCheckTable::print(std::ostream& out) const 128{ 129} 130