ruby: get rid of gems_common/util.hh and .cc and use stuff in src/base

This commit is contained in:
Nathan Binkert 2010-04-02 11:20:32 -07:00
parent f1c3f3044b
commit 141f61d83a
29 changed files with 130 additions and 293 deletions

View file

@ -27,6 +27,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/intmath.hh"
#include "cpu/rubytest/Check.hh" #include "cpu/rubytest/Check.hh"
#include "cpu/rubytest/CheckTable.hh" #include "cpu/rubytest/CheckTable.hh"
#include "cpu/rubytest/CheckTable.hh" #include "cpu/rubytest/CheckTable.hh"
@ -81,7 +82,7 @@ CheckTable::~CheckTable()
void void
CheckTable::addCheck(const Address& address) CheckTable::addCheck(const Address& address)
{ {
if (log_int(CHECK_SIZE) != 0) { if (floorLog2(CHECK_SIZE) != 0) {
if (address.bitSelect(0, CHECK_SIZE_BITS - 1) != 0) { if (address.bitSelect(0, CHECK_SIZE_BITS - 1) != 0) {
ERROR_MSG("Check not aligned"); ERROR_MSG("Check not aligned");
} }

View file

@ -33,6 +33,4 @@ Import('*')
if not env['RUBY']: if not env['RUBY']:
Return() Return()
Source('util.cc')
TraceFlag('GemsCommon') TraceFlag('GemsCommon')

View file

@ -1,129 +0,0 @@
/*
* Copyright (c) 1999-2005 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.
*/
/*
* $Id$
*/
#include <cassert>
#include <iomanip>
#include <sstream>
#include "mem/gems_common/util.hh"
using namespace std;
// Split a string into a head and tail strings on the specified
// character. Return the head and the string passed in is modified by
// removing the head, leaving just the tail.
string string_split(string& str, char split_character)
{
string head = "";
string tail = "";
unsigned counter = 0;
while(counter < str.size()) {
if (str[counter] == split_character) {
counter++;
break;
} else {
head += str[counter];
}
counter++;
}
while(counter < str.size()) {
tail += str[counter];
counter++;
}
str = tail;
return head;
}
string bool_to_string(bool value)
{
if (value) {
return "true";
} else {
return "false";
}
}
string int_to_string(int n, bool zero_fill, int width)
{
ostringstream sstr;
if(zero_fill) {
sstr << setw(width) << setfill('0') << n;
} else {
sstr << n;
}
string str = sstr.str();
return str;
}
float string_to_float(string& str)
{
stringstream sstr(str);
float ret;
sstr >> ret;
return ret;
}
bool string_to_bool(const string & str)
{
string lower(str);
for (size_t i=0;i<str.length();i++)
lower[i] = tolower(str[i]);
if (lower == "true")
return true;
else if (lower == "false")
return false;
else
assert(0);
return false;
}
// Log functions
int log_int(long long n)
{
assert(n > 0);
int counter = 0;
while (n >= 2) {
counter++;
n = n>>(long long)(1);
}
return counter;
}
bool is_power_of_2(long long n)
{
return (n == ((long long)(1) << log_int(n)));
}

View file

@ -1,69 +0,0 @@
/*
* Copyright (c) 1999-2005 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.
*/
/*
* $Id$
*/
#ifndef UTIL_H
#define UTIL_H
#include <string>
std::string string_split(std::string& str, char split_character);
std::string bool_to_string(bool value);
std::string int_to_string(int n, bool zero_fill = false, int width = 0);
float string_to_float(std::string& str);
bool string_to_bool(const std::string & str);
int log_int(long long n);
bool is_power_of_2(long long n);
// Min and Max functions (since they are extern inline, they are as
// fast as macros)
extern inline
int max(int n1, int n2)
{
if (n1 > n2) {
return n1;
} else {
return n2;
}
}
extern inline
int min(int n1, int n2)
{
if (n1 < n2) {
return n1;
} else {
return n2;
}
}
#endif //UTIL_H

View file

@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/cprintf.hh"
#include "mem/ruby/buffers/MessageBuffer.hh" #include "mem/ruby/buffers/MessageBuffer.hh"
#include "mem/ruby/system/System.hh" #include "mem/ruby/system/System.hh"
@ -123,8 +124,8 @@ MessageBuffer::peekAtHeadOfQueue() const
DEBUG_NEWLINE(QUEUE_COMP, MedPrio); DEBUG_NEWLINE(QUEUE_COMP, MedPrio);
DEBUG_MSG(QUEUE_COMP, MedPrio, DEBUG_MSG(QUEUE_COMP, MedPrio,
"Peeking at head of queue " + m_name + " time: " csprintf("Peeking at head of queue %s time: %d.",
+ int_to_string(g_eventQueue_ptr->getTime()) + "."); m_name, g_eventQueue_ptr->getTime()));
assert(isReady()); assert(isReady());
msg_ptr = m_prio_heap.peekMin().m_msgptr.ref(); msg_ptr = m_prio_heap.peekMin().m_msgptr.ref();
@ -151,8 +152,9 @@ void
MessageBuffer::enqueue(const MsgPtr& message, Time delta) MessageBuffer::enqueue(const MsgPtr& message, Time delta)
{ {
DEBUG_NEWLINE(QUEUE_COMP, HighPrio); DEBUG_NEWLINE(QUEUE_COMP, HighPrio);
DEBUG_MSG(QUEUE_COMP, HighPrio, "enqueue " + m_name + " time: " DEBUG_MSG(QUEUE_COMP, HighPrio,
+ int_to_string(g_eventQueue_ptr->getTime()) + "."); csprintf("enqueue %s time: %d.", m_name,
g_eventQueue_ptr->getTime()));
DEBUG_EXPR(QUEUE_COMP, MedPrio, message); DEBUG_EXPR(QUEUE_COMP, MedPrio, message);
DEBUG_NEWLINE(QUEUE_COMP, HighPrio); DEBUG_NEWLINE(QUEUE_COMP, HighPrio);
@ -228,10 +230,9 @@ MessageBuffer::enqueue(const MsgPtr& message, Time delta)
m_prio_heap.insert(thisNode); m_prio_heap.insert(thisNode);
DEBUG_NEWLINE(QUEUE_COMP, HighPrio); DEBUG_NEWLINE(QUEUE_COMP, HighPrio);
DEBUG_MSG(QUEUE_COMP, HighPrio, "enqueue " + m_name DEBUG_MSG(QUEUE_COMP, HighPrio,
+ " with arrival_time " + int_to_string(arrival_time) csprintf("enqueue %s with arrival_time %d cur_time: %d.",
+ " cur_time: " + int_to_string(g_eventQueue_ptr->getTime()) m_name, arrival_time, g_eventQueue_ptr->getTime()));
+ ".");
DEBUG_EXPR(QUEUE_COMP, MedPrio, message); DEBUG_EXPR(QUEUE_COMP, MedPrio, message);
DEBUG_NEWLINE(QUEUE_COMP, HighPrio); DEBUG_NEWLINE(QUEUE_COMP, HighPrio);

View file

@ -38,7 +38,6 @@
#include <string> #include <string>
#include "mem/gems_common/PrioHeap.hh" #include "mem/gems_common/PrioHeap.hh"
#include "mem/gems_common/util.hh"
#include "mem/ruby/buffers/MessageBufferNode.hh" #include "mem/ruby/buffers/MessageBufferNode.hh"
#include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"

View file

@ -30,7 +30,6 @@
#include <stdarg.h> #include <stdarg.h>
#include "base/misc.hh" #include "base/misc.hh"
#include "mem/gems_common/util.hh"
#include "mem/ruby/common/Debug.hh" #include "mem/ruby/common/Debug.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
#include "mem/ruby/eventqueue/RubyEventQueue.hh" #include "mem/ruby/eventqueue/RubyEventQueue.hh"

View file

@ -26,6 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/intmath.hh"
#include "base/str.hh"
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Address.hh"
#include "mem/ruby/filters/BlockBloomFilter.hh" #include "mem/ruby/filters/BlockBloomFilter.hh"
@ -34,11 +36,17 @@ using namespace std;
BlockBloomFilter::BlockBloomFilter(string str) BlockBloomFilter::BlockBloomFilter(string str)
{ {
string tail(str); string head, tail;
string head = string_split(tail, '_');
#ifndef NDEBUG
bool success =
#endif
split_first(str, head, tail, '_');
assert(success);
m_filter_size = atoi(head.c_str()); m_filter_size = atoi(head.c_str());
m_filter_size_bits = log_int(m_filter_size); m_filter_size_bits = floorLog2(m_filter_size);
m_filter.setSize(m_filter_size); m_filter.setSize(m_filter_size);

View file

@ -26,6 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/intmath.hh"
#include "base/str.hh"
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Address.hh"
#include "mem/ruby/filters/BulkBloomFilter.hh" #include "mem/ruby/filters/BulkBloomFilter.hh"
@ -34,11 +36,16 @@ using namespace std;
BulkBloomFilter::BulkBloomFilter(string str) BulkBloomFilter::BulkBloomFilter(string str)
{ {
string tail(str); string head, tail;
string head = string_split(tail, '_');
#ifndef NDEBUG
bool success =
#endif
split_first(str, head, tail, '_');
assert(success);
m_filter_size = atoi(head.c_str()); m_filter_size = atoi(head.c_str());
m_filter_size_bits = log_int(m_filter_size); m_filter_size_bits = floorLog2(m_filter_size);
// split the filter bits in half, c0 and c1 // split the filter bits in half, c0 and c1
m_sector_bits = m_filter_size_bits - 1; m_sector_bits = m_filter_size_bits - 1;

View file

@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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/Address.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
#include "mem/ruby/filters/BlockBloomFilter.hh" #include "mem/ruby/filters/BlockBloomFilter.hh"
@ -41,8 +42,12 @@ using namespace std;
GenericBloomFilter::GenericBloomFilter(string config) GenericBloomFilter::GenericBloomFilter(string config)
{ {
string tail(config); string head, tail;
string head = string_split(tail,'_'); #ifndef NDEBUG
bool success =
#endif
split_first(config, head, tail, '_');
assert(success);
if (head == "LSB_Counting" ) { if (head == "LSB_Counting" ) {
m_filter = new LSB_CountingBloomFilter(tail); m_filter = new LSB_CountingBloomFilter(tail);

View file

@ -26,6 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/intmath.hh"
#include "base/str.hh"
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Address.hh"
#include "mem/ruby/filters/H3BloomFilter.hh" #include "mem/ruby/filters/H3BloomFilter.hh"
@ -378,29 +380,26 @@ H3BloomFilter::H3BloomFilter(string str)
adds_list[4] = 7777; adds_list[4] = 7777;
adds_list[5] = 65931; adds_list[5] = 65931;
string tail(str); vector<string> items;
string head = string_split(tail, '_'); tokenize(items, str, '_');
assert(items.size() == 3);
// head contains filter size, tail contains bit offset from block number // head contains filter size, tail contains bit offset from block number
m_filter_size = atoi(head.c_str()); m_filter_size = atoi(items[0].c_str());
m_num_hashes = atoi(items[1].c_str());
head = string_split(tail, '_'); if (items[2] == "Regular") {
m_num_hashes = atoi(head.c_str());
if(tail == "Regular") {
isParallel = false; isParallel = false;
} else if (tail == "Parallel") { } else if (items[2] == "Parallel") {
isParallel = true; isParallel = true;
} else { } else {
cout << "ERROR: Incorrect config string for MultiHash Bloom! :" panic("ERROR: Incorrect config string for MultiHash Bloom! :%s", str);
<< str << endl;
assert(0);
} }
m_filter_size_bits = log_int(m_filter_size); m_filter_size_bits = floorLog2(m_filter_size);
m_par_filter_size = m_filter_size/m_num_hashes; m_par_filter_size = m_filter_size / m_num_hashes;
m_par_filter_size_bits = log_int(m_par_filter_size); m_par_filter_size_bits = floorLog2(m_par_filter_size);
m_filter.setSize(m_filter_size); m_filter.setSize(m_filter_size);
clear(); clear();

View file

@ -26,6 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/intmath.hh"
#include "base/str.hh"
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Address.hh"
#include "mem/ruby/filters/LSB_CountingBloomFilter.hh" #include "mem/ruby/filters/LSB_CountingBloomFilter.hh"
@ -34,14 +36,18 @@ using namespace std;
LSB_CountingBloomFilter::LSB_CountingBloomFilter(string str) LSB_CountingBloomFilter::LSB_CountingBloomFilter(string str)
{ {
string tail(str); string head, tail;
string head = string_split(tail, ':'); #ifndef NDEBUG
bool success =
#endif
split_first(str, head, tail, '_');
assert(success);
m_filter_size = atoi(head.c_str()); m_filter_size = atoi(head.c_str());
m_filter_size_bits = log_int(m_filter_size); m_filter_size_bits = floorLog2(m_filter_size);
m_count = atoi(tail.c_str()); m_count = atoi(tail.c_str());
m_count_bits = log_int(m_count); m_count_bits = floorLog2(m_count);
m_filter.setSize(m_filter_size); m_filter.setSize(m_filter_size);
clear(); clear();

View file

@ -26,6 +26,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <vector>
#include "base/intmath.hh"
#include "base/str.hh"
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Address.hh"
#include "mem/ruby/filters/MultiBitSelBloomFilter.hh" #include "mem/ruby/filters/MultiBitSelBloomFilter.hh"
@ -34,32 +38,28 @@ using namespace std;
MultiBitSelBloomFilter::MultiBitSelBloomFilter(string str) MultiBitSelBloomFilter::MultiBitSelBloomFilter(string str)
{ {
string tail(str); vector<string> items;
string head = string_split(tail, '_'); tokenize(items, str, '_');
assert(items.size() == 4);
// head contains filter size, tail contains bit offset from block number // head contains filter size, tail contains bit offset from block number
m_filter_size = atoi(head.c_str()); m_filter_size = atoi(items[0].c_str());
m_num_hashes = atoi(items[1].c_str());
m_skip_bits = atoi(items[2].c_str());
head = string_split(tail, '_'); if (items[3] == "Regular") {
m_num_hashes = atoi(head.c_str());
head = string_split(tail, '_');
m_skip_bits = atoi(head.c_str());
if(tail == "Regular") {
isParallel = false; isParallel = false;
} else if (tail == "Parallel") { } else if (items[3] == "Parallel") {
isParallel = true; isParallel = true;
} else { } else {
cout << "ERROR: Incorrect config string for MultiBitSel Bloom! :" panic("ERROR: Incorrect config string for MultiBitSel Bloom! :%s",
<< str << endl; str);
assert(0);
} }
m_filter_size_bits = log_int(m_filter_size); m_filter_size_bits = floorLog2(m_filter_size);
m_par_filter_size = m_filter_size/m_num_hashes; m_par_filter_size = m_filter_size / m_num_hashes;
m_par_filter_size_bits = log_int(m_par_filter_size); m_par_filter_size_bits = floorLog2(m_par_filter_size);
m_filter.setSize(m_filter_size); m_filter.setSize(m_filter_size);
clear(); clear();

View file

@ -26,6 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/intmath.hh"
#include "base/str.hh"
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Address.hh"
#include "mem/ruby/filters/MultiGrainBloomFilter.hh" #include "mem/ruby/filters/MultiGrainBloomFilter.hh"
@ -34,19 +36,21 @@ using namespace std;
MultiGrainBloomFilter::MultiGrainBloomFilter(string str) MultiGrainBloomFilter::MultiGrainBloomFilter(string str)
{ {
string tail(str); string head, tail;
#ifndef NDEBUG
// split into the 2 filter sizes bool success =
string head = string_split(tail, '_'); #endif
split_first(str, head, tail, '_');
assert(success);
// head contains size of 1st bloom filter, tail contains size of // head contains size of 1st bloom filter, tail contains size of
// 2nd bloom filter // 2nd bloom filter
m_filter_size = atoi(head.c_str()); m_filter_size = atoi(head.c_str());
m_filter_size_bits = log_int(m_filter_size); m_filter_size_bits = floorLog2(m_filter_size);
m_page_filter_size = atoi(tail.c_str()); m_page_filter_size = atoi(tail.c_str());
m_page_filter_size_bits = log_int(m_page_filter_size); m_page_filter_size_bits = floorLog2(m_page_filter_size);
m_filter.setSize(m_filter_size); m_filter.setSize(m_filter_size);
m_page_filter.setSize(m_page_filter_size); m_page_filter.setSize(m_page_filter_size);

View file

@ -26,6 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/intmath.hh"
#include "base/str.hh"
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Address.hh"
#include "mem/ruby/filters/NonCountingBloomFilter.hh" #include "mem/ruby/filters/NonCountingBloomFilter.hh"
@ -34,13 +36,17 @@ using namespace std;
NonCountingBloomFilter::NonCountingBloomFilter(string str) NonCountingBloomFilter::NonCountingBloomFilter(string str)
{ {
string tail(str); string head, tail;
string head = string_split(tail, '_'); #ifndef NDEBUG
bool success =
#endif
split_first(str, head, tail, '_');
assert(success);
// head contains filter size, tail contains bit offset from block number // head contains filter size, tail contains bit offset from block number
m_filter_size = atoi(head.c_str()); m_filter_size = atoi(head.c_str());
m_offset = atoi(tail.c_str()); m_offset = atoi(tail.c_str());
m_filter_size_bits = log_int(m_filter_size); m_filter_size_bits = floorLog2(m_filter_size);
m_filter.setSize(m_filter_size); m_filter.setSize(m_filter_size);
clear(); clear();

View file

@ -37,7 +37,6 @@
#define BASEGARNETNETWORK_H #define BASEGARNETNETWORK_H
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/gems_common/util.hh"
#include "mem/ruby/network/Network.hh" #include "mem/ruby/network/Network.hh"
#include "params/BaseGarnetNetwork.hh" #include "params/BaseGarnetNetwork.hh"

View file

@ -26,7 +26,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "mem/gems_common/util.hh"
#include "mem/protocol/Protocol.hh" #include "mem/protocol/Protocol.hh"
#include "mem/ruby/buffers/MessageBuffer.hh" #include "mem/ruby/buffers/MessageBuffer.hh"
#include "mem/ruby/network/simple/PerfectSwitch.hh" #include "mem/ruby/network/simple/PerfectSwitch.hh"

View file

@ -75,10 +75,10 @@ SimpleNetwork::SimpleNetwork(const Params *p)
m_toNetQueues[node].setSize(m_virtual_networks); m_toNetQueues[node].setSize(m_virtual_networks);
m_fromNetQueues[node].setSize(m_virtual_networks); m_fromNetQueues[node].setSize(m_virtual_networks);
for (int j = 0; j < m_virtual_networks; j++) { for (int j = 0; j < m_virtual_networks; j++) {
m_toNetQueues[node][j] = new MessageBuffer( m_toNetQueues[node][j] =
"toNet node "+int_to_string(node)+" j "+int_to_string(j)); new MessageBuffer(csprintf("toNet node %d j %d", node, j));
m_fromNetQueues[node][j] = new MessageBuffer( m_fromNetQueues[node][j] =
"fromNet node "+int_to_string(node)+" j "+int_to_string(j)); new MessageBuffer(csprintf("fromNet node %d j %d", node, j));
} }
} }
} }

View file

@ -26,7 +26,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "mem/gems_common/util.hh"
#include "mem/protocol/MachineType.hh" #include "mem/protocol/MachineType.hh"
#include "mem/protocol/Protocol.hh" #include "mem/protocol/Protocol.hh"
#include "mem/protocol/TopologyType.hh" #include "mem/protocol/TopologyType.hh"

View file

@ -46,9 +46,9 @@
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/times.h> #include <sys/times.h>
#include "base/str.hh"
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/gems_common/PrioHeap.hh" #include "mem/gems_common/PrioHeap.hh"
#include "mem/gems_common/util.hh"
#include "mem/protocol/CacheMsg.hh" #include "mem/protocol/CacheMsg.hh"
#include "mem/protocol/MachineType.hh" #include "mem/protocol/MachineType.hh"
#include "mem/protocol/Protocol.hh" #include "mem/protocol/Protocol.hh"
@ -360,9 +360,12 @@ Profiler::printStats(ostream& out, bool short_stats)
int temp_int = int temp_int =
m_requestProfileMap_ptr->lookup(requestProfileKeys[i]); m_requestProfileMap_ptr->lookup(requestProfileKeys[i]);
double percent = (100.0 * double(temp_int)) / double(m_requests); double percent = (100.0 * double(temp_int)) / double(m_requests);
while (requestProfileKeys[i] != "") { vector<string> items;
out << setw(10) << string_split(requestProfileKeys[i], ':'); tokenize(items, requestProfileKeys[i], ':');
} vector<string>::iterator i = items.begin();
vector<string>::iterator end = items.end();
for (; i != end; ++i)
out << setw(10) << *i;
out << setw(11) << temp_int; out << setw(11) << temp_int;
out << setw(14) << percent << endl; out << setw(14) << percent << endl;
} }

View file

@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/intmath.hh"
#include "mem/ruby/system/CacheMemory.hh" #include "mem/ruby/system/CacheMemory.hh"
using namespace std; using namespace std;
@ -60,7 +61,7 @@ CacheMemory::init()
m_cache_num_sets = (m_cache_size / m_cache_assoc) / m_cache_num_sets = (m_cache_size / m_cache_assoc) /
RubySystem::getBlockSizeBytes(); RubySystem::getBlockSizeBytes();
assert(m_cache_num_sets > 1); assert(m_cache_num_sets > 1);
m_cache_num_set_bits = log_int(m_cache_num_sets); m_cache_num_set_bits = floorLog2(m_cache_num_sets);
assert(m_cache_num_set_bits > 0); assert(m_cache_num_set_bits > 0);
if (m_policy == "PSEUDO_LRU") if (m_policy == "PSEUDO_LRU")

View file

@ -26,7 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "mem/gems_common/util.hh" #include "base/intmath.hh"
#include "mem/ruby/slicc_interface/RubySlicc_Util.hh" #include "mem/ruby/slicc_interface/RubySlicc_Util.hh"
#include "mem/ruby/system/DirectoryMemory.hh" #include "mem/ruby/system/DirectoryMemory.hh"
#include "mem/ruby/system/System.hh" #include "mem/ruby/system/System.hh"
@ -43,7 +43,7 @@ DirectoryMemory::DirectoryMemory(const Params *p)
{ {
m_version = p->version; m_version = p->version;
m_size_bytes = p->size; m_size_bytes = p->size;
m_size_bits = log_int(m_size_bytes); m_size_bits = floorLog2(m_size_bytes);
m_num_entries = 0; m_num_entries = 0;
m_use_map = p->use_map; m_use_map = p->use_map;
m_map_levels = p->map_levels; m_map_levels = p->map_levels;
@ -56,7 +56,7 @@ DirectoryMemory::init()
m_num_entries = m_size_bytes / RubySystem::getBlockSizeBytes(); m_num_entries = m_size_bytes / RubySystem::getBlockSizeBytes();
if (m_use_map) { if (m_use_map) {
int entry_bits = log_int(m_num_entries); int entry_bits = floorLog2(m_num_entries);
assert(entry_bits >= m_map_levels); assert(entry_bits >= m_map_levels);
m_sparseMemory = new SparseMemory(entry_bits, m_map_levels); m_sparseMemory = new SparseMemory(entry_bits, m_map_levels);
} else { } else {
@ -67,7 +67,7 @@ DirectoryMemory::init()
} }
m_num_directories++; m_num_directories++;
m_num_directories_bits = log_int(m_num_directories); m_num_directories_bits = floorLog2(m_num_directories);
m_total_size_bytes += m_size_bytes; m_total_size_bytes += m_size_bytes;
if (m_numa_high_bit == 0) { if (m_numa_high_bit == 0) {
@ -116,7 +116,7 @@ DirectoryMemory::printGlobalConfig(ostream & out)
<< endl; << endl;
} }
out << " total memory size bytes: " << m_total_size_bytes << endl; out << " total memory size bytes: " << m_total_size_bytes << endl;
out << " total memory bits: " << log_int(m_total_size_bytes) << endl; out << " total memory bits: " << floorLog2(m_total_size_bytes) << endl;
} }
uint64 uint64

View file

@ -32,7 +32,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "mem/gems_common/util.hh" #include "base/cprintf.hh"
#include "mem/protocol/MachineType.hh" #include "mem/protocol/MachineType.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
@ -45,7 +45,7 @@ struct MachineID
inline std::string inline std::string
MachineIDToString(MachineID machine) MachineIDToString(MachineID machine)
{ {
return MachineType_to_string(machine.type)+"_"+int_to_string(machine.num); return csprintf("%s_%d", MachineType_to_string(machine.type), machine.num);
} }
inline bool inline bool

View file

@ -34,7 +34,6 @@
#include <string> #include <string>
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/gems_common/util.hh"
#include "mem/protocol/MemoryMsg.hh" #include "mem/protocol/MemoryMsg.hh"
#include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Address.hh"
#include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Consumer.hh"

View file

@ -31,7 +31,7 @@
#include <string> #include <string>
#include "mem/gems_common/util.hh" #include "base/str.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
typedef int NodeID; typedef int NodeID;
@ -39,7 +39,7 @@ typedef int NodeID;
inline std::string inline std::string
NodeIDToString(NodeID node) NodeIDToString(NodeID node)
{ {
return int_to_string(node); return to_string(node);
} }
#endif // __MEM_RUBY_SYSTEM_NODEID_HH__ #endif // __MEM_RUBY_SYSTEM_NODEID_HH__

View file

@ -26,7 +26,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "mem/gems_common/util.hh"
#include "mem/ruby/system/PersistentTable.hh" #include "mem/ruby/system/PersistentTable.hh"
using namespace std; using namespace std;

View file

@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/str.hh"
#include "cpu/rubytest/RubyTester.hh" #include "cpu/rubytest/RubyTester.hh"
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/protocol/CacheMsg.hh" #include "mem/protocol/CacheMsg.hh"

View file

@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "base/intmath.hh"
#include "base/output.hh" #include "base/output.hh"
#include "mem/ruby/buffers/MessageBuffer.hh" #include "mem/ruby/buffers/MessageBuffer.hh"
#include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Address.hh"
@ -63,14 +64,14 @@ RubySystem::RubySystem(const Params *p)
m_clock = p->clock; m_clock = p->clock;
m_block_size_bytes = p->block_size_bytes; m_block_size_bytes = p->block_size_bytes;
assert(is_power_of_2(m_block_size_bytes)); assert(isPowerOf2(m_block_size_bytes));
m_block_size_bits = log_int(m_block_size_bytes); m_block_size_bits = floorLog2(m_block_size_bytes);
m_memory_size_bytes = p->mem_size; m_memory_size_bytes = p->mem_size;
if (m_memory_size_bytes == 0) { if (m_memory_size_bytes == 0) {
m_memory_size_bits = 0; m_memory_size_bits = 0;
} else { } else {
m_memory_size_bits = log_int(m_memory_size_bytes); m_memory_size_bits = floorLog2(m_memory_size_bytes);
} }
m_network_ptr = p->network; m_network_ptr = p->network;

View file

@ -330,12 +330,13 @@ static int m_num_controllers;
#include <sstream> #include <sstream>
#include <string> #include <string>
#include "mem/ruby/common/Global.hh" #include "base/cprintf.hh"
#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
#include "mem/protocol/${ident}_Controller.hh" #include "mem/protocol/${ident}_Controller.hh"
#include "mem/protocol/${ident}_State.hh" #include "mem/protocol/${ident}_State.hh"
#include "mem/protocol/${ident}_Event.hh" #include "mem/protocol/${ident}_Event.hh"
#include "mem/protocol/Types.hh" #include "mem/protocol/Types.hh"
#include "mem/ruby/common/Global.hh"
#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
#include "mem/ruby/system/System.hh" #include "mem/ruby/system/System.hh"
using namespace std; using namespace std;
@ -526,7 +527,7 @@ if (m_buffer_size > 0) {
# set description (may be overriden later by port def) # set description (may be overriden later by port def)
code(''' code('''
$vid->setDescription("[Version " + int_to_string(m_version) + ", ${ident}, name=${{var.c_ident}}]"); $vid->setDescription("[Version " + to_string(m_version) + ", ${ident}, name=${{var.c_ident}}]");
''') ''')
@ -538,7 +539,7 @@ $vid->setDescription("[Version " + int_to_string(m_version) + ", ${ident}, name=
# Set the queue descriptions # Set the queue descriptions
code.insert_newline() code.insert_newline()
for port in self.in_ports: for port in self.in_ports:
code('${{port.code}}.setDescription("[Version " + int_to_string(m_version) + ", $ident, $port]");') code('${{port.code}}.setDescription("[Version " + to_string(m_version) + ", $ident, $port]");')
# Initialize the transition profiling # Initialize the transition profiling
code.insert_newline() code.insert_newline()