summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-04-02 11:20:32 -0700
committerNathan Binkert <nate@binkert.org>2010-04-02 11:20:32 -0700
commit141f61d83a23096dcff20df704bdd734c520f535 (patch)
treeee2383d721a039bb056bd6442a7241aa305d187e /src
parentf1c3f3044b73d890ffdfdd113b3b37ae2809d21b (diff)
downloadgem5-141f61d83a23096dcff20df704bdd734c520f535.tar.xz
ruby: get rid of gems_common/util.hh and .cc and use stuff in src/base
Diffstat (limited to 'src')
-rw-r--r--src/cpu/rubytest/CheckTable.cc3
-rw-r--r--src/mem/gems_common/SConscript2
-rw-r--r--src/mem/gems_common/util.cc129
-rw-r--r--src/mem/gems_common/util.hh69
-rw-r--r--src/mem/ruby/buffers/MessageBuffer.cc17
-rw-r--r--src/mem/ruby/buffers/MessageBuffer.hh1
-rw-r--r--src/mem/ruby/common/Debug.cc1
-rw-r--r--src/mem/ruby/filters/BlockBloomFilter.cc14
-rw-r--r--src/mem/ruby/filters/BulkBloomFilter.cc13
-rw-r--r--src/mem/ruby/filters/GenericBloomFilter.cc9
-rw-r--r--src/mem/ruby/filters/H3BloomFilter.cc27
-rw-r--r--src/mem/ruby/filters/LSB_CountingBloomFilter.cc14
-rw-r--r--src/mem/ruby/filters/MultiBitSelBloomFilter.cc34
-rw-r--r--src/mem/ruby/filters/MultiGrainBloomFilter.cc16
-rw-r--r--src/mem/ruby/filters/NonCountingBloomFilter.cc12
-rw-r--r--src/mem/ruby/network/garnet/BaseGarnetNetwork.hh1
-rw-r--r--src/mem/ruby/network/simple/PerfectSwitch.cc1
-rw-r--r--src/mem/ruby/network/simple/SimpleNetwork.cc8
-rw-r--r--src/mem/ruby/network/simple/Topology.cc1
-rw-r--r--src/mem/ruby/profiler/Profiler.cc11
-rw-r--r--src/mem/ruby/system/CacheMemory.cc3
-rw-r--r--src/mem/ruby/system/DirectoryMemory.cc10
-rw-r--r--src/mem/ruby/system/MachineID.hh4
-rw-r--r--src/mem/ruby/system/MemoryControl.hh1
-rw-r--r--src/mem/ruby/system/NodeID.hh4
-rw-r--r--src/mem/ruby/system/PersistentTable.cc1
-rw-r--r--src/mem/ruby/system/Sequencer.cc1
-rw-r--r--src/mem/ruby/system/System.cc7
-rw-r--r--src/mem/slicc/symbols/StateMachine.py9
29 files changed, 130 insertions, 293 deletions
diff --git a/src/cpu/rubytest/CheckTable.cc b/src/cpu/rubytest/CheckTable.cc
index 1674ca234..3b94de315 100644
--- a/src/cpu/rubytest/CheckTable.cc
+++ b/src/cpu/rubytest/CheckTable.cc
@@ -27,6 +27,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "base/intmath.hh"
#include "cpu/rubytest/Check.hh"
#include "cpu/rubytest/CheckTable.hh"
#include "cpu/rubytest/CheckTable.hh"
@@ -81,7 +82,7 @@ CheckTable::~CheckTable()
void
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) {
ERROR_MSG("Check not aligned");
}
diff --git a/src/mem/gems_common/SConscript b/src/mem/gems_common/SConscript
index 851aa412f..86d8bb345 100644
--- a/src/mem/gems_common/SConscript
+++ b/src/mem/gems_common/SConscript
@@ -33,6 +33,4 @@ Import('*')
if not env['RUBY']:
Return()
-Source('util.cc')
-
TraceFlag('GemsCommon')
diff --git a/src/mem/gems_common/util.cc b/src/mem/gems_common/util.cc
deleted file mode 100644
index d7ce2e893..000000000
--- a/src/mem/gems_common/util.cc
+++ /dev/null
@@ -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)));
-}
-
diff --git a/src/mem/gems_common/util.hh b/src/mem/gems_common/util.hh
deleted file mode 100644
index f5a86f325..000000000
--- a/src/mem/gems_common/util.hh
+++ /dev/null
@@ -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
diff --git a/src/mem/ruby/buffers/MessageBuffer.cc b/src/mem/ruby/buffers/MessageBuffer.cc
index 086f92ab7..e64e47cad 100644
--- a/src/mem/ruby/buffers/MessageBuffer.cc
+++ b/src/mem/ruby/buffers/MessageBuffer.cc
@@ -26,6 +26,7 @@
* 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/system/System.hh"
@@ -123,8 +124,8 @@ MessageBuffer::peekAtHeadOfQueue() const
DEBUG_NEWLINE(QUEUE_COMP, MedPrio);
DEBUG_MSG(QUEUE_COMP, MedPrio,
- "Peeking at head of queue " + m_name + " time: "
- + int_to_string(g_eventQueue_ptr->getTime()) + ".");
+ csprintf("Peeking at head of queue %s time: %d.",
+ m_name, g_eventQueue_ptr->getTime()));
assert(isReady());
msg_ptr = m_prio_heap.peekMin().m_msgptr.ref();
@@ -151,8 +152,9 @@ void
MessageBuffer::enqueue(const MsgPtr& message, Time delta)
{
DEBUG_NEWLINE(QUEUE_COMP, HighPrio);
- DEBUG_MSG(QUEUE_COMP, HighPrio, "enqueue " + m_name + " time: "
- + int_to_string(g_eventQueue_ptr->getTime()) + ".");
+ DEBUG_MSG(QUEUE_COMP, HighPrio,
+ csprintf("enqueue %s time: %d.", m_name,
+ g_eventQueue_ptr->getTime()));
DEBUG_EXPR(QUEUE_COMP, MedPrio, message);
DEBUG_NEWLINE(QUEUE_COMP, HighPrio);
@@ -228,10 +230,9 @@ MessageBuffer::enqueue(const MsgPtr& message, Time delta)
m_prio_heap.insert(thisNode);
DEBUG_NEWLINE(QUEUE_COMP, HighPrio);
- DEBUG_MSG(QUEUE_COMP, HighPrio, "enqueue " + m_name
- + " with arrival_time " + int_to_string(arrival_time)
- + " cur_time: " + int_to_string(g_eventQueue_ptr->getTime())
- + ".");
+ DEBUG_MSG(QUEUE_COMP, HighPrio,
+ csprintf("enqueue %s with arrival_time %d cur_time: %d.",
+ m_name, arrival_time, g_eventQueue_ptr->getTime()));
DEBUG_EXPR(QUEUE_COMP, MedPrio, message);
DEBUG_NEWLINE(QUEUE_COMP, HighPrio);
diff --git a/src/mem/ruby/buffers/MessageBuffer.hh b/src/mem/ruby/buffers/MessageBuffer.hh
index 8fc86af97..6b567d70d 100644
--- a/src/mem/ruby/buffers/MessageBuffer.hh
+++ b/src/mem/ruby/buffers/MessageBuffer.hh
@@ -38,7 +38,6 @@
#include <string>
#include "mem/gems_common/PrioHeap.hh"
-#include "mem/gems_common/util.hh"
#include "mem/ruby/buffers/MessageBufferNode.hh"
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/common/Global.hh"
diff --git a/src/mem/ruby/common/Debug.cc b/src/mem/ruby/common/Debug.cc
index 2c1acc4ff..1bf7ae43b 100644
--- a/src/mem/ruby/common/Debug.cc
+++ b/src/mem/ruby/common/Debug.cc
@@ -30,7 +30,6 @@
#include <stdarg.h>
#include "base/misc.hh"
-#include "mem/gems_common/util.hh"
#include "mem/ruby/common/Debug.hh"
#include "mem/ruby/common/Global.hh"
#include "mem/ruby/eventqueue/RubyEventQueue.hh"
diff --git a/src/mem/ruby/filters/BlockBloomFilter.cc b/src/mem/ruby/filters/BlockBloomFilter.cc
index 21d7921c6..875a0d015 100644
--- a/src/mem/ruby/filters/BlockBloomFilter.cc
+++ b/src/mem/ruby/filters/BlockBloomFilter.cc
@@ -26,6 +26,8 @@
* 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/ruby/common/Address.hh"
#include "mem/ruby/filters/BlockBloomFilter.hh"
@@ -34,11 +36,17 @@ using namespace std;
BlockBloomFilter::BlockBloomFilter(string str)
{
- string tail(str);
- string head = string_split(tail, '_');
+ string head, tail;
+
+#ifndef NDEBUG
+ bool success =
+#endif
+ split_first(str, head, tail, '_');
+
+ assert(success);
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);
diff --git a/src/mem/ruby/filters/BulkBloomFilter.cc b/src/mem/ruby/filters/BulkBloomFilter.cc
index 47cc386cd..a03cba37b 100644
--- a/src/mem/ruby/filters/BulkBloomFilter.cc
+++ b/src/mem/ruby/filters/BulkBloomFilter.cc
@@ -26,6 +26,8 @@
* 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/ruby/common/Address.hh"
#include "mem/ruby/filters/BulkBloomFilter.hh"
@@ -34,11 +36,16 @@ using namespace std;
BulkBloomFilter::BulkBloomFilter(string str)
{
- string tail(str);
- string head = string_split(tail, '_');
+ string head, tail;
+
+#ifndef NDEBUG
+ bool success =
+#endif
+ split_first(str, head, tail, '_');
+ assert(success);
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
m_sector_bits = m_filter_size_bits - 1;
diff --git a/src/mem/ruby/filters/GenericBloomFilter.cc b/src/mem/ruby/filters/GenericBloomFilter.cc
index 8d6b18e9e..e04547fec 100644
--- a/src/mem/ruby/filters/GenericBloomFilter.cc
+++ b/src/mem/ruby/filters/GenericBloomFilter.cc
@@ -26,6 +26,7 @@
* 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/Global.hh"
#include "mem/ruby/filters/BlockBloomFilter.hh"
@@ -41,8 +42,12 @@ using namespace std;
GenericBloomFilter::GenericBloomFilter(string config)
{
- string tail(config);
- string head = string_split(tail,'_');
+ string head, tail;
+#ifndef NDEBUG
+ bool success =
+#endif
+ split_first(config, head, tail, '_');
+ assert(success);
if (head == "LSB_Counting" ) {
m_filter = new LSB_CountingBloomFilter(tail);
diff --git a/src/mem/ruby/filters/H3BloomFilter.cc b/src/mem/ruby/filters/H3BloomFilter.cc
index 8018c7e38..d0a4f400d 100644
--- a/src/mem/ruby/filters/H3BloomFilter.cc
+++ b/src/mem/ruby/filters/H3BloomFilter.cc
@@ -26,6 +26,8 @@
* 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/ruby/common/Address.hh"
#include "mem/ruby/filters/H3BloomFilter.hh"
@@ -378,29 +380,26 @@ H3BloomFilter::H3BloomFilter(string str)
adds_list[4] = 7777;
adds_list[5] = 65931;
- string tail(str);
- string head = string_split(tail, '_');
+ vector<string> items;
+ tokenize(items, str, '_');
+ assert(items.size() == 3);
// 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, '_');
- m_num_hashes = atoi(head.c_str());
-
- if(tail == "Regular") {
+ if (items[2] == "Regular") {
isParallel = false;
- } else if (tail == "Parallel") {
+ } else if (items[2] == "Parallel") {
isParallel = true;
} else {
- cout << "ERROR: Incorrect config string for MultiHash Bloom! :"
- << str << endl;
- assert(0);
+ panic("ERROR: Incorrect config string for MultiHash Bloom! :%s", str);
}
- 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_bits = log_int(m_par_filter_size);
+ m_par_filter_size = m_filter_size / m_num_hashes;
+ m_par_filter_size_bits = floorLog2(m_par_filter_size);
m_filter.setSize(m_filter_size);
clear();
diff --git a/src/mem/ruby/filters/LSB_CountingBloomFilter.cc b/src/mem/ruby/filters/LSB_CountingBloomFilter.cc
index 7ec927d6c..029ce1501 100644
--- a/src/mem/ruby/filters/LSB_CountingBloomFilter.cc
+++ b/src/mem/ruby/filters/LSB_CountingBloomFilter.cc
@@ -26,6 +26,8 @@
* 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/ruby/common/Address.hh"
#include "mem/ruby/filters/LSB_CountingBloomFilter.hh"
@@ -34,14 +36,18 @@ using namespace std;
LSB_CountingBloomFilter::LSB_CountingBloomFilter(string str)
{
- string tail(str);
- string head = string_split(tail, ':');
+ string head, tail;
+#ifndef NDEBUG
+ bool success =
+#endif
+ split_first(str, head, tail, '_');
+ assert(success);
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_bits = log_int(m_count);
+ m_count_bits = floorLog2(m_count);
m_filter.setSize(m_filter_size);
clear();
diff --git a/src/mem/ruby/filters/MultiBitSelBloomFilter.cc b/src/mem/ruby/filters/MultiBitSelBloomFilter.cc
index 90f299fb4..466e3fccb 100644
--- a/src/mem/ruby/filters/MultiBitSelBloomFilter.cc
+++ b/src/mem/ruby/filters/MultiBitSelBloomFilter.cc
@@ -26,6 +26,10 @@
* 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/ruby/common/Address.hh"
#include "mem/ruby/filters/MultiBitSelBloomFilter.hh"
@@ -34,32 +38,28 @@ using namespace std;
MultiBitSelBloomFilter::MultiBitSelBloomFilter(string str)
{
- string tail(str);
- string head = string_split(tail, '_');
+ vector<string> items;
+ tokenize(items, str, '_');
+ assert(items.size() == 4);
// head contains filter size, tail contains bit offset from block number
- m_filter_size = atoi(head.c_str());
-
- head = string_split(tail, '_');
- m_num_hashes = atoi(head.c_str());
-
- head = string_split(tail, '_');
- m_skip_bits = 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());
- if(tail == "Regular") {
+ if (items[3] == "Regular") {
isParallel = false;
- } else if (tail == "Parallel") {
+ } else if (items[3] == "Parallel") {
isParallel = true;
} else {
- cout << "ERROR: Incorrect config string for MultiBitSel Bloom! :"
- << str << endl;
- assert(0);
+ panic("ERROR: Incorrect config string for MultiBitSel Bloom! :%s",
+ str);
}
- 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_bits = log_int(m_par_filter_size);
+ m_par_filter_size = m_filter_size / m_num_hashes;
+ m_par_filter_size_bits = floorLog2(m_par_filter_size);
m_filter.setSize(m_filter_size);
clear();
diff --git a/src/mem/ruby/filters/MultiGrainBloomFilter.cc b/src/mem/ruby/filters/MultiGrainBloomFilter.cc
index 24fcd7ead..7b3976473 100644
--- a/src/mem/ruby/filters/MultiGrainBloomFilter.cc
+++ b/src/mem/ruby/filters/MultiGrainBloomFilter.cc
@@ -26,6 +26,8 @@
* 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/ruby/common/Address.hh"
#include "mem/ruby/filters/MultiGrainBloomFilter.hh"
@@ -34,19 +36,21 @@ using namespace std;
MultiGrainBloomFilter::MultiGrainBloomFilter(string str)
{
- string tail(str);
-
- // split into the 2 filter sizes
- string head = string_split(tail, '_');
+ string head, tail;
+#ifndef NDEBUG
+ bool success =
+#endif
+ split_first(str, head, tail, '_');
+ assert(success);
// head contains size of 1st bloom filter, tail contains size of
// 2nd bloom filter
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_bits = log_int(m_page_filter_size);
+ m_page_filter_size_bits = floorLog2(m_page_filter_size);
m_filter.setSize(m_filter_size);
m_page_filter.setSize(m_page_filter_size);
diff --git a/src/mem/ruby/filters/NonCountingBloomFilter.cc b/src/mem/ruby/filters/NonCountingBloomFilter.cc
index 2b3965927..909aaf76b 100644
--- a/src/mem/ruby/filters/NonCountingBloomFilter.cc
+++ b/src/mem/ruby/filters/NonCountingBloomFilter.cc
@@ -26,6 +26,8 @@
* 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/ruby/common/Address.hh"
#include "mem/ruby/filters/NonCountingBloomFilter.hh"
@@ -34,13 +36,17 @@ using namespace std;
NonCountingBloomFilter::NonCountingBloomFilter(string str)
{
- string tail(str);
- string head = string_split(tail, '_');
+ string head, tail;
+#ifndef NDEBUG
+ bool success =
+#endif
+ split_first(str, head, tail, '_');
+ assert(success);
// head contains filter size, tail contains bit offset from block number
m_filter_size = atoi(head.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);
clear();
diff --git a/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh b/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh
index 1c90c2ca2..a8eca11a4 100644
--- a/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh
+++ b/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh
@@ -37,7 +37,6 @@
#define BASEGARNETNETWORK_H
#include "mem/ruby/network/garnet/NetworkHeader.hh"
-#include "mem/gems_common/util.hh"
#include "mem/ruby/network/Network.hh"
#include "params/BaseGarnetNetwork.hh"
diff --git a/src/mem/ruby/network/simple/PerfectSwitch.cc b/src/mem/ruby/network/simple/PerfectSwitch.cc
index 4555ef2b3..cf3a5af9c 100644
--- a/src/mem/ruby/network/simple/PerfectSwitch.cc
+++ b/src/mem/ruby/network/simple/PerfectSwitch.cc
@@ -26,7 +26,6 @@
* 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/ruby/buffers/MessageBuffer.hh"
#include "mem/ruby/network/simple/PerfectSwitch.hh"
diff --git a/src/mem/ruby/network/simple/SimpleNetwork.cc b/src/mem/ruby/network/simple/SimpleNetwork.cc
index 2940f19a1..47404ad01 100644
--- a/src/mem/ruby/network/simple/SimpleNetwork.cc
+++ b/src/mem/ruby/network/simple/SimpleNetwork.cc
@@ -75,10 +75,10 @@ SimpleNetwork::SimpleNetwork(const Params *p)
m_toNetQueues[node].setSize(m_virtual_networks);
m_fromNetQueues[node].setSize(m_virtual_networks);
for (int j = 0; j < m_virtual_networks; j++) {
- m_toNetQueues[node][j] = new MessageBuffer(
- "toNet node "+int_to_string(node)+" j "+int_to_string(j));
- m_fromNetQueues[node][j] = new MessageBuffer(
- "fromNet node "+int_to_string(node)+" j "+int_to_string(j));
+ m_toNetQueues[node][j] =
+ new MessageBuffer(csprintf("toNet node %d j %d", node, j));
+ m_fromNetQueues[node][j] =
+ new MessageBuffer(csprintf("fromNet node %d j %d", node, j));
}
}
}
diff --git a/src/mem/ruby/network/simple/Topology.cc b/src/mem/ruby/network/simple/Topology.cc
index f21129255..18618580a 100644
--- a/src/mem/ruby/network/simple/Topology.cc
+++ b/src/mem/ruby/network/simple/Topology.cc
@@ -26,7 +26,6 @@
* 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/Protocol.hh"
#include "mem/protocol/TopologyType.hh"
diff --git a/src/mem/ruby/profiler/Profiler.cc b/src/mem/ruby/profiler/Profiler.cc
index fc67f0052..aa23388ee 100644
--- a/src/mem/ruby/profiler/Profiler.cc
+++ b/src/mem/ruby/profiler/Profiler.cc
@@ -46,9 +46,9 @@
#include <sys/resource.h>
#include <sys/times.h>
+#include "base/str.hh"
#include "mem/gems_common/Map.hh"
#include "mem/gems_common/PrioHeap.hh"
-#include "mem/gems_common/util.hh"
#include "mem/protocol/CacheMsg.hh"
#include "mem/protocol/MachineType.hh"
#include "mem/protocol/Protocol.hh"
@@ -360,9 +360,12 @@ Profiler::printStats(ostream& out, bool short_stats)
int temp_int =
m_requestProfileMap_ptr->lookup(requestProfileKeys[i]);
double percent = (100.0 * double(temp_int)) / double(m_requests);
- while (requestProfileKeys[i] != "") {
- out << setw(10) << string_split(requestProfileKeys[i], ':');
- }
+ vector<string> items;
+ 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(14) << percent << endl;
}
diff --git a/src/mem/ruby/system/CacheMemory.cc b/src/mem/ruby/system/CacheMemory.cc
index 1e188fb60..62aa1e25d 100644
--- a/src/mem/ruby/system/CacheMemory.cc
+++ b/src/mem/ruby/system/CacheMemory.cc
@@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "base/intmath.hh"
#include "mem/ruby/system/CacheMemory.hh"
using namespace std;
@@ -60,7 +61,7 @@ CacheMemory::init()
m_cache_num_sets = (m_cache_size / m_cache_assoc) /
RubySystem::getBlockSizeBytes();
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);
if (m_policy == "PSEUDO_LRU")
diff --git a/src/mem/ruby/system/DirectoryMemory.cc b/src/mem/ruby/system/DirectoryMemory.cc
index b3999fb3f..65b61c935 100644
--- a/src/mem/ruby/system/DirectoryMemory.cc
+++ b/src/mem/ruby/system/DirectoryMemory.cc
@@ -26,7 +26,7 @@
* 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/system/DirectoryMemory.hh"
#include "mem/ruby/system/System.hh"
@@ -43,7 +43,7 @@ DirectoryMemory::DirectoryMemory(const Params *p)
{
m_version = p->version;
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_use_map = p->use_map;
m_map_levels = p->map_levels;
@@ -56,7 +56,7 @@ DirectoryMemory::init()
m_num_entries = m_size_bytes / RubySystem::getBlockSizeBytes();
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);
m_sparseMemory = new SparseMemory(entry_bits, m_map_levels);
} else {
@@ -67,7 +67,7 @@ DirectoryMemory::init()
}
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;
if (m_numa_high_bit == 0) {
@@ -116,7 +116,7 @@ DirectoryMemory::printGlobalConfig(ostream & out)
<< 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
diff --git a/src/mem/ruby/system/MachineID.hh b/src/mem/ruby/system/MachineID.hh
index 716196248..567d1f004 100644
--- a/src/mem/ruby/system/MachineID.hh
+++ b/src/mem/ruby/system/MachineID.hh
@@ -32,7 +32,7 @@
#include <iostream>
#include <string>
-#include "mem/gems_common/util.hh"
+#include "base/cprintf.hh"
#include "mem/protocol/MachineType.hh"
#include "mem/ruby/common/Global.hh"
@@ -45,7 +45,7 @@ struct MachineID
inline std::string
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
diff --git a/src/mem/ruby/system/MemoryControl.hh b/src/mem/ruby/system/MemoryControl.hh
index 73646f623..839fd007c 100644
--- a/src/mem/ruby/system/MemoryControl.hh
+++ b/src/mem/ruby/system/MemoryControl.hh
@@ -34,7 +34,6 @@
#include <string>
#include "mem/gems_common/Map.hh"
-#include "mem/gems_common/util.hh"
#include "mem/protocol/MemoryMsg.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/common/Consumer.hh"
diff --git a/src/mem/ruby/system/NodeID.hh b/src/mem/ruby/system/NodeID.hh
index 4ce8d8a8d..ed3486aaf 100644
--- a/src/mem/ruby/system/NodeID.hh
+++ b/src/mem/ruby/system/NodeID.hh
@@ -31,7 +31,7 @@
#include <string>
-#include "mem/gems_common/util.hh"
+#include "base/str.hh"
#include "mem/ruby/common/Global.hh"
typedef int NodeID;
@@ -39,7 +39,7 @@ typedef int NodeID;
inline std::string
NodeIDToString(NodeID node)
{
- return int_to_string(node);
+ return to_string(node);
}
#endif // __MEM_RUBY_SYSTEM_NODEID_HH__
diff --git a/src/mem/ruby/system/PersistentTable.cc b/src/mem/ruby/system/PersistentTable.cc
index 64730ee29..a8e6b0323 100644
--- a/src/mem/ruby/system/PersistentTable.cc
+++ b/src/mem/ruby/system/PersistentTable.cc
@@ -26,7 +26,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "mem/gems_common/util.hh"
#include "mem/ruby/system/PersistentTable.hh"
using namespace std;
diff --git a/src/mem/ruby/system/Sequencer.cc b/src/mem/ruby/system/Sequencer.cc
index 42bf7ebb5..dd8cec967 100644
--- a/src/mem/ruby/system/Sequencer.cc
+++ b/src/mem/ruby/system/Sequencer.cc
@@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "base/str.hh"
#include "cpu/rubytest/RubyTester.hh"
#include "mem/gems_common/Map.hh"
#include "mem/protocol/CacheMsg.hh"
diff --git a/src/mem/ruby/system/System.cc b/src/mem/ruby/system/System.cc
index 418b31bf0..d28d74a89 100644
--- a/src/mem/ruby/system/System.cc
+++ b/src/mem/ruby/system/System.cc
@@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "base/intmath.hh"
#include "base/output.hh"
#include "mem/ruby/buffers/MessageBuffer.hh"
#include "mem/ruby/common/Address.hh"
@@ -63,14 +64,14 @@ RubySystem::RubySystem(const Params *p)
m_clock = p->clock;
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);
+ assert(isPowerOf2(m_block_size_bytes));
+ m_block_size_bits = floorLog2(m_block_size_bytes);
m_memory_size_bytes = p->mem_size;
if (m_memory_size_bytes == 0) {
m_memory_size_bits = 0;
} 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;
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
index a58c1e9c7..ff9bccf63 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -330,12 +330,13 @@ static int m_num_controllers;
#include <sstream>
#include <string>
-#include "mem/ruby/common/Global.hh"
-#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
+#include "base/cprintf.hh"
#include "mem/protocol/${ident}_Controller.hh"
#include "mem/protocol/${ident}_State.hh"
#include "mem/protocol/${ident}_Event.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"
using namespace std;
@@ -526,7 +527,7 @@ if (m_buffer_size > 0) {
# set description (may be overriden later by port def)
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
code.insert_newline()
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
code.insert_newline()