CheckTable.cc (10348:c91b23c72d5e) | CheckTable.cc (11025:4872dbdea907) |
---|---|
1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * Copyright (c) 2009 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32#include "cpu/testers/rubytest/Check.hh" 33#include "cpu/testers/rubytest/CheckTable.hh" 34#include "debug/RubyTest.hh" 35 36CheckTable::CheckTable(int _num_writers, int _num_readers, RubyTester* _tester) 37 : m_num_writers(_num_writers), m_num_readers(_num_readers), 38 m_tester_ptr(_tester) 39{ | 1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * Copyright (c) 2009 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32#include "cpu/testers/rubytest/Check.hh" 33#include "cpu/testers/rubytest/CheckTable.hh" 34#include "debug/RubyTest.hh" 35 36CheckTable::CheckTable(int _num_writers, int _num_readers, RubyTester* _tester) 37 : m_num_writers(_num_writers), m_num_readers(_num_readers), 38 m_tester_ptr(_tester) 39{ |
40 physical_address_t physical = 0; 41 Address address; | 40 Addr physical = 0; |
42 43 const int size1 = 32; 44 const int size2 = 100; 45 46 // The first set is to get some false sharing 47 physical = 1000; 48 for (int i = 0; i < size1; i++) { 49 // Setup linear addresses | 41 42 const int size1 = 32; 43 const int size2 = 100; 44 45 // The first set is to get some false sharing 46 physical = 1000; 47 for (int i = 0; i < size1; i++) { 48 // Setup linear addresses |
50 address.setAddress(physical); 51 addCheck(address); | 49 addCheck(physical); |
52 physical += CHECK_SIZE; 53 } 54 55 // The next two sets are to get some limited false sharing and 56 // cache conflicts 57 physical = 1000; 58 for (int i = 0; i < size2; i++) { 59 // Setup linear addresses | 50 physical += CHECK_SIZE; 51 } 52 53 // The next two sets are to get some limited false sharing and 54 // cache conflicts 55 physical = 1000; 56 for (int i = 0; i < size2; i++) { 57 // Setup linear addresses |
60 address.setAddress(physical); 61 addCheck(address); | 58 addCheck(physical); |
62 physical += 256; 63 } 64 65 physical = 1000 + CHECK_SIZE; 66 for (int i = 0; i < size2; i++) { 67 // Setup linear addresses | 59 physical += 256; 60 } 61 62 physical = 1000 + CHECK_SIZE; 63 for (int i = 0; i < size2; i++) { 64 // Setup linear addresses |
68 address.setAddress(physical); 69 addCheck(address); | 65 addCheck(physical); |
70 physical += 256; 71 } 72} 73 74CheckTable::~CheckTable() 75{ 76 int size = m_check_vector.size(); 77 for (int i = 0; i < size; i++) 78 delete m_check_vector[i]; 79} 80 81void | 66 physical += 256; 67 } 68} 69 70CheckTable::~CheckTable() 71{ 72 int size = m_check_vector.size(); 73 for (int i = 0; i < size; i++) 74 delete m_check_vector[i]; 75} 76 77void |
82CheckTable::addCheck(const Address& address) | 78CheckTable::addCheck(Addr address) |
83{ 84 if (floorLog2(CHECK_SIZE) != 0) { | 79{ 80 if (floorLog2(CHECK_SIZE) != 0) { |
85 if (address.bitSelect(0, CHECK_SIZE_BITS - 1) != 0) { | 81 if (bitSelect(address, 0, CHECK_SIZE_BITS - 1) != 0) { |
86 panic("Check not aligned"); 87 } 88 } 89 90 for (int i = 0; i < CHECK_SIZE; i++) { | 82 panic("Check not aligned"); 83 } 84 } 85 86 for (int i = 0; i < CHECK_SIZE; i++) { |
91 if (m_lookup_map.count(Address(address.getAddress()+i))) { | 87 if (m_lookup_map.count(address+i)) { |
92 // A mapping for this byte already existed, discard the 93 // entire check 94 return; 95 } 96 } 97 | 88 // A mapping for this byte already existed, discard the 89 // entire check 90 return; 91 } 92 } 93 |
98 Check* check_ptr = new Check(address, Address(100 + m_check_vector.size()), | 94 Check* check_ptr = new Check(address, 100 + m_check_vector.size(), |
99 m_num_writers, m_num_readers, m_tester_ptr); 100 for (int i = 0; i < CHECK_SIZE; i++) { 101 // Insert it once per byte | 95 m_num_writers, m_num_readers, m_tester_ptr); 96 for (int i = 0; i < CHECK_SIZE; i++) { 97 // Insert it once per byte |
102 m_lookup_map[Address(address.getAddress() + i)] = check_ptr; | 98 m_lookup_map[address + i] = check_ptr; |
103 } 104 m_check_vector.push_back(check_ptr); 105} 106 107Check* 108CheckTable::getRandomCheck() 109{ 110 assert(m_check_vector.size() > 0); 111 return m_check_vector[random_mt.random<unsigned>(0, m_check_vector.size() - 1)]; 112} 113 114Check* | 99 } 100 m_check_vector.push_back(check_ptr); 101} 102 103Check* 104CheckTable::getRandomCheck() 105{ 106 assert(m_check_vector.size() > 0); 107 return m_check_vector[random_mt.random<unsigned>(0, m_check_vector.size() - 1)]; 108} 109 110Check* |
115CheckTable::getCheck(const Address& address) | 111CheckTable::getCheck(const Addr address) |
116{ 117 DPRINTF(RubyTest, "Looking for check by address: %s", address); 118 | 112{ 113 DPRINTF(RubyTest, "Looking for check by address: %s", address); 114 |
119 m5::hash_map<Address, Check*>::iterator i = m_lookup_map.find(address); | 115 m5::hash_map |
120 121 if (i == m_lookup_map.end()) 122 return NULL; 123 124 Check* check = i->second; 125 assert(check != NULL); 126 return check; 127} 128 129void 130CheckTable::print(std::ostream& out) const 131{ 132} | 116 117 if (i == m_lookup_map.end()) 118 return NULL; 119 120 Check* check = i->second; 121 assert(check != NULL); 122 return check; 123} 124 125void 126CheckTable::print(std::ostream& out) const 127{ 128} |