ruby: get rid of Vector and use STL

add a couple of helper functions to base for deleteing all pointers in
a container and outputting containers to a stream
This commit is contained in:
Nathan Binkert 2010-06-10 23:17:07 -07:00
parent bc87fa30d7
commit 006818aeea
90 changed files with 603 additions and 787 deletions

97
src/base/stl_helpers.hh Normal file
View file

@ -0,0 +1,97 @@
/*
* Copyright (c) 2010 The Hewlett-Packard Development Company
* 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.
*
* Authors: Nathan Binkert
*/
#ifndef __BASE_STL_HELPERS_HH__
#define __BASE_STL_HELPERS_HH__
#include <algorithm>
#include <iostream>
namespace m5 {
namespace stl_helpers {
template <typename T>
void
deletePointer(T &ptr)
{
delete ptr;
ptr = NULL;
}
template <class T>
class ContainerPrint
{
private:
std::ostream &out;
bool first;
public:
ContainerPrint(std::ostream &out)
: out(out), first(true)
{}
void
operator()(const T &elem)
{
out << elem;
// First one doesn't get a space before it. The rest do.
if (first)
first = false;
else
out << " ";
}
};
// Treat all objects in an stl container as pointers to heap objects,
// calling delete on each one and zeroing the pointers along the way
template <typename T, template <typename T, typename A> class C, typename A>
void
deletePointers(C<T,A> &container)
{
std::for_each(container.begin(), container.end(), deletePointer<T>);
}
// Write out all elements in an stl container as a space separated
// list enclosed in square brackets
template <typename T, template <typename T, typename A> class C, typename A>
std::ostream &
operator<<(std::ostream& out, const C<T,A> &vec)
{
out << "[ ";
std::for_each(vec.begin(), vec.end(), ContainerPrint<T>(out));
out << " ]";
out << std::flush;
return out;
}
/* namespace stl_helpers */ }
/* namespace m5 */ }
#endif // __BASE_STL_HELPERS_HH__

View file

@ -102,7 +102,7 @@ CheckTable::addCheck(const Address& address)
// Insert it once per byte // Insert it once per byte
m_lookup_map_ptr->add(Address(address.getAddress() + i), check_ptr); m_lookup_map_ptr->add(Address(address.getAddress() + i), check_ptr);
} }
m_check_vector.insertAtBottom(check_ptr); m_check_vector.push_back(check_ptr);
} }
Check* Check*

View file

@ -31,8 +31,8 @@
#define __CPU_RUBYTEST_CHECKTABLE_HH__ #define __CPU_RUBYTEST_CHECKTABLE_HH__
#include <iostream> #include <iostream>
#include <vector>
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
class Address; class Address;
@ -63,7 +63,7 @@ class CheckTable
CheckTable(const CheckTable& obj); CheckTable(const CheckTable& obj);
CheckTable& operator=(const CheckTable& obj); CheckTable& operator=(const CheckTable& obj);
Vector<Check*> m_check_vector; std::vector<Check*> m_check_vector;
Map<Address, Check*>* m_lookup_map_ptr; Map<Address, Check*>* m_lookup_map_ptr;
int m_num_cpu_sequencers; int m_num_cpu_sequencers;

View file

@ -59,7 +59,7 @@ RubyTester::init()
{ {
assert(ports.size() > 0); assert(ports.size() > 0);
m_last_progress_vector.setSize(ports.size()); m_last_progress_vector.resize(ports.size());
for (int i = 0; i < m_last_progress_vector.size(); i++) { for (int i = 0; i < m_last_progress_vector.size(); i++) {
m_last_progress_vector[i] = 0; m_last_progress_vector[i] = 0;
} }

View file

@ -31,6 +31,7 @@
#define __CPU_RUBYTEST_RUBYTESTER_HH__ #define __CPU_RUBYTEST_RUBYTESTER_HH__
#include <iostream> #include <iostream>
#include <vector>
#include <string> #include <string>
#include "cpu/rubytest/CheckTable.hh" #include "cpu/rubytest/CheckTable.hh"
@ -126,7 +127,7 @@ class RubyTester : public MemObject
RubyTester& operator=(const RubyTester& obj); RubyTester& operator=(const RubyTester& obj);
CheckTable* m_checkTable_ptr; CheckTable* m_checkTable_ptr;
Vector<Time> m_last_progress_vector; std::vector<Time> m_last_progress_vector;
uint64 m_checks_completed; uint64 m_checks_completed;
std::vector<CpuPort*> ports; std::vector<CpuPort*> ports;

View file

@ -34,10 +34,11 @@
#ifndef MAP_H #ifndef MAP_H
#define MAP_H #define MAP_H
#include <cassert>
#include <iostream> #include <iostream>
#include <vector>
#include "base/hashmap.hh" #include "base/hashmap.hh"
#include "mem/gems_common/Vector.hh"
template <class KEY_TYPE, class VALUE_TYPE> template <class KEY_TYPE, class VALUE_TYPE>
class Map class Map
@ -55,8 +56,8 @@ public:
bool exist(const KEY_TYPE& key) const; bool exist(const KEY_TYPE& key) const;
int size() const { return m_map.size(); } int size() const { return m_map.size(); }
void erase(const KEY_TYPE& key) { assert(exist(key)); m_map.erase(key); } void erase(const KEY_TYPE& key) { assert(exist(key)); m_map.erase(key); }
Vector<KEY_TYPE> keys() const; std::vector<KEY_TYPE> keys() const;
Vector<VALUE_TYPE> values() const; std::vector<VALUE_TYPE> values() const;
void deleteKeys(); void deleteKeys();
void deleteValues(); void deleteValues();
VALUE_TYPE& lookup(const KEY_TYPE& key) const; VALUE_TYPE& lookup(const KEY_TYPE& key) const;
@ -108,27 +109,29 @@ VALUE_TYPE& Map<KEY_TYPE, VALUE_TYPE>::lookup(const KEY_TYPE& key) const
} }
template <class KEY_TYPE, class VALUE_TYPE> template <class KEY_TYPE, class VALUE_TYPE>
Vector<KEY_TYPE> Map<KEY_TYPE, VALUE_TYPE>::keys() const std::vector<KEY_TYPE> Map<KEY_TYPE, VALUE_TYPE>::keys() const
{ {
Vector<KEY_TYPE> keys; std::vector<KEY_TYPE> keys(m_map.size());
const_iterator iter; const_iterator iter = m_map.begin();
for (iter = m_map.begin(); iter != m_map.end(); iter++) { for (int i = 0; i < m_map.size(); ++i) {
keys.insertAtBottom((*iter).first); keys[i] = iter->first;
++iter;
} }
assert(iter == m_map.end());
return keys; return keys;
} }
template <class KEY_TYPE, class VALUE_TYPE> template <class KEY_TYPE, class VALUE_TYPE>
Vector<VALUE_TYPE> Map<KEY_TYPE, VALUE_TYPE>::values() const std::vector<VALUE_TYPE> Map<KEY_TYPE, VALUE_TYPE>::values() const
{ {
Vector<VALUE_TYPE> values; std::vector<VALUE_TYPE> values(m_map.size());
const_iterator iter; const_iterator iter = m_map.begin();
std::pair<KEY_TYPE, VALUE_TYPE> p;
for (iter = m_map.begin(); iter != m_map.end(); iter++) { for (int i = 0; i < m_map.size(); ++i) {
p = *iter; values[i] = iter->second;
values.insertAtBottom(p.second); ++iter;
} }
assert(iter == m_map.end());
return values; return values;
} }

View file

@ -29,9 +29,9 @@
#ifndef PRIOHEAP_H #ifndef PRIOHEAP_H
#define PRIOHEAP_H #define PRIOHEAP_H
#include <cassert>
#include <iostream> #include <iostream>
#include <vector>
#include "mem/gems_common/Vector.hh"
typedef unsigned int HeapIndex; typedef unsigned int HeapIndex;
@ -63,7 +63,7 @@ private:
PrioHeap<TYPE>& operator=(const PrioHeap& obj); PrioHeap<TYPE>& operator=(const PrioHeap& obj);
// Data Members (m_ prefix) // Data Members (m_ prefix)
Vector<TYPE> m_heap; std::vector<TYPE> m_heap;
HeapIndex m_current_size; HeapIndex m_current_size;
}; };
@ -109,7 +109,7 @@ void PrioHeap<TYPE>::insert(const TYPE& key)
int i; int i;
// grow the vector size // grow the vector size
m_current_size++; m_current_size++;
m_heap.setSize(m_current_size+1); m_heap.resize(m_current_size+1);
if(m_current_size == 1){ // HACK: need to initialize index 0 to avoid purify UMCs if(m_current_size == 1){ // HACK: need to initialize index 0 to avoid purify UMCs
m_heap[0] = key; m_heap[0] = key;
@ -214,7 +214,7 @@ void PrioHeap<TYPE>::heapify()
template <class TYPE> template <class TYPE>
void PrioHeap<TYPE>::print(std::ostream& out) const void PrioHeap<TYPE>::print(std::ostream& out) const
{ {
Vector<TYPE> copyHeap(m_heap); std::vector<TYPE> copyHeap(m_heap);
// sort copyHeap (inefficient, but will not be done often) // sort copyHeap (inefficient, but will not be done often)

View file

@ -1,337 +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.
*/
/*
* Description: The Vector class is a generic container which acts
* much like an array. The Vector class handles dynamic sizing and
* resizing as well as performing bounds checking on each access. An
* "insertAtBottom" operation is supported to allow adding elements to
* the Vector much like you would add new elements to a linked list or
* queue.
*/
#ifndef VECTOR_H
#define VECTOR_H
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
template <class TYPE>
class Vector
{
public:
Vector();
explicit Vector(int initial_size); // Construct with an initial max size
~Vector();
const TYPE& ref(int index) const; // Get an element of the vector
TYPE& ref(int index); // Get an element of the vector
void clear(); // remove all elements of the vector
void sortVector(); // sort all elements using < operator
int size() const { return m_size; }
void setSize(int new_size); // Increase size, reallocates memory as needed
void expand(int num) { setSize(m_size+num); } // Increase size by num
void increaseSize(int new_size, const TYPE& reset); // and adds num of slots at the bottom set to reset value
void insertAtTop(const TYPE& element); // Increase size by one and set last element
// FIXME - WARNING: insertAtTop is currently O(n) and needs to be fixed
void insertAtBottom(const TYPE& element); // Increase size by one and set last element
TYPE sum() const; // Uses the += operator to sum all the elements of the vector
void deletePointers(); // Walks the Vector calling delete on all
// elements and sets them to NULL, can only
// be used when the TYPE is a pointer type.
void removeFromTop(int num); // removes elements from top
void print(std::ostream& out) const;
// Array Reference operator overloading
const TYPE& operator[](int index) const { return ref(index); }
TYPE& operator[](int index) { return ref(index); }
// Public copy constructor and assignment operator
Vector(const Vector& vec);
Vector<TYPE>& operator=(const Vector& vec);
private:
void grow(int new_max_size); // Expands vector to new_max_size
// Data members
TYPE* m_vec; // Array to hold the elements
int m_size; // Number of elements in use
int m_max_size; // Size of allocated array
};
template <class TYPE>
std::ostream& operator<<(std::ostream& out, const Vector<TYPE>& vec);
// *********************
template <class TYPE>
Vector<TYPE>::Vector()
{
m_size = 0;
m_max_size = 0;
m_vec = NULL;
}
template <class TYPE>
Vector<TYPE>::Vector(int initial_size)
{
m_size = 0;
m_max_size = initial_size;
m_vec = NULL;
grow(initial_size);
}
template <class TYPE>
Vector<TYPE>::~Vector()
{
delete [] m_vec;
}
template <class TYPE>
const TYPE& Vector<TYPE>::ref(int index) const
{
#ifndef NO_VECTOR_BOUNDS_CHECKS
assert(m_size != 0);
assert(index < m_size);
assert(index >= 0);
#endif
return m_vec[index];
}
template <class TYPE>
TYPE& Vector<TYPE>::ref(int index)
{
#ifndef NO_VECTOR_BOUNDS_CHECKS
assert(m_size != 0);
assert(index < m_size);
assert(index >= 0);
#endif
return m_vec[index];
}
template <class TYPE>
void Vector<TYPE>::setSize(int new_size)
{
// FIXME - this should also decrease or shrink the size of the array at some point.
if (new_size > m_max_size) {
grow(std::max((m_max_size+1)*2, new_size));
}
m_size = new_size;
#ifndef NO_VECTOR_BOUNDS_CHECKS
assert(m_size <= m_max_size);
assert(m_size >= 0);
#endif
}
template <class TYPE>
inline
void Vector<TYPE>::increaseSize(int new_size, const TYPE& reset)
{
assert(new_size >= m_size);
if (new_size >= m_max_size) {
grow(std::max((m_max_size+1)*2, new_size));
}
int old_size = m_size;
m_size = new_size;
for (int j = old_size; j < m_size; j++) {
ref(j) = reset;
}
#ifndef NO_VECTOR_BOUNDS_CHECKS
assert(m_size <= m_max_size);
assert(m_size >= 0);
#endif
}
template <class TYPE>
inline
void Vector<TYPE>::clear()
{
m_size = 0;
m_max_size = 0;
delete [] m_vec;
m_vec = NULL;
}
template <class TYPE>
inline
void Vector<TYPE>::sortVector()
{
std::sort(&m_vec[0], &m_vec[m_size]);
}
template <class TYPE>
inline
void Vector<TYPE>::insertAtTop(const TYPE& element)
{
setSize(m_size+1);
for (int i = m_size-1; i >= 1; i--) {
ref(i) = ref(i-1);
}
ref(0) = element;
}
template <class TYPE>
inline
void Vector<TYPE>::removeFromTop(int num)
{
if (num > m_size) {
num = m_size;
}
for (int i = 0; i < m_size - num; i++) {
m_vec[i] = m_vec[i+num];
}
m_size = m_size - num;
}
template <class TYPE>
void Vector<TYPE>::insertAtBottom(const TYPE& element)
{
setSize(m_size+1);
ref(m_size-1) = element;
}
template <class TYPE>
TYPE Vector<TYPE>::sum() const
{
assert(m_size > 0);
TYPE sum = ref(0);
for(int i=1; i<m_size; i++) {
sum += ref(i);
}
return sum;
}
template <class TYPE>
void Vector<TYPE>::deletePointers()
{
assert(m_size >= 0);
for(int i=0; i<m_size; i++) {
// FIXME this function should be non-member function, otherwise this
// prevent template instantiation for non-pointer types
//
// Also, there is warning of Switch.cc which use void* here
delete ref(i);
ref(i) = NULL;
}
}
template <class TYPE>
void Vector<TYPE>::print(std::ostream& out) const
{
out << "[ ";
for(int i=0; i<m_size; i++) {
if (i != 0) {
out << " ";
}
out << ref(i);
}
out << " ]";
out << std::flush;
}
// Copy constructor
template <class TYPE>
Vector<TYPE>::Vector(const Vector& vec)
{
// Setup the new memory
m_size = vec.m_size;
m_max_size = vec.m_max_size;
if (m_max_size != 0) {
m_vec = new TYPE[m_max_size];
assert(m_vec != NULL);
} else {
m_vec = NULL;
}
// Copy the elements of the array
for(int i=0; i<m_size; i++) {
m_vec[i] = vec.m_vec[i]; // Element copy
}
}
template <class TYPE>
Vector<TYPE>& Vector<TYPE>::operator=(const Vector& vec)
{
if (this == &vec) {
// assert(0);
} else {
// Free the old memory
delete [] m_vec;
// Setup the new memory
m_size = vec.m_size;
m_max_size = vec.m_max_size;
if (m_max_size != 0) {
m_vec = new TYPE[m_max_size];
assert(m_vec != NULL);
} else {
m_vec = NULL;
}
// Copy the elements of the array
for(int i=0; i<m_size; i++) {
m_vec[i] = vec.m_vec[i]; // Element copy
}
}
return *this;
}
template <class TYPE>
void Vector<TYPE>::grow(int new_max_size)
{
TYPE* temp_vec;
m_max_size = new_max_size;
if (new_max_size != 0) {
temp_vec = new TYPE[new_max_size];
assert(temp_vec != NULL);
} else {
temp_vec = NULL;
}
// Copy the elements of the array
for(int i=0; i<m_size; i++) {
temp_vec[i] = m_vec[i]; // Element copy
}
delete [] m_vec;
m_vec = temp_vec;
}
template <class TYPE>
std::ostream& operator<<(std::ostream& out, const Vector<TYPE>& vec)
{
vec.print(out);
return out;
}
#endif //VECTOR_H

View file

@ -121,7 +121,7 @@ class MessageBuffer
m_strict_fifo = order; m_strict_fifo = order;
m_ordering_set = true; m_ordering_set = true;
} }
void setSize(int size) { m_max_size = size; } void resize(int size) { m_max_size = size; }
int getSize(); int getSize();
void setRandomization(bool random_flag) { m_randomization = random_flag; } void setRandomization(bool random_flag) { m_randomization = random_flag; }

View file

@ -32,7 +32,6 @@
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
#include "mem/ruby/system/System.hh" #include "mem/ruby/system/System.hh"

View file

@ -58,7 +58,7 @@ Histogram::clear(int bins)
m_bins = bins; m_bins = bins;
m_largest_bin = 0; m_largest_bin = 0;
m_max = 0; m_max = 0;
m_data.setSize(m_bins); m_data.resize(m_bins);
for (int i = 0; i < m_bins; i++) { for (int i = 0; i < m_bins; i++) {
m_data[i] = 0; m_data[i] = 0;
} }

View file

@ -30,9 +30,9 @@
#define __MEM_RUBY_COMMON_HISTOGRAM_HH__ #define __MEM_RUBY_COMMON_HISTOGRAM_HH__
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
#include "mem/gems_common/Vector.hh"
class Histogram class Histogram
{ {
@ -56,7 +56,7 @@ class Histogram
void print(std::ostream& out) const; void print(std::ostream& out) const;
private: private:
Vector<int64> m_data; std::vector<int64> m_data;
int64 m_max; // the maximum value seen so far int64 m_max; // the maximum value seen so far
int64 m_count; // the number of elements added int64 m_count; // the number of elements added
int m_binsize; // the size of each bucket int m_binsize; // the size of each bucket

View file

@ -31,7 +31,7 @@
NetDest::NetDest() NetDest::NetDest()
{ {
setSize(); resize();
} }
void void
@ -107,16 +107,16 @@ NetDest::broadcast(MachineType machineType)
} }
//For Princeton Network //For Princeton Network
Vector<NodeID> std::vector<NodeID>
NetDest::getAllDest() NetDest::getAllDest()
{ {
Vector<NodeID> dest; std::vector<NodeID> dest;
dest.clear(); dest.clear();
for (int i = 0; i < m_bits.size(); i++) { for (int i = 0; i < m_bits.size(); i++) {
for (int j = 0; j < m_bits[i].getSize(); j++) { for (int j = 0; j < m_bits[i].getSize(); j++) {
if (m_bits[i].isElement(j)) { if (m_bits[i].isElement(j)) {
int id = MachineType_base_number((MachineType)i) + j; int id = MachineType_base_number((MachineType)i) + j;
dest.insertAtBottom((NodeID)id); dest.push_back((NodeID)id);
} }
} }
} }
@ -249,9 +249,9 @@ NetDest::isElement(MachineID element) const
} }
void void
NetDest::setSize() NetDest::resize()
{ {
m_bits.setSize(MachineType_base_level(MachineType_NUM)); m_bits.resize(MachineType_base_level(MachineType_NUM));
assert(m_bits.size() == MachineType_NUM); assert(m_bits.size() == MachineType_NUM);
for (int i = 0; i < m_bits.size(); i++) { for (int i = 0; i < m_bits.size(); i++) {

View file

@ -35,8 +35,8 @@
#define __MEM_RUBY_COMMON_NETDEST_HH__ #define __MEM_RUBY_COMMON_NETDEST_HH__
#include <iostream> #include <iostream>
#include <vector>
#include "mem/gems_common/Vector.hh"
#include "mem/protocol/MachineType.hh" #include "mem/protocol/MachineType.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
#include "mem/ruby/common/Set.hh" #include "mem/ruby/common/Set.hh"
@ -89,12 +89,12 @@ class NetDest
bool isEmpty() const; bool isEmpty() const;
// For Princeton Network // For Princeton Network
Vector<NodeID> getAllDest(); std::vector<NodeID> getAllDest();
MachineID smallestElement() const; MachineID smallestElement() const;
MachineID smallestElement(MachineType machine) const; MachineID smallestElement(MachineType machine) const;
void setSize(); void resize();
int getSize() const { return m_bits.size(); } int getSize() const { return m_bits.size(); }
// get element for a index // get element for a index
@ -119,7 +119,7 @@ class NetDest
return index; return index;
} }
Vector <Set> m_bits; // a Vector of bit vectors - i.e. Sets std::vector<Set> m_bits; // a vector of bit vectors - i.e. Sets
}; };
inline std::ostream& inline std::ostream&

View file

@ -26,12 +26,15 @@
* 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/stl_helpers.hh"
#include "mem/ruby/common/SubBlock.hh" #include "mem/ruby/common/SubBlock.hh"
using m5::stl_helpers::operator<<;
SubBlock::SubBlock(const Address& addr, int size) SubBlock::SubBlock(const Address& addr, int size)
{ {
m_address = addr; m_address = addr;
setSize(size); resize(size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
setByte(i, 0); setByte(i, 0);
} }

View file

@ -30,8 +30,8 @@
#define __MEM_RUBY_COMMON_SUBBLOCK_HH__ #define __MEM_RUBY_COMMON_SUBBLOCK_HH__
#include <iostream> #include <iostream>
#include <vector>
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/common/Address.hh" #include "mem/ruby/common/Address.hh"
#include "mem/ruby/common/DataBlock.hh" #include "mem/ruby/common/DataBlock.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
@ -47,7 +47,7 @@ class SubBlock
void setAddress(const Address& addr) { m_address = addr; } void setAddress(const Address& addr) { m_address = addr; }
int getSize() const { return m_data.size(); } int getSize() const { return m_data.size(); }
void setSize(int size) { m_data.setSize(size); } void resize(int size) { m_data.resize(size); }
uint8 getByte(int offset) const { return m_data[offset]; } uint8 getByte(int offset) const { return m_data[offset]; }
void setByte(int offset, uint8 data) { m_data[offset] = data; } void setByte(int offset, uint8 data) { m_data[offset] = data; }
@ -68,7 +68,7 @@ class SubBlock
// Data Members (m_ prefix) // Data Members (m_ prefix)
Address m_address; Address m_address;
Vector<uint8_t> m_data; std::vector<uint8_t> m_data;
}; };
inline std::ostream& inline std::ostream&

View file

@ -60,7 +60,6 @@
#include "config/no_vector_bounds_checks.hh" #include "config/no_vector_bounds_checks.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
#include "mem/gems_common/Vector.hh"
#include "sim/eventq.hh" #include "sim/eventq.hh"
class Consumer; class Consumer;

View file

@ -48,7 +48,7 @@ BlockBloomFilter::BlockBloomFilter(string str)
m_filter_size = atoi(head.c_str()); m_filter_size = atoi(head.c_str());
m_filter_size_bits = floorLog2(m_filter_size); m_filter_size_bits = floorLog2(m_filter_size);
m_filter.setSize(m_filter_size); m_filter.resize(m_filter_size);
clear(); clear();
} }

View file

@ -31,8 +31,8 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/gems_common/Map.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/AbstractBloomFilter.hh" #include "mem/ruby/filters/AbstractBloomFilter.hh"
@ -62,7 +62,7 @@ class BlockBloomFilter : public AbstractBloomFilter
private: private:
int get_index(const Address& addr); int get_index(const Address& addr);
Vector<int> m_filter; std::vector<int> m_filter;
int m_filter_size; int m_filter_size;
int m_filter_size_bits; int m_filter_size_bits;

View file

@ -49,8 +49,8 @@ BulkBloomFilter::BulkBloomFilter(string str)
// 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;
m_temp_filter.setSize(m_filter_size); m_temp_filter.resize(m_filter_size);
m_filter.setSize(m_filter_size); m_filter.resize(m_filter_size);
clear(); clear();
// clear temp filter // clear temp filter

View file

@ -31,8 +31,8 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/gems_common/Map.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/AbstractBloomFilter.hh" #include "mem/ruby/filters/AbstractBloomFilter.hh"
@ -63,8 +63,8 @@ class BulkBloomFilter : public AbstractBloomFilter
int get_index(const Address& addr); int get_index(const Address& addr);
Address permute(const Address & addr); Address permute(const Address & addr);
Vector<int> m_filter; std::vector<int> m_filter;
Vector<int> m_temp_filter; std::vector<int> m_temp_filter;
int m_filter_size; int m_filter_size;
int m_filter_size_bits; int m_filter_size_bits;

View file

@ -401,7 +401,7 @@ H3BloomFilter::H3BloomFilter(string str)
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 = floorLog2(m_par_filter_size); m_par_filter_size_bits = floorLog2(m_par_filter_size);
m_filter.setSize(m_filter_size); m_filter.resize(m_filter_size);
clear(); clear();
} }

View file

@ -31,8 +31,8 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/gems_common/Map.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/AbstractBloomFilter.hh" #include "mem/ruby/filters/AbstractBloomFilter.hh"
@ -72,7 +72,7 @@ class H3BloomFilter : public AbstractBloomFilter
int hash_H3(uint64 value, int index); int hash_H3(uint64 value, int index);
Vector<int> m_filter; std::vector<int> m_filter;
int m_filter_size; int m_filter_size;
int m_num_hashes; int m_num_hashes;
int m_filter_size_bits; int m_filter_size_bits;

View file

@ -49,7 +49,7 @@ LSB_CountingBloomFilter::LSB_CountingBloomFilter(string str)
m_count = atoi(tail.c_str()); m_count = atoi(tail.c_str());
m_count_bits = floorLog2(m_count); m_count_bits = floorLog2(m_count);
m_filter.setSize(m_filter_size); m_filter.resize(m_filter_size);
clear(); clear();
} }

View file

@ -31,8 +31,8 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/gems_common/Map.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/AbstractBloomFilter.hh" #include "mem/ruby/filters/AbstractBloomFilter.hh"
@ -62,7 +62,7 @@ class LSB_CountingBloomFilter : public AbstractBloomFilter
private: private:
int get_index(const Address& addr); int get_index(const Address& addr);
Vector<int> m_filter; std::vector<int> m_filter;
int m_filter_size; int m_filter_size;
int m_filter_size_bits; int m_filter_size_bits;

View file

@ -61,7 +61,7 @@ MultiBitSelBloomFilter::MultiBitSelBloomFilter(string str)
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 = floorLog2(m_par_filter_size); m_par_filter_size_bits = floorLog2(m_par_filter_size);
m_filter.setSize(m_filter_size); m_filter.resize(m_filter_size);
clear(); clear();
} }

View file

@ -31,8 +31,8 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/gems_common/Map.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/AbstractBloomFilter.hh" #include "mem/ruby/filters/AbstractBloomFilter.hh"
@ -73,7 +73,7 @@ class MultiBitSelBloomFilter : public AbstractBloomFilter
int hash_bitsel(uint64 value, int index, int jump, int maxBits, int hash_bitsel(uint64 value, int index, int jump, int maxBits,
int numBits); int numBits);
Vector<int> m_filter; std::vector<int> m_filter;
int m_filter_size; int m_filter_size;
int m_num_hashes; int m_num_hashes;
int m_filter_size_bits; int m_filter_size_bits;

View file

@ -52,8 +52,8 @@ MultiGrainBloomFilter::MultiGrainBloomFilter(string str)
m_page_filter_size = atoi(tail.c_str()); m_page_filter_size = atoi(tail.c_str());
m_page_filter_size_bits = floorLog2(m_page_filter_size); m_page_filter_size_bits = floorLog2(m_page_filter_size);
m_filter.setSize(m_filter_size); m_filter.resize(m_filter_size);
m_page_filter.setSize(m_page_filter_size); m_page_filter.resize(m_page_filter_size);
clear(); clear();
} }

View file

@ -31,8 +31,8 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/gems_common/Map.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/AbstractBloomFilter.hh" #include "mem/ruby/filters/AbstractBloomFilter.hh"
@ -64,11 +64,11 @@ class MultiGrainBloomFilter : public AbstractBloomFilter
int get_page_index(const Address & addr); int get_page_index(const Address & addr);
// The block filter // The block filter
Vector<int> m_filter; std::vector<int> m_filter;
int m_filter_size; int m_filter_size;
int m_filter_size_bits; int m_filter_size_bits;
// The page number filter // The page number filter
Vector<int> m_page_filter; std::vector<int> m_page_filter;
int m_page_filter_size; int m_page_filter_size;
int m_page_filter_size_bits; int m_page_filter_size_bits;

View file

@ -48,7 +48,7 @@ NonCountingBloomFilter::NonCountingBloomFilter(string str)
m_offset = atoi(tail.c_str()); m_offset = atoi(tail.c_str());
m_filter_size_bits = floorLog2(m_filter_size); m_filter_size_bits = floorLog2(m_filter_size);
m_filter.setSize(m_filter_size); m_filter.resize(m_filter_size);
clear(); clear();
} }

View file

@ -31,8 +31,8 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/gems_common/Map.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/AbstractBloomFilter.hh" #include "mem/ruby/filters/AbstractBloomFilter.hh"
@ -69,7 +69,7 @@ class NonCountingBloomFilter : public AbstractBloomFilter
private: private:
int get_index(const Address& addr); int get_index(const Address& addr);
Vector<int> m_filter; std::vector<int> m_filter;
int m_filter_size; int m_filter_size;
int m_offset; int m_offset;
int m_filter_size_bits; int m_filter_size_bits;

View file

@ -90,7 +90,7 @@ Network::MessageSizeType_to_int(MessageSizeType size_type)
return 0; return 0;
} }
const Vector<Throttle*>* const std::vector<Throttle*>*
Network::getThrottles(NodeID id) const Network::getThrottles(NodeID id) const
{ {
return NULL; return NULL;

View file

@ -42,6 +42,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/protocol/MessageSizeType.hh" #include "mem/protocol/MessageSizeType.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
@ -76,7 +77,7 @@ class Network : public SimObject
int netNumber) = 0; int netNumber) = 0;
virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered,
int netNumber) = 0; int netNumber) = 0;
virtual const Vector<Throttle*>* getThrottles(NodeID id) const; virtual const std::vector<Throttle*>* getThrottles(NodeID id) const;
virtual int getNumNodes() {return 1;} virtual int getNumNodes() {return 1;}
virtual void makeOutLink(SwitchID src, NodeID dest, virtual void makeOutLink(SwitchID src, NodeID dest,

View file

@ -28,6 +28,7 @@
* Authors: Niket Agarwal * Authors: Niket Agarwal
*/ */
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
#include "mem/protocol/MachineType.hh" #include "mem/protocol/MachineType.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh"
@ -39,6 +40,7 @@
#include "mem/ruby/common/NetDest.hh" #include "mem/ruby/common/NetDest.hh"
using namespace std; using namespace std;
using m5::stl_helpers::deletePointers;
GarnetNetwork_d::GarnetNetwork_d(const Params *p) GarnetNetwork_d::GarnetNetwork_d(const Params *p)
: BaseGarnetNetwork(p) : BaseGarnetNetwork(p)
@ -52,10 +54,10 @@ GarnetNetwork_d::GarnetNetwork_d(const Params *p)
m_router_ptr_vector.clear(); m_router_ptr_vector.clear();
// Allocate to and from queues // Allocate to and from queues
m_toNetQueues.setSize(m_nodes); // Queues that are getting messages from protocol m_toNetQueues.resize(m_nodes); // Queues that are getting messages from protocol
m_fromNetQueues.setSize(m_nodes); // Queues that are feeding the protocol m_fromNetQueues.resize(m_nodes); // Queues that are feeding the protocol
m_in_use.setSize(m_virtual_networks); m_in_use.resize(m_virtual_networks);
m_ordered.setSize(m_virtual_networks); m_ordered.resize(m_virtual_networks);
for (int i = 0; i < m_virtual_networks; i++) for (int i = 0; i < m_virtual_networks; i++)
{ {
m_in_use[i] = false; m_in_use[i] = false;
@ -65,8 +67,8 @@ GarnetNetwork_d::GarnetNetwork_d(const Params *p)
for (int node = 0; node < m_nodes; node++) for (int node = 0; node < m_nodes; node++)
{ {
//Setting how many vitual message buffers will there be per Network Queue //Setting how many vitual message buffers will there be per Network Queue
m_toNetQueues[node].setSize(m_virtual_networks); m_toNetQueues[node].resize(m_virtual_networks);
m_fromNetQueues[node].setSize(m_virtual_networks); m_fromNetQueues[node].resize(m_virtual_networks);
for (int j = 0; j < m_virtual_networks; j++) for (int j = 0; j < m_virtual_networks; j++)
{ {
@ -88,13 +90,13 @@ void GarnetNetwork_d::init()
int number_of_routers = m_topology_ptr->numSwitches(); int number_of_routers = m_topology_ptr->numSwitches();
for (int i=0; i<number_of_routers; i++) { for (int i=0; i<number_of_routers; i++) {
m_router_ptr_vector.insertAtBottom(new Router_d(i, this)); m_router_ptr_vector.push_back(new Router_d(i, this));
} }
for (int i=0; i < m_nodes; i++) { for (int i=0; i < m_nodes; i++) {
NetworkInterface_d *ni = new NetworkInterface_d(i, m_virtual_networks, this); NetworkInterface_d *ni = new NetworkInterface_d(i, m_virtual_networks, this);
ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]); ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]);
m_ni_ptr_vector.insertAtBottom(ni); m_ni_ptr_vector.push_back(ni);
} }
m_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration m_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration
for(int i = 0; i < m_router_ptr_vector.size(); i++) for(int i = 0; i < m_router_ptr_vector.size(); i++)
@ -107,13 +109,13 @@ GarnetNetwork_d::~GarnetNetwork_d()
{ {
for (int i = 0; i < m_nodes; i++) for (int i = 0; i < m_nodes; i++)
{ {
m_toNetQueues[i].deletePointers(); deletePointers(m_toNetQueues[i]);
m_fromNetQueues[i].deletePointers(); deletePointers(m_fromNetQueues[i]);
} }
m_router_ptr_vector.deletePointers(); deletePointers(m_router_ptr_vector);
m_ni_ptr_vector.deletePointers(); deletePointers(m_ni_ptr_vector);
m_link_ptr_vector.deletePointers(); deletePointers(m_link_ptr_vector);
m_creditlink_ptr_vector.deletePointers(); deletePointers(m_creditlink_ptr_vector);
delete m_topology_ptr; delete m_topology_ptr;
} }
@ -143,8 +145,8 @@ void GarnetNetwork_d::makeInLink(NodeID src, SwitchID dest, const NetDest& routi
{ {
NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this); NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this);
CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this); CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this);
m_link_ptr_vector.insertAtBottom(net_link); m_link_ptr_vector.push_back(net_link);
m_creditlink_ptr_vector.insertAtBottom(credit_link); m_creditlink_ptr_vector.push_back(credit_link);
m_router_ptr_vector[dest]->addInPort(net_link, credit_link); m_router_ptr_vector[dest]->addInPort(net_link, credit_link);
m_ni_ptr_vector[src]->addOutPort(net_link, credit_link); m_ni_ptr_vector[src]->addOutPort(net_link, credit_link);
@ -172,8 +174,8 @@ void GarnetNetwork_d::makeOutLink(SwitchID src, NodeID dest, const NetDest& rout
{ {
NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this); NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this);
CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this); CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this);
m_link_ptr_vector.insertAtBottom(net_link); m_link_ptr_vector.push_back(net_link);
m_creditlink_ptr_vector.insertAtBottom(credit_link); m_creditlink_ptr_vector.push_back(credit_link);
m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight, credit_link); m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight, credit_link);
m_ni_ptr_vector[dest]->addInPort(net_link, credit_link); m_ni_ptr_vector[dest]->addInPort(net_link, credit_link);
@ -195,8 +197,8 @@ void GarnetNetwork_d::makeInternalLink(SwitchID src, SwitchID dest, const NetDes
{ {
NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this); NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this);
CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this); CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this);
m_link_ptr_vector.insertAtBottom(net_link); m_link_ptr_vector.push_back(net_link);
m_creditlink_ptr_vector.insertAtBottom(credit_link); m_creditlink_ptr_vector.push_back(credit_link);
m_router_ptr_vector[dest]->addInPort(net_link, credit_link); m_router_ptr_vector[dest]->addInPort(net_link, credit_link);
m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight, credit_link); m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight, credit_link);
@ -244,8 +246,8 @@ Time GarnetNetwork_d::getRubyStartTime()
void GarnetNetwork_d::printStats(ostream& out) const void GarnetNetwork_d::printStats(ostream& out) const
{ double average_link_utilization = 0; { double average_link_utilization = 0;
Vector<double > average_vc_load; vector<double> average_vc_load;
average_vc_load.setSize(m_virtual_networks*m_vcs_per_class); average_vc_load.resize(m_virtual_networks*m_vcs_per_class);
for(int i = 0; i < m_virtual_networks*m_vcs_per_class; i++) for(int i = 0; i < m_virtual_networks*m_vcs_per_class; i++)
{ {
@ -260,7 +262,7 @@ void GarnetNetwork_d::printStats(ostream& out) const
{ {
average_link_utilization += (double(m_link_ptr_vector[i]->getLinkUtilization())) / (double(g_eventQueue_ptr->getTime()-m_ruby_start)); average_link_utilization += (double(m_link_ptr_vector[i]->getLinkUtilization())) / (double(g_eventQueue_ptr->getTime()-m_ruby_start));
Vector<int > vc_load = m_link_ptr_vector[i]->getVcLoad(); vector<int> vc_load = m_link_ptr_vector[i]->getVcLoad();
for(int j = 0; j < vc_load.size(); j++) for(int j = 0; j < vc_load.size(); j++)
{ {
assert(vc_load.size() == m_vcs_per_class*m_virtual_networks); assert(vc_load.size() == m_vcs_per_class*m_virtual_networks);

View file

@ -32,9 +32,9 @@
#define GARNETNETWORK_D_H #define GARNETNETWORK_D_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh" #include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
#include "mem/ruby/network/Network.hh" #include "mem/ruby/network/Network.hh"
#include "params/GarnetNetwork_d.hh" #include "params/GarnetNetwork_d.hh"
@ -112,16 +112,16 @@ private:
int m_flits_recieved, m_flits_injected; int m_flits_recieved, m_flits_injected;
double m_network_latency, m_queueing_latency; double m_network_latency, m_queueing_latency;
Vector<bool> m_in_use; std::vector<bool> m_in_use;
Vector<bool> m_ordered; std::vector<bool> m_ordered;
Vector<Vector<MessageBuffer*> > m_toNetQueues; std::vector<std::vector<MessageBuffer*> > m_toNetQueues;
Vector<Vector<MessageBuffer*> > m_fromNetQueues; std::vector<std::vector<MessageBuffer*> > m_fromNetQueues;
Vector<Router_d *> m_router_ptr_vector; // All Routers in Network std::vector<Router_d *> m_router_ptr_vector; // All Routers in Network
Vector<NetworkLink_d *> m_link_ptr_vector; // All links in the network std::vector<NetworkLink_d *> m_link_ptr_vector; // All links in the network
Vector<CreditLink_d *> m_creditlink_ptr_vector; // All links in the network std::vector<CreditLink_d *> m_creditlink_ptr_vector; // All links in the network
Vector<NetworkInterface_d *> m_ni_ptr_vector; // All NI's in Network std::vector<NetworkInterface_d *> m_ni_ptr_vector; // All NI's in Network
// Topology* m_topology_ptr; // Topology* m_topology_ptr;
Time m_ruby_start; Time m_ruby_start;

View file

@ -28,10 +28,12 @@
* Authors: Niket Agarwal * Authors: Niket Agarwal
*/ */
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
using namespace std; using namespace std;
using m5::stl_helpers::deletePointers;
InputUnit_d::InputUnit_d(int id, Router_d *router) InputUnit_d::InputUnit_d(int id, Router_d *router)
{ {
@ -44,7 +46,7 @@ InputUnit_d::InputUnit_d(int id, Router_d *router)
creditQueue = new flitBuffer_d(); creditQueue = new flitBuffer_d();
// Instantiating the virtual channels // Instantiating the virtual channels
m_vcs.setSize(m_num_vcs); m_vcs.resize(m_num_vcs);
for(int i=0; i < m_num_vcs; i++) for(int i=0; i < m_num_vcs; i++)
{ {
m_vcs[i] = new VirtualChannel_d(i); m_vcs[i] = new VirtualChannel_d(i);
@ -54,7 +56,7 @@ InputUnit_d::InputUnit_d(int id, Router_d *router)
InputUnit_d::~InputUnit_d() InputUnit_d::~InputUnit_d()
{ {
delete creditQueue; delete creditQueue;
m_vcs.deletePointers(); deletePointers(m_vcs);
} }
void InputUnit_d::wakeup() void InputUnit_d::wakeup()

View file

@ -32,11 +32,11 @@
#define INPUT_UNIT_D_H #define INPUT_UNIT_D_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
#include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Consumer.hh"
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
@ -163,7 +163,7 @@ private:
flitBuffer_d *creditQueue; flitBuffer_d *creditQueue;
// Virtual channels // Virtual channels
Vector<VirtualChannel_d *> m_vcs; // [vc] std::vector<VirtualChannel_d *> m_vcs; // [vc]
}; };
#endif #endif

View file

@ -30,11 +30,15 @@
#include <cmath> #include <cmath>
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh"
#include "mem/ruby/buffers/MessageBuffer.hh" #include "mem/ruby/buffers/MessageBuffer.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
#include "mem/ruby/slicc_interface/NetworkMessage.hh" #include "mem/ruby/slicc_interface/NetworkMessage.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwork_d *network_ptr) NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwork_d *network_ptr)
{ {
m_id = id; m_id = id;
@ -44,10 +48,10 @@ NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwo
m_num_vcs = m_vc_per_vnet*m_virtual_networks; m_num_vcs = m_vc_per_vnet*m_virtual_networks;
m_vc_round_robin = 0; m_vc_round_robin = 0;
m_ni_buffers.setSize(m_num_vcs); m_ni_buffers.resize(m_num_vcs);
m_ni_enqueue_time.setSize(m_num_vcs); m_ni_enqueue_time.resize(m_num_vcs);
inNode_ptr.setSize(m_virtual_networks); inNode_ptr.resize(m_virtual_networks);
outNode_ptr.setSize(m_virtual_networks); outNode_ptr.resize(m_virtual_networks);
creditQueue = new flitBuffer_d(); creditQueue = new flitBuffer_d();
for(int i =0; i < m_num_vcs; i++) for(int i =0; i < m_num_vcs; i++)
@ -55,7 +59,7 @@ NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwo
m_ni_buffers[i] = new flitBuffer_d(); // instantiating the NI flit buffers m_ni_buffers[i] = new flitBuffer_d(); // instantiating the NI flit buffers
m_ni_enqueue_time[i] = INFINITE_; m_ni_enqueue_time[i] = INFINITE_;
} }
m_vc_allocator.setSize(m_virtual_networks); // 1 allocator per virtual net m_vc_allocator.resize(m_virtual_networks); // 1 allocator per virtual net
for(int i = 0; i < m_virtual_networks; i++) for(int i = 0; i < m_virtual_networks; i++)
{ {
m_vc_allocator[i] = 0; m_vc_allocator[i] = 0;
@ -63,15 +67,15 @@ NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwo
for(int i = 0; i < m_num_vcs; i++) for(int i = 0; i < m_num_vcs; i++)
{ {
m_out_vc_state.insertAtBottom(new OutVcState_d(i, m_net_ptr)); m_out_vc_state.push_back(new OutVcState_d(i, m_net_ptr));
m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime());
} }
} }
NetworkInterface_d::~NetworkInterface_d() NetworkInterface_d::~NetworkInterface_d()
{ {
m_out_vc_state.deletePointers(); deletePointers(m_out_vc_state);
m_ni_buffers.deletePointers(); deletePointers(m_ni_buffers);
delete creditQueue; delete creditQueue;
delete outSrcQueue; delete outSrcQueue;
} }
@ -94,7 +98,7 @@ void NetworkInterface_d::addOutPort(NetworkLink_d *out_link, CreditLink_d *credi
out_link->setSourceQueue(outSrcQueue); out_link->setSourceQueue(outSrcQueue);
} }
void NetworkInterface_d::addNode(Vector<MessageBuffer*>& in, Vector<MessageBuffer*>& out) void NetworkInterface_d::addNode(vector<MessageBuffer*>& in, vector<MessageBuffer*>& out)
{ {
ASSERT(in.size() == m_virtual_networks); ASSERT(in.size() == m_virtual_networks);
inNode_ptr = in; inNode_ptr = in;
@ -110,7 +114,7 @@ bool NetworkInterface_d::flitisizeMessage(MsgPtr msg_ptr, int vnet)
NetworkMessage *net_msg_ptr = NetworkMessage *net_msg_ptr =
safe_cast<NetworkMessage *>(msg_ptr.get()); safe_cast<NetworkMessage *>(msg_ptr.get());
NetDest net_msg_dest = net_msg_ptr->getInternalDestination(); NetDest net_msg_dest = net_msg_ptr->getInternalDestination();
Vector<NodeID> dest_nodes = net_msg_dest.getAllDest(); // gets all the destinations associated with this message. vector<NodeID> dest_nodes = net_msg_dest.getAllDest(); // gets all the destinations associated with this message.
int num_flits = (int) ceil((double) m_net_ptr->MessageSizeType_to_int(net_msg_ptr->getMessageSize())/m_net_ptr->getFlitSize() ); // Number of flits is dependent on the link bandwidth available. This is expressed in terms of bytes/cycle or the flit size int num_flits = (int) ceil((double) m_net_ptr->MessageSizeType_to_int(net_msg_ptr->getMessageSize())/m_net_ptr->getFlitSize() ); // Number of flits is dependent on the link bandwidth available. This is expressed in terms of bytes/cycle or the flit size

View file

@ -32,10 +32,10 @@
#define NET_INTERFACE_D_H #define NET_INTERFACE_D_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/slicc_interface/Message.hh" #include "mem/ruby/slicc_interface/Message.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
@ -56,7 +56,8 @@ public:
void addOutPort(NetworkLink_d *out_link, CreditLink_d *credit_link); void addOutPort(NetworkLink_d *out_link, CreditLink_d *credit_link);
void wakeup(); void wakeup();
void addNode(Vector<MessageBuffer *> &inNode, Vector<MessageBuffer *> &outNode); void addNode(std::vector<MessageBuffer *> &inNode,
std::vector<MessageBuffer *> &outNode);
void printConfig(std::ostream& out) const; void printConfig(std::ostream& out) const;
void print(std::ostream& out) const; void print(std::ostream& out) const;
int get_vnet(int vc); int get_vnet(int vc);
@ -66,8 +67,8 @@ private:
GarnetNetwork_d *m_net_ptr; GarnetNetwork_d *m_net_ptr;
int m_virtual_networks, m_num_vcs, m_vc_per_vnet; int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
NodeID m_id; NodeID m_id;
Vector<OutVcState_d *> m_out_vc_state; std::vector<OutVcState_d *> m_out_vc_state;
Vector<int > m_vc_allocator; std::vector<int > m_vc_allocator;
int m_vc_round_robin; // For round robin scheduling int m_vc_round_robin; // For round robin scheduling
flitBuffer_d *outSrcQueue; // For modelling link contention flitBuffer_d *outSrcQueue; // For modelling link contention
flitBuffer_d *creditQueue; flitBuffer_d *creditQueue;
@ -78,11 +79,11 @@ private:
CreditLink_d *m_ni_credit_link; CreditLink_d *m_ni_credit_link;
// Input Flit Buffers // Input Flit Buffers
Vector<flitBuffer_d *> m_ni_buffers; // The flit buffers which will serve the Consumer std::vector<flitBuffer_d *> m_ni_buffers; // The flit buffers which will serve the Consumer
Vector<Time > m_ni_enqueue_time; std::vector<Time > m_ni_enqueue_time;
Vector<MessageBuffer *> inNode_ptr; // The Message buffers that takes messages from the protocol std::vector<MessageBuffer *> inNode_ptr; // The Message buffers that takes messages from the protocol
Vector<MessageBuffer *> outNode_ptr; // The Message buffers that provides messages to the protocol std::vector<MessageBuffer *> outNode_ptr; // The Message buffers that provides messages to the protocol
bool flitisizeMessage(MsgPtr msg_ptr, int vnet); bool flitisizeMessage(MsgPtr msg_ptr, int vnet);
int calculateVC(int vnet); int calculateVC(int vnet);

View file

@ -40,7 +40,7 @@ NetworkLink_d::NetworkLink_d(int id)
linkBuffer = new flitBuffer_d(); linkBuffer = new flitBuffer_d();
m_link_utilized = 0; m_link_utilized = 0;
m_vc_load.setSize(NetworkConfig::getVCsPerClass()*RubySystem::getNetwork()->getNumberOfVirtualNetworks()); m_vc_load.resize(NetworkConfig::getVCsPerClass()*RubySystem::getNetwork()->getNumberOfVirtualNetworks());
for(int i = 0; i < NetworkConfig::getVCsPerClass()*RubySystem::getNetwork()->getNumberOfVirtualNetworks(); i++) for(int i = 0; i < NetworkConfig::getVCsPerClass()*RubySystem::getNetwork()->getNumberOfVirtualNetworks(); i++)
m_vc_load[i] = 0; m_vc_load[i] = 0;
@ -53,7 +53,7 @@ NetworkLink_d::NetworkLink_d(int id, int link_latency, GarnetNetwork_d *net_ptr)
m_latency = link_latency; m_latency = link_latency;
linkBuffer = new flitBuffer_d(); linkBuffer = new flitBuffer_d();
m_link_utilized = 0; m_link_utilized = 0;
m_vc_load.setSize(m_net_ptr->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks()); m_vc_load.resize(m_net_ptr->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks());
for(int i = 0; i < m_net_ptr->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks(); i++) for(int i = 0; i < m_net_ptr->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks(); i++)
m_vc_load[i] = 0; m_vc_load[i] = 0;
@ -87,7 +87,7 @@ void NetworkLink_d::wakeup()
} }
} }
Vector<int> NetworkLink_d::getVcLoad() std::vector<int> NetworkLink_d::getVcLoad()
{ {
return m_vc_load; return m_vc_load;
} }

View file

@ -32,6 +32,7 @@
#define NETWORK_LINK_D_H #define NETWORK_LINK_D_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Consumer.hh"
@ -51,7 +52,7 @@ public:
void setSourceQueue(flitBuffer_d *srcQueue); void setSourceQueue(flitBuffer_d *srcQueue);
void print(std::ostream& out) const{} void print(std::ostream& out) const{}
int getLinkUtilization(); int getLinkUtilization();
Vector<int> getVcLoad(); std::vector<int> getVcLoad();
int get_id(){return m_id;} int get_id(){return m_id;}
void wakeup(); void wakeup();
@ -80,7 +81,7 @@ protected:
Consumer *link_consumer; Consumer *link_consumer;
flitBuffer_d *link_srcQueue; flitBuffer_d *link_srcQueue;
int m_link_utilized; int m_link_utilized;
Vector<int > m_vc_load; std::vector<int> m_vc_load;
int m_flit_width; int m_flit_width;
}; };

View file

@ -28,10 +28,12 @@
* Authors: Niket Agarwal * Authors: Niket Agarwal
*/ */
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
using namespace std; using namespace std;
using m5::stl_helpers::deletePointers;
OutputUnit_d::OutputUnit_d(int id, Router_d *router) OutputUnit_d::OutputUnit_d(int id, Router_d *router)
{ {
@ -42,14 +44,14 @@ OutputUnit_d::OutputUnit_d(int id, Router_d *router)
for(int i = 0; i < m_num_vcs; i++) for(int i = 0; i < m_num_vcs; i++)
{ {
m_outvc_state.insertAtBottom(new OutVcState_d(i, m_router->get_net_ptr())); m_outvc_state.push_back(new OutVcState_d(i, m_router->get_net_ptr()));
} }
} }
OutputUnit_d::~OutputUnit_d() OutputUnit_d::~OutputUnit_d()
{ {
delete m_out_buffer; delete m_out_buffer;
m_outvc_state.deletePointers(); deletePointers(m_outvc_state);
} }
void OutputUnit_d::decrement_credit(int out_vc) void OutputUnit_d::decrement_credit(int out_vc)

View file

@ -32,6 +32,7 @@
#define OUTPUT_UNIT_D_H #define OUTPUT_UNIT_D_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Consumer.hh"
@ -85,7 +86,7 @@ private:
CreditLink_d *m_credit_link; CreditLink_d *m_credit_link;
flitBuffer_d *m_out_buffer; // This is for the network link to consume flitBuffer_d *m_out_buffer; // This is for the network link to consume
Vector<OutVcState_d *> m_outvc_state; // vc state of downstream router std::vector<OutVcState_d *> m_outvc_state; // vc state of downstream router
}; };

View file

@ -28,6 +28,7 @@
* Authors: Niket Agarwal * Authors: Niket Agarwal
*/ */
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
@ -40,6 +41,7 @@
#include "mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh"
using namespace std; using namespace std;
using m5::stl_helpers::deletePointers;
Router_d::Router_d(int id, GarnetNetwork_d *network_ptr) Router_d::Router_d(int id, GarnetNetwork_d *network_ptr)
{ {
@ -69,8 +71,8 @@ Router_d::Router_d(int id, GarnetNetwork_d *network_ptr)
Router_d::~Router_d() Router_d::~Router_d()
{ {
m_input_unit.deletePointers(); deletePointers(m_input_unit);
m_output_unit.deletePointers(); deletePointers(m_output_unit);
delete m_routing_unit; delete m_routing_unit;
delete m_vc_alloc; delete m_vc_alloc;
delete m_sw_alloc; delete m_sw_alloc;
@ -94,7 +96,7 @@ void Router_d::addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link)
in_link->setLinkConsumer(input_unit); in_link->setLinkConsumer(input_unit);
credit_link->setSourceQueue(input_unit->getCreditQueue()); credit_link->setSourceQueue(input_unit->getCreditQueue());
m_input_unit.insertAtBottom(input_unit); m_input_unit.push_back(input_unit);
} }
void Router_d::addOutPort(NetworkLink_d *out_link, const NetDest& routing_table_entry, int link_weight, CreditLink_d *credit_link) void Router_d::addOutPort(NetworkLink_d *out_link, const NetDest& routing_table_entry, int link_weight, CreditLink_d *credit_link)
@ -107,7 +109,7 @@ void Router_d::addOutPort(NetworkLink_d *out_link, const NetDest& routing_table_
credit_link->setLinkConsumer(output_unit); credit_link->setLinkConsumer(output_unit);
out_link->setSourceQueue(output_unit->getOutQueue()); out_link->setSourceQueue(output_unit->getOutQueue());
m_output_unit.insertAtBottom(output_unit); m_output_unit.push_back(output_unit);
m_routing_unit->addRoute(routing_table_entry); m_routing_unit->addRoute(routing_table_entry);
m_routing_unit->addWeight(link_weight); m_routing_unit->addWeight(link_weight);

View file

@ -32,9 +32,9 @@
#define ROUTER_D_H #define ROUTER_D_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh"
#include "mem/ruby/common/NetDest.hh" #include "mem/ruby/common/NetDest.hh"
#include "mem/ruby/network/orion/power_router_init.hh" #include "mem/ruby/network/orion/power_router_init.hh"
@ -66,8 +66,8 @@ public:
int get_id() { return m_id; } int get_id() { return m_id; }
GarnetNetwork_d* get_net_ptr() { return m_network_ptr; } GarnetNetwork_d* get_net_ptr() { return m_network_ptr; }
Vector<InputUnit_d *>& get_inputUnit_ref() { return m_input_unit; } std::vector<InputUnit_d *>& get_inputUnit_ref() { return m_input_unit; }
Vector<OutputUnit_d *>& get_outputUnit_ref() { return m_output_unit; } std::vector<OutputUnit_d *>& get_outputUnit_ref() { return m_output_unit; }
void update_sw_winner(int inport, flit_d *t_flit); void update_sw_winner(int inport, flit_d *t_flit);
void update_incredit(int in_port, int in_vc, int credit); void update_incredit(int in_port, int in_vc, int credit);
@ -88,8 +88,8 @@ private:
double buf_read_count, buf_write_count, crossbar_count, vc_local_arbit_count, vc_global_arbit_count, sw_local_arbit_count, sw_global_arbit_count; double buf_read_count, buf_write_count, crossbar_count, vc_local_arbit_count, vc_global_arbit_count, sw_local_arbit_count, sw_global_arbit_count;
Vector<InputUnit_d *> m_input_unit; std::vector<InputUnit_d *> m_input_unit;
Vector<OutputUnit_d *> m_output_unit; std::vector<OutputUnit_d *> m_output_unit;
RoutingUnit_d *m_routing_unit; RoutingUnit_d *m_routing_unit;
VCallocator_d *m_vc_alloc; VCallocator_d *m_vc_alloc;
SWallocator_d *m_sw_alloc; SWallocator_d *m_sw_alloc;

View file

@ -42,12 +42,12 @@ RoutingUnit_d::RoutingUnit_d(Router_d *router)
void RoutingUnit_d::addRoute(const NetDest& routing_table_entry) void RoutingUnit_d::addRoute(const NetDest& routing_table_entry)
{ {
m_routing_table.insertAtBottom(routing_table_entry); m_routing_table.push_back(routing_table_entry);
} }
void RoutingUnit_d::addWeight(int link_weight) void RoutingUnit_d::addWeight(int link_weight)
{ {
m_weight_table.insertAtBottom(link_weight); m_weight_table.push_back(link_weight);
} }
void RoutingUnit_d::RC_stage(flit_d *t_flit, InputUnit_d *in_unit, int invc) void RoutingUnit_d::RC_stage(flit_d *t_flit, InputUnit_d *in_unit, int invc)

View file

@ -49,8 +49,8 @@ public:
private: private:
Router_d *m_router; Router_d *m_router;
Vector<NetDest > m_routing_table; std::vector<NetDest > m_routing_table;
Vector<int > m_weight_table; std::vector<int > m_weight_table;
}; };
#endif #endif

View file

@ -51,10 +51,10 @@ void SWallocator_d::init()
m_num_inports = m_router->get_num_inports(); m_num_inports = m_router->get_num_inports();
m_num_outports = m_router->get_num_outports(); m_num_outports = m_router->get_num_outports();
m_round_robin_outport.setSize(m_num_outports); m_round_robin_outport.resize(m_num_outports);
m_round_robin_inport.setSize(m_num_inports); m_round_robin_inport.resize(m_num_inports);
m_port_req.setSize(m_num_outports); m_port_req.resize(m_num_outports);
m_vc_winners.setSize(m_num_outports); m_vc_winners.resize(m_num_outports);
for(int i = 0; i < m_num_inports; i++) for(int i = 0; i < m_num_inports; i++)
{ {
@ -63,8 +63,8 @@ void SWallocator_d::init()
for(int i = 0; i < m_num_outports; i++) for(int i = 0; i < m_num_outports; i++)
{ {
m_port_req[i].setSize(m_num_inports); m_port_req[i].resize(m_num_inports);
m_vc_winners[i].setSize(m_num_inports); m_vc_winners[i].resize(m_num_inports);
m_round_robin_outport[i] = 0; m_round_robin_outport[i] = 0;

View file

@ -32,6 +32,7 @@
#define SW_ALLOCATOR_D_H #define SW_ALLOCATOR_D_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Consumer.hh"
@ -68,12 +69,12 @@ private:
double m_local_arbiter_activity, m_global_arbiter_activity; double m_local_arbiter_activity, m_global_arbiter_activity;
Router_d *m_router; Router_d *m_router;
Vector<int > m_round_robin_outport; std::vector<int> m_round_robin_outport;
Vector<int > m_round_robin_inport; std::vector<int> m_round_robin_inport;
Vector<Vector<bool > > m_port_req; std::vector<std::vector<bool> > m_port_req;
Vector<Vector<int > > m_vc_winners; // a list for each outport std::vector<std::vector<int> > m_vc_winners; // a list for each outport
Vector<InputUnit_d *> m_input_unit; std::vector<InputUnit_d *> m_input_unit;
Vector<OutputUnit_d *> m_output_unit; std::vector<OutputUnit_d *> m_output_unit;
}; };
#endif #endif

View file

@ -28,10 +28,13 @@
* Authors: Niket Agarwal * Authors: Niket Agarwal
*/ */
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
using m5::stl_helpers::deletePointers;
Switch_d::Switch_d(Router_d *router) Switch_d::Switch_d(Router_d *router)
{ {
m_router = router; m_router = router;
@ -41,7 +44,7 @@ Switch_d::Switch_d(Router_d *router)
Switch_d::~Switch_d() Switch_d::~Switch_d()
{ {
m_switch_buffer.deletePointers(); deletePointers(m_switch_buffer);
} }
void Switch_d::init() void Switch_d::init()
@ -49,7 +52,7 @@ void Switch_d::init()
m_output_unit = m_router->get_outputUnit_ref(); m_output_unit = m_router->get_outputUnit_ref();
m_num_inports = m_router->get_num_inports(); m_num_inports = m_router->get_num_inports();
m_switch_buffer.setSize(m_num_inports); m_switch_buffer.resize(m_num_inports);
for(int i = 0; i < m_num_inports; i++) for(int i = 0; i < m_num_inports; i++)
{ {
m_switch_buffer[i] = new flitBuffer_d(); m_switch_buffer[i] = new flitBuffer_d();

View file

@ -32,6 +32,7 @@
#define SWITCH_D_H #define SWITCH_D_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Consumer.hh"
@ -63,8 +64,8 @@ private:
int m_num_inports; int m_num_inports;
double m_crossbar_activity; double m_crossbar_activity;
Router_d *m_router; Router_d *m_router;
Vector<flitBuffer_d *> m_switch_buffer; std::vector<flitBuffer_d *> m_switch_buffer;
Vector<OutputUnit_d *> m_output_unit; std::vector<OutputUnit_d *> m_output_unit;
}; };
#endif #endif

View file

@ -50,14 +50,14 @@ void VCallocator_d::init()
m_num_inports = m_router->get_num_inports(); m_num_inports = m_router->get_num_inports();
m_num_outports = m_router->get_num_outports(); m_num_outports = m_router->get_num_outports();
m_round_robin_invc.setSize(m_num_inports); m_round_robin_invc.resize(m_num_inports);
m_round_robin_outvc.setSize(m_num_outports); m_round_robin_outvc.resize(m_num_outports);
m_outvc_req.setSize(m_num_outports); m_outvc_req.resize(m_num_outports);
m_outvc_is_req.setSize(m_num_outports); m_outvc_is_req.resize(m_num_outports);
for(int i = 0; i < m_num_inports; i++) for(int i = 0; i < m_num_inports; i++)
{ {
m_round_robin_invc[i].setSize(m_num_vcs); m_round_robin_invc[i].resize(m_num_vcs);
for(int j = 0; j < m_num_vcs; j++) for(int j = 0; j < m_num_vcs; j++)
{ {
@ -67,9 +67,9 @@ void VCallocator_d::init()
for(int i = 0; i < m_num_outports; i++) for(int i = 0; i < m_num_outports; i++)
{ {
m_round_robin_outvc[i].setSize(m_num_vcs); m_round_robin_outvc[i].resize(m_num_vcs);
m_outvc_req[i].setSize(m_num_vcs); m_outvc_req[i].resize(m_num_vcs);
m_outvc_is_req[i].setSize(m_num_vcs); m_outvc_is_req[i].resize(m_num_vcs);
for(int j = 0; j < m_num_vcs; j++) for(int j = 0; j < m_num_vcs; j++)
{ {
@ -77,11 +77,11 @@ void VCallocator_d::init()
m_round_robin_outvc[i][j].second = 0; m_round_robin_outvc[i][j].second = 0;
m_outvc_is_req[i][j] = false; m_outvc_is_req[i][j] = false;
m_outvc_req[i][j].setSize(m_num_inports); m_outvc_req[i][j].resize(m_num_inports);
for(int k = 0; k < m_num_inports; k++) for(int k = 0; k < m_num_inports; k++)
{ {
m_outvc_req[i][j][k].setSize(m_num_vcs); m_outvc_req[i][j][k].resize(m_num_vcs);
for(int l = 0; l < m_num_vcs; l++) for(int l = 0; l < m_num_vcs; l++)
{ {
m_outvc_req[i][j][k][l] = false; m_outvc_req[i][j][k][l] = false;

View file

@ -32,6 +32,7 @@
#define VC_ALLOCATOR_D_H #define VC_ALLOCATOR_D_H
#include <iostream> #include <iostream>
#include <vector>
#include <utility> #include <utility>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
@ -71,13 +72,13 @@ private:
double m_local_arbiter_activity, m_global_arbiter_activity; double m_local_arbiter_activity, m_global_arbiter_activity;
Router_d *m_router; Router_d *m_router;
Vector<Vector <int > > m_round_robin_invc; // First stage of arbitration where all vcs select an output vc to content for std::vector<std::vector<int > > m_round_robin_invc; // First stage of arbitration where all vcs select an output vc to content for
Vector<Vector <std::pair<int, int> > > m_round_robin_outvc; // Arbiter for every output vc std::vector<std::vector<std::pair<int, int> > > m_round_robin_outvc; // Arbiter for every output vc
Vector<Vector<Vector<Vector<bool > > > > m_outvc_req; // [outport][outvc][inpotr][invc]. set true in the first phase of allocation std::vector<std::vector<std::vector<std::vector<bool> > > > m_outvc_req; // [outport][outvc][inpotr][invc]. set true in the first phase of allocation
Vector<Vector<bool > > m_outvc_is_req; std::vector<std::vector<bool> > m_outvc_is_req;
Vector<InputUnit_d *> m_input_unit ; std::vector<InputUnit_d *> m_input_unit ;
Vector<OutputUnit_d *> m_output_unit ; std::vector<OutputUnit_d *> m_output_unit ;
}; };

View file

@ -28,6 +28,7 @@
* Authors: Niket Agarwal * Authors: Niket Agarwal
*/ */
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh" #include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
#include "mem/protocol/MachineType.hh" #include "mem/protocol/MachineType.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh" #include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh"
@ -40,6 +41,7 @@
#include "mem/ruby/common/NetDest.hh" #include "mem/ruby/common/NetDest.hh"
using namespace std; using namespace std;
using m5::stl_helpers::deletePointers;
GarnetNetwork::GarnetNetwork(const Params *p) GarnetNetwork::GarnetNetwork(const Params *p)
: BaseGarnetNetwork(p) : BaseGarnetNetwork(p)
@ -47,10 +49,10 @@ GarnetNetwork::GarnetNetwork(const Params *p)
m_ruby_start = 0; m_ruby_start = 0;
// Allocate to and from queues // Allocate to and from queues
m_toNetQueues.setSize(m_nodes); // Queues that are getting messages from protocol m_toNetQueues.resize(m_nodes); // Queues that are getting messages from protocol
m_fromNetQueues.setSize(m_nodes); // Queues that are feeding the protocol m_fromNetQueues.resize(m_nodes); // Queues that are feeding the protocol
m_in_use.setSize(m_virtual_networks); m_in_use.resize(m_virtual_networks);
m_ordered.setSize(m_virtual_networks); m_ordered.resize(m_virtual_networks);
for (int i = 0; i < m_virtual_networks; i++) for (int i = 0; i < m_virtual_networks; i++)
{ {
m_in_use[i] = false; m_in_use[i] = false;
@ -60,8 +62,8 @@ GarnetNetwork::GarnetNetwork(const Params *p)
for (int node = 0; node < m_nodes; node++) for (int node = 0; node < m_nodes; node++)
{ {
//Setting how many vitual message buffers will there be per Network Queue //Setting how many vitual message buffers will there be per Network Queue
m_toNetQueues[node].setSize(m_virtual_networks); m_toNetQueues[node].resize(m_virtual_networks);
m_fromNetQueues[node].setSize(m_virtual_networks); m_fromNetQueues[node].resize(m_virtual_networks);
for (int j = 0; j < m_virtual_networks; j++) for (int j = 0; j < m_virtual_networks; j++)
{ {
@ -80,13 +82,13 @@ void GarnetNetwork::init()
int number_of_routers = m_topology_ptr->numSwitches(); int number_of_routers = m_topology_ptr->numSwitches();
for (int i=0; i<number_of_routers; i++) { for (int i=0; i<number_of_routers; i++) {
m_router_ptr_vector.insertAtBottom(new Router(i, this)); m_router_ptr_vector.push_back(new Router(i, this));
} }
for (int i=0; i < m_nodes; i++) { for (int i=0; i < m_nodes; i++) {
NetworkInterface *ni = new NetworkInterface(i, m_virtual_networks, this); NetworkInterface *ni = new NetworkInterface(i, m_virtual_networks, this);
ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]); ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]);
m_ni_ptr_vector.insertAtBottom(ni); m_ni_ptr_vector.push_back(ni);
} }
m_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration m_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration
} }
@ -95,12 +97,12 @@ GarnetNetwork::~GarnetNetwork()
{ {
for (int i = 0; i < m_nodes; i++) for (int i = 0; i < m_nodes; i++)
{ {
m_toNetQueues[i].deletePointers(); deletePointers(m_toNetQueues[i]);
m_fromNetQueues[i].deletePointers(); deletePointers(m_fromNetQueues[i]);
} }
m_router_ptr_vector.deletePointers(); deletePointers(m_router_ptr_vector);
m_ni_ptr_vector.deletePointers(); deletePointers(m_ni_ptr_vector);
m_link_ptr_vector.deletePointers(); deletePointers(m_link_ptr_vector);
delete m_topology_ptr; delete m_topology_ptr;
} }
@ -123,7 +125,7 @@ void GarnetNetwork::makeInLink(NodeID src, SwitchID dest, const NetDest& routing
if(!isReconfiguration) if(!isReconfiguration)
{ {
NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this); NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this);
m_link_ptr_vector.insertAtBottom(net_link); m_link_ptr_vector.push_back(net_link);
m_router_ptr_vector[dest]->addInPort(net_link); m_router_ptr_vector[dest]->addInPort(net_link);
m_ni_ptr_vector[src]->addOutPort(net_link); m_ni_ptr_vector[src]->addOutPort(net_link);
} }
@ -143,7 +145,7 @@ void GarnetNetwork::makeOutLink(SwitchID src, NodeID dest, const NetDest& routin
if(!isReconfiguration) if(!isReconfiguration)
{ {
NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this); NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this);
m_link_ptr_vector.insertAtBottom(net_link); m_link_ptr_vector.push_back(net_link);
m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight); m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight);
m_ni_ptr_vector[dest]->addInPort(net_link); m_ni_ptr_vector[dest]->addInPort(net_link);
} }
@ -159,7 +161,7 @@ void GarnetNetwork::makeInternalLink(SwitchID src, SwitchID dest, const NetDest&
if(!isReconfiguration) if(!isReconfiguration)
{ {
NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this); NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this);
m_link_ptr_vector.insertAtBottom(net_link); m_link_ptr_vector.push_back(net_link);
m_router_ptr_vector[dest]->addInPort(net_link); m_router_ptr_vector[dest]->addInPort(net_link);
m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight); m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight);
} }
@ -208,8 +210,8 @@ Time GarnetNetwork::getRubyStartTime()
void GarnetNetwork::printStats(ostream& out) const void GarnetNetwork::printStats(ostream& out) const
{ double average_link_utilization = 0; { double average_link_utilization = 0;
Vector<double > average_vc_load; std::vector<double> average_vc_load;
average_vc_load.setSize(m_virtual_networks*m_vcs_per_class); average_vc_load.resize(m_virtual_networks*m_vcs_per_class);
for(int i = 0; i < m_virtual_networks*m_vcs_per_class; i++) for(int i = 0; i < m_virtual_networks*m_vcs_per_class; i++)
{ {
@ -223,7 +225,7 @@ void GarnetNetwork::printStats(ostream& out) const
for(int i = 0; i < m_link_ptr_vector.size(); i++) for(int i = 0; i < m_link_ptr_vector.size(); i++)
{ {
average_link_utilization += m_link_ptr_vector[i]->getLinkUtilization(); average_link_utilization += m_link_ptr_vector[i]->getLinkUtilization();
Vector<int > vc_load = m_link_ptr_vector[i]->getVcLoad(); std::vector<int> vc_load = m_link_ptr_vector[i]->getVcLoad();
for(int j = 0; j < vc_load.size(); j++) for(int j = 0; j < vc_load.size(); j++)
{ {
assert(vc_load.size() == m_vcs_per_class*m_virtual_networks); assert(vc_load.size() == m_vcs_per_class*m_virtual_networks);

View file

@ -32,10 +32,10 @@
#define GARNET_NETWORK_H #define GARNET_NETWORK_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh" #include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/network/Network.hh" #include "mem/ruby/network/Network.hh"
#include "params/GarnetNetwork.hh" #include "params/GarnetNetwork.hh"
@ -89,15 +89,15 @@ private:
// int m_virtual_networks; // int m_virtual_networks;
// int m_nodes; // int m_nodes;
Vector<bool> m_in_use; std::vector<bool> m_in_use;
Vector<bool> m_ordered; std::vector<bool> m_ordered;
Vector<Vector<MessageBuffer*> > m_toNetQueues; std::vector<std::vector<MessageBuffer*> > m_toNetQueues;
Vector<Vector<MessageBuffer*> > m_fromNetQueues; std::vector<std::vector<MessageBuffer*> > m_fromNetQueues;
Vector<Router *> m_router_ptr_vector; // All Routers in Network std::vector<Router *> m_router_ptr_vector; // All Routers in Network
Vector<NetworkLink *> m_link_ptr_vector; // All links in the network std::vector<NetworkLink *> m_link_ptr_vector; // All links in the network
Vector<NetworkInterface *> m_ni_ptr_vector; // All NI's in Network std::vector<NetworkInterface *> m_ni_ptr_vector; // All NI's in Network
// Topology* m_topology_ptr; // Topology* m_topology_ptr;
Time m_ruby_start; Time m_ruby_start;

View file

@ -30,11 +30,15 @@
#include <cmath> #include <cmath>
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh" #include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh"
#include "mem/ruby/buffers/MessageBuffer.hh" #include "mem/ruby/buffers/MessageBuffer.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh" #include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh"
#include "mem/ruby/slicc_interface/NetworkMessage.hh" #include "mem/ruby/slicc_interface/NetworkMessage.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
NetworkInterface::NetworkInterface(int id, int virtual_networks, GarnetNetwork *network_ptr) NetworkInterface::NetworkInterface(int id, int virtual_networks, GarnetNetwork *network_ptr)
{ {
m_id = id; m_id = id;
@ -44,14 +48,14 @@ NetworkInterface::NetworkInterface(int id, int virtual_networks, GarnetNetwork *
m_num_vcs = m_vc_per_vnet*m_virtual_networks; m_num_vcs = m_vc_per_vnet*m_virtual_networks;
m_vc_round_robin = 0; m_vc_round_robin = 0;
m_ni_buffers.setSize(m_num_vcs); m_ni_buffers.resize(m_num_vcs);
inNode_ptr.setSize(m_virtual_networks); inNode_ptr.resize(m_virtual_networks);
outNode_ptr.setSize(m_virtual_networks); outNode_ptr.resize(m_virtual_networks);
for(int i =0; i < m_num_vcs; i++) for(int i =0; i < m_num_vcs; i++)
m_ni_buffers[i] = new flitBuffer(); // instantiating the NI flit buffers m_ni_buffers[i] = new flitBuffer(); // instantiating the NI flit buffers
m_vc_allocator.setSize(m_virtual_networks); m_vc_allocator.resize(m_virtual_networks);
for(int i = 0; i < m_virtual_networks; i++) for(int i = 0; i < m_virtual_networks; i++)
{ {
m_vc_allocator[i] = 0; m_vc_allocator[i] = 0;
@ -59,15 +63,15 @@ NetworkInterface::NetworkInterface(int id, int virtual_networks, GarnetNetwork *
for(int i = 0; i < m_num_vcs; i++) for(int i = 0; i < m_num_vcs; i++)
{ {
m_out_vc_state.insertAtBottom(new OutVcState(i)); m_out_vc_state.push_back(new OutVcState(i));
m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime());
} }
} }
NetworkInterface::~NetworkInterface() NetworkInterface::~NetworkInterface()
{ {
m_out_vc_state.deletePointers(); deletePointers(m_out_vc_state);
m_ni_buffers.deletePointers(); deletePointers(m_ni_buffers);
delete outSrcQueue; delete outSrcQueue;
} }
@ -85,7 +89,7 @@ void NetworkInterface::addOutPort(NetworkLink *out_link)
out_link->setSource(this); out_link->setSource(this);
} }
void NetworkInterface::addNode(Vector<MessageBuffer*>& in, Vector<MessageBuffer*>& out) void NetworkInterface::addNode(vector<MessageBuffer*>& in, vector<MessageBuffer*>& out)
{ {
ASSERT(in.size() == m_virtual_networks); ASSERT(in.size() == m_virtual_networks);
inNode_ptr = in; inNode_ptr = in;
@ -106,7 +110,7 @@ bool NetworkInterface::flitisizeMessage(MsgPtr msg_ptr, int vnet)
NetworkMessage *net_msg_ptr = NetworkMessage *net_msg_ptr =
safe_cast<NetworkMessage*>(msg_ptr.get()); safe_cast<NetworkMessage*>(msg_ptr.get());
NetDest net_msg_dest = net_msg_ptr->getInternalDestination(); NetDest net_msg_dest = net_msg_ptr->getInternalDestination();
Vector<NodeID> dest_nodes = net_msg_dest.getAllDest(); // gets all the destinations associated with this message. vector<NodeID> dest_nodes = net_msg_dest.getAllDest(); // gets all the destinations associated with this message.
int num_flits = (int) ceil((double) m_net_ptr->MessageSizeType_to_int(net_msg_ptr->getMessageSize())/m_net_ptr->getFlitSize() ); // Number of flits is dependent on the link bandwidth available. This is expressed in terms of bytes/cycle or the flit size int num_flits = (int) ceil((double) m_net_ptr->MessageSizeType_to_int(net_msg_ptr->getMessageSize())/m_net_ptr->getFlitSize() ); // Number of flits is dependent on the link bandwidth available. This is expressed in terms of bytes/cycle or the flit size
for(int ctr = 0; ctr < dest_nodes.size(); ctr++) // loop because we will be converting all multicast messages into unicast messages for(int ctr = 0; ctr < dest_nodes.size(); ctr++) // loop because we will be converting all multicast messages into unicast messages

View file

@ -32,10 +32,10 @@
#define NET_INTERFACE_H #define NET_INTERFACE_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh" #include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh" #include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh"
#include "mem/ruby/slicc_interface/Message.hh" #include "mem/ruby/slicc_interface/Message.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh" #include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
@ -55,7 +55,7 @@ public:
void addOutPort(NetworkLink *out_link); void addOutPort(NetworkLink *out_link);
void wakeup(); void wakeup();
void addNode(Vector<MessageBuffer *> &inNode, Vector<MessageBuffer *> &outNode); void addNode(std::vector<MessageBuffer *> &inNode, std::vector<MessageBuffer *> &outNode);
void grant_vc(int out_port, int vc, Time grant_time); void grant_vc(int out_port, int vc, Time grant_time);
void release_vc(int out_port, int vc, Time release_time); void release_vc(int out_port, int vc, Time release_time);
bool isBufferNotFull(int vc, int inport) bool isBufferNotFull(int vc, int inport)
@ -73,8 +73,8 @@ private:
int m_virtual_networks, m_num_vcs, m_vc_per_vnet; int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
NodeID m_id; NodeID m_id;
Vector<OutVcState *> m_out_vc_state; std::vector<OutVcState *> m_out_vc_state;
Vector<int > m_vc_allocator; std::vector<int> m_vc_allocator;
int m_vc_round_robin; // For round robin scheduling int m_vc_round_robin; // For round robin scheduling
flitBuffer *outSrcQueue; // For modelling link contention flitBuffer *outSrcQueue; // For modelling link contention
@ -82,10 +82,10 @@ private:
NetworkLink *outNetLink; NetworkLink *outNetLink;
// Input Flit Buffers // Input Flit Buffers
Vector<flitBuffer *> m_ni_buffers; // The flit buffers which will serve the Consumer std::vector<flitBuffer *> m_ni_buffers; // The flit buffers which will serve the Consumer
Vector<MessageBuffer *> inNode_ptr; // The Message buffers that takes messages from the protocol std::vector<MessageBuffer *> inNode_ptr; // The Message buffers that takes messages from the protocol
Vector<MessageBuffer *> outNode_ptr; // The Message buffers that provides messages to the protocol std::vector<MessageBuffer *> outNode_ptr; // The Message buffers that provides messages to the protocol
bool flitisizeMessage(MsgPtr msg_ptr, int vnet); bool flitisizeMessage(MsgPtr msg_ptr, int vnet);
int calculateVC(int vnet); int calculateVC(int vnet);

View file

@ -42,7 +42,7 @@ NetworkLink::NetworkLink(int id, int latency, GarnetNetwork *net_ptr)
m_latency = latency; m_latency = latency;
int num_net = net_ptr->getNumberOfVirtualNetworks(); int num_net = net_ptr->getNumberOfVirtualNetworks();
int num_vc = m_net_ptr->getVCsPerClass(); int num_vc = m_net_ptr->getVCsPerClass();
m_vc_load.setSize(num_net*num_vc); m_vc_load.resize(num_net * num_vc);
for(int i = 0; i < num_net*num_vc; i++) for(int i = 0; i < num_net*num_vc; i++)
m_vc_load[i] = 0; m_vc_load[i] = 0;
@ -91,7 +91,7 @@ void NetworkLink::release_vc_link(int vc, Time release_time)
link_source->release_vc(m_out_port, vc, release_time); link_source->release_vc(m_out_port, vc, release_time);
} }
Vector<int> NetworkLink::getVcLoad() std::vector<int> NetworkLink::getVcLoad()
{ {
return m_vc_load; return m_vc_load;
} }

View file

@ -32,6 +32,7 @@
#define NETWORK_LINK_H #define NETWORK_LINK_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh" #include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh"
@ -67,13 +68,13 @@ public:
bool isBufferNotFull_link(int vc); bool isBufferNotFull_link(int vc);
void setSource(FlexibleConsumer *source); void setSource(FlexibleConsumer *source);
double getLinkUtilization(); double getLinkUtilization();
Vector<int> getVcLoad(); std::vector<int> getVcLoad();
protected: protected:
int m_id, m_latency; int m_id, m_latency;
int m_in_port, m_out_port; int m_in_port, m_out_port;
int m_link_utilized; int m_link_utilized;
Vector<int > m_vc_load; std::vector<int> m_vc_load;
GarnetNetwork *m_net_ptr; GarnetNetwork *m_net_ptr;
flitBuffer *linkBuffer; flitBuffer *linkBuffer;

View file

@ -28,6 +28,7 @@
* Authors: Niket Agarwal * Authors: Niket Agarwal
*/ */
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/Router.hh" #include "mem/ruby/network/garnet/flexible-pipeline/Router.hh"
#include "mem/ruby/slicc_interface/NetworkMessage.hh" #include "mem/ruby/slicc_interface/NetworkMessage.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/InVcState.hh" #include "mem/ruby/network/garnet/flexible-pipeline/InVcState.hh"
@ -35,6 +36,7 @@
#include "mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh" #include "mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh"
using namespace std; using namespace std;
using m5::stl_helpers::deletePointers;
Router::Router(int id, GarnetNetwork *network_ptr) Router::Router(int id, GarnetNetwork *network_ptr)
{ {
@ -52,14 +54,14 @@ Router::~Router()
{ {
for (int i = 0; i < m_in_link.size(); i++) for (int i = 0; i < m_in_link.size(); i++)
{ {
m_in_vc_state[i].deletePointers(); deletePointers(m_in_vc_state[i]);
} }
for (int i = 0; i < m_out_link.size(); i++) for (int i = 0; i < m_out_link.size(); i++)
{ {
m_out_vc_state[i].deletePointers(); deletePointers(m_out_vc_state[i]);
m_router_buffers[i].deletePointers(); deletePointers(m_router_buffers[i]);
} }
m_out_src_queue.deletePointers(); deletePointers(m_out_src_queue);
delete m_vc_arbiter; delete m_vc_arbiter;
} }
@ -67,19 +69,19 @@ Router::~Router()
void Router::addInPort(NetworkLink *in_link) void Router::addInPort(NetworkLink *in_link)
{ {
int port = m_in_link.size(); int port = m_in_link.size();
Vector<InVcState *> in_vc_vector; vector<InVcState *> in_vc_vector;
for(int i = 0; i < m_num_vcs; i++) for(int i = 0; i < m_num_vcs; i++)
{ {
in_vc_vector.insertAtBottom(new InVcState(i)); in_vc_vector.push_back(new InVcState(i));
in_vc_vector[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); in_vc_vector[i]->setState(IDLE_, g_eventQueue_ptr->getTime());
} }
m_in_vc_state.insertAtBottom(in_vc_vector); m_in_vc_state.push_back(in_vc_vector);
m_in_link.insertAtBottom(in_link); m_in_link.push_back(in_link);
in_link->setLinkConsumer(this); in_link->setLinkConsumer(this);
in_link->setInPort(port); in_link->setInPort(port);
int start = 0; int start = 0;
m_round_robin_invc.insertAtBottom(start); m_round_robin_invc.push_back(start);
} }
@ -88,30 +90,30 @@ void Router::addOutPort(NetworkLink *out_link, const NetDest& routing_table_entr
int port = m_out_link.size(); int port = m_out_link.size();
out_link->setOutPort(port); out_link->setOutPort(port);
int start = 0; int start = 0;
m_vc_round_robin.insertAtBottom(start); m_vc_round_robin.push_back(start);
m_out_src_queue.insertAtBottom(new flitBuffer()); m_out_src_queue.push_back(new flitBuffer());
m_out_link.insertAtBottom(out_link); m_out_link.push_back(out_link);
m_routing_table.insertAtBottom(routing_table_entry); m_routing_table.push_back(routing_table_entry);
out_link->setSourceQueue(m_out_src_queue[port]); out_link->setSourceQueue(m_out_src_queue[port]);
out_link->setSource(this); out_link->setSource(this);
Vector<flitBuffer *> intermediateQueues; vector<flitBuffer *> intermediateQueues;
for(int i = 0; i < m_num_vcs; i++) for(int i = 0; i < m_num_vcs; i++)
{ {
intermediateQueues.insertAtBottom(new flitBuffer(m_net_ptr->getBufferSize())); intermediateQueues.push_back(new flitBuffer(m_net_ptr->getBufferSize()));
} }
m_router_buffers.insertAtBottom(intermediateQueues); m_router_buffers.push_back(intermediateQueues);
Vector<OutVcState *> out_vc_vector; vector<OutVcState *> out_vc_vector;
for(int i = 0; i < m_num_vcs; i++) for(int i = 0; i < m_num_vcs; i++)
{ {
out_vc_vector.insertAtBottom(new OutVcState(i)); out_vc_vector.push_back(new OutVcState(i));
out_vc_vector[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); out_vc_vector[i]->setState(IDLE_, g_eventQueue_ptr->getTime());
} }
m_out_vc_state.insertAtBottom(out_vc_vector); m_out_vc_state.push_back(out_vc_vector);
m_link_weights.insertAtBottom(link_weight); m_link_weights.push_back(link_weight);
} }
bool Router::isBufferNotFull(int vc, int inport) bool Router::isBufferNotFull(int vc, int inport)
@ -164,7 +166,7 @@ void Router::vc_arbitrate()
if(in_vc_state->isInState(VC_AB_, g_eventQueue_ptr->getTime())) if(in_vc_state->isInState(VC_AB_, g_eventQueue_ptr->getTime()))
{ {
int outport = in_vc_state->get_outport(); int outport = in_vc_state->get_outport();
Vector<int > valid_vcs = get_valid_vcs(invc); vector<int> valid_vcs = get_valid_vcs(invc);
for(int valid_vc_iter = 0; valid_vc_iter < valid_vcs.size(); valid_vc_iter++) for(int valid_vc_iter = 0; valid_vc_iter < valid_vcs.size(); valid_vc_iter++)
{ {
if(m_out_vc_state[outport][valid_vcs[valid_vc_iter]]->isInState(IDLE_, g_eventQueue_ptr->getTime())) if(m_out_vc_state[outport][valid_vcs[valid_vc_iter]]->isInState(IDLE_, g_eventQueue_ptr->getTime()))
@ -180,9 +182,9 @@ void Router::vc_arbitrate()
} }
} }
Vector<int > Router::get_valid_vcs(int invc) vector<int> Router::get_valid_vcs(int invc)
{ {
Vector<int > vc_list; vector<int> vc_list;
for(int vnet = 0; vnet < m_virtual_networks; vnet++) for(int vnet = 0; vnet < m_virtual_networks; vnet++)
{ {
@ -197,7 +199,7 @@ Vector<int > Router::get_valid_vcs(int invc)
for(int offset = 0; offset < vc_per_vnet; offset++) for(int offset = 0; offset < vc_per_vnet; offset++)
{ {
vc_list.insertAtBottom(base+offset); vc_list.push_back(base+offset);
} }
break; break;
} }

View file

@ -32,6 +32,7 @@
#define ROUTER_H #define ROUTER_H
#include <iostream> #include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh" #include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
@ -68,23 +69,23 @@ private:
int m_id; int m_id;
int m_virtual_networks, m_num_vcs, m_vc_per_vnet; int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
GarnetNetwork *m_net_ptr; GarnetNetwork *m_net_ptr;
Vector<int > m_vc_round_robin; // For scheduling of out source queues std::vector<int> m_vc_round_robin; // For scheduling of out source queues
int m_round_robin_inport, m_round_robin_start; // for vc arbitration int m_round_robin_inport, m_round_robin_start; // for vc arbitration
Vector<int > m_round_robin_invc; // For every outport. for vc arbitration std::vector<int> m_round_robin_invc; // For every outport. for vc arbitration
Vector<Vector<flitBuffer *> > m_router_buffers; // These are essentially output buffers std::vector<std::vector<flitBuffer *> > m_router_buffers; // These are essentially output buffers
Vector<flitBuffer *> m_out_src_queue; // These are source queues for the output link std::vector<flitBuffer *> m_out_src_queue; // These are source queues for the output link
Vector<NetworkLink *> m_in_link; std::vector<NetworkLink *> m_in_link;
Vector<NetworkLink *> m_out_link; std::vector<NetworkLink *> m_out_link;
Vector<Vector<InVcState * > > m_in_vc_state; std::vector<std::vector<InVcState *> > m_in_vc_state;
Vector<Vector<OutVcState * > > m_out_vc_state; std::vector<std::vector<OutVcState *> > m_out_vc_state;
Vector<NetDest> m_routing_table; std::vector<NetDest> m_routing_table;
Vector<int > m_link_weights; std::vector<int> m_link_weights;
VCarbiter *m_vc_arbiter; VCarbiter *m_vc_arbiter;
/*********** Private methods *************/ /*********** Private methods *************/
int getRoute(NetDest destination); int getRoute(NetDest destination);
Vector<int > get_valid_vcs(int invc); std::vector<int> get_valid_vcs(int invc);
void routeCompute(flit *m_flit, int inport); void routeCompute(flit *m_flit, int inport);
void checkReschedule(); void checkReschedule();
void check_arbiter_reschedule(); void check_arbiter_reschedule();

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 <algorithm>
#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"
@ -55,11 +57,11 @@ PerfectSwitch::PerfectSwitch(SwitchID sid, SimpleNetwork* network_ptr)
} }
void void
PerfectSwitch::addInPort(const Vector<MessageBuffer*>& in) PerfectSwitch::addInPort(const vector<MessageBuffer*>& in)
{ {
assert(in.size() == m_virtual_networks); assert(in.size() == m_virtual_networks);
NodeID port = m_in.size(); NodeID port = m_in.size();
m_in.insertAtBottom(in); m_in.push_back(in);
for (int j = 0; j < m_virtual_networks; j++) { for (int j = 0; j < m_virtual_networks; j++) {
m_in[port][j]->setConsumer(this); m_in[port][j]->setConsumer(this);
string desc = csprintf("[Queue from port %s %s %s to PerfectSwitch]", string desc = csprintf("[Queue from port %s %s %s to PerfectSwitch]",
@ -70,7 +72,7 @@ PerfectSwitch::addInPort(const Vector<MessageBuffer*>& in)
} }
void void
PerfectSwitch::addOutPort(const Vector<MessageBuffer*>& out, PerfectSwitch::addOutPort(const vector<MessageBuffer*>& out,
const NetDest& routing_table_entry) const NetDest& routing_table_entry)
{ {
assert(out.size() == m_virtual_networks); assert(out.size() == m_virtual_networks);
@ -79,11 +81,11 @@ PerfectSwitch::addOutPort(const Vector<MessageBuffer*>& out,
LinkOrder l; LinkOrder l;
l.m_value = 0; l.m_value = 0;
l.m_link = m_out.size(); l.m_link = m_out.size();
m_link_order.insertAtBottom(l); m_link_order.push_back(l);
// Add to routing table // Add to routing table
m_out.insertAtBottom(out); m_out.push_back(out);
m_routing_table.insertAtBottom(routing_table_entry); m_routing_table.push_back(routing_table_entry);
} }
void void
@ -111,7 +113,7 @@ PerfectSwitch::clearBuffers()
void void
PerfectSwitch::reconfigureOutPort(const NetDest& routing_table_entry) PerfectSwitch::reconfigureOutPort(const NetDest& routing_table_entry)
{ {
m_routing_table.insertAtBottom(routing_table_entry); m_routing_table.push_back(routing_table_entry);
} }
PerfectSwitch::~PerfectSwitch() PerfectSwitch::~PerfectSwitch()
@ -161,8 +163,8 @@ PerfectSwitch::wakeup()
} }
// temporary vectors to store the routing results // temporary vectors to store the routing results
Vector<LinkID> output_links; vector<LinkID> output_links;
Vector<NetDest> output_link_destinations; vector<NetDest> output_link_destinations;
// Is there a message waiting? // Is there a message waiting?
while (m_in[incoming][vnet]->isReady()) { while (m_in[incoming][vnet]->isReady()) {
@ -206,7 +208,7 @@ PerfectSwitch::wakeup()
} }
// Look at the most empty link first // Look at the most empty link first
m_link_order.sortVector(); sort(m_link_order.begin(), m_link_order.end());
} }
} }
@ -220,14 +222,14 @@ PerfectSwitch::wakeup()
continue; continue;
// Remember what link we're using // Remember what link we're using
output_links.insertAtBottom(link); output_links.push_back(link);
// Need to remember which destinations need this // Need to remember which destinations need this
// message in another vector. This Set is the // message in another vector. This Set is the
// intersection of the routing_table entry and the // intersection of the routing_table entry and the
// current destination set. The intersection must // current destination set. The intersection must
// not be empty, since we are inside "if" // not be empty, since we are inside "if"
output_link_destinations.insertAtBottom(msg_dsts.AND(dst)); output_link_destinations.push_back(msg_dsts.AND(dst));
// Next, we update the msg_destination not to // Next, we update the msg_destination not to
// include those nodes that were already handled // include those nodes that were already handled

View file

@ -37,8 +37,8 @@
#define __MEM_RUBY_NETWORK_SIMPLE_PERFECTSWITCH_HH__ #define __MEM_RUBY_NETWORK_SIMPLE_PERFECTSWITCH_HH__
#include <iostream> #include <iostream>
#include <vector>
#include "mem/gems_common/Vector.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"
#include "mem/ruby/system/NodeID.hh" #include "mem/ruby/system/NodeID.hh"
@ -59,8 +59,8 @@ class PerfectSwitch : public Consumer
PerfectSwitch(SwitchID sid, SimpleNetwork* network_ptr); PerfectSwitch(SwitchID sid, SimpleNetwork* network_ptr);
~PerfectSwitch(); ~PerfectSwitch();
void addInPort(const Vector<MessageBuffer*>& in); void addInPort(const std::vector<MessageBuffer*>& in);
void addOutPort(const Vector<MessageBuffer*>& out, void addOutPort(const std::vector<MessageBuffer*>& out,
const NetDest& routing_table_entry); const NetDest& routing_table_entry);
void clearRoutingTables(); void clearRoutingTables();
void clearBuffers(); void clearBuffers();
@ -84,10 +84,10 @@ class PerfectSwitch : public Consumer
SwitchID m_switch_id; SwitchID m_switch_id;
// vector of queues from the components // vector of queues from the components
Vector<Vector<MessageBuffer*> > m_in; std::vector<std::vector<MessageBuffer*> > m_in;
Vector<Vector<MessageBuffer*> > m_out; std::vector<std::vector<MessageBuffer*> > m_out;
Vector<NetDest> m_routing_table; std::vector<NetDest> m_routing_table;
Vector<LinkOrder> m_link_order; std::vector<LinkOrder> m_link_order;
int m_virtual_networks; int m_virtual_networks;
int m_round_robin_start; int m_round_robin_start;
int m_wakeups_wo_switch; int m_wakeups_wo_switch;

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/stl_helpers.hh"
#include "mem/gems_common/Map.hh" #include "mem/gems_common/Map.hh"
#include "mem/protocol/MachineType.hh" #include "mem/protocol/MachineType.hh"
#include "mem/protocol/Protocol.hh" #include "mem/protocol/Protocol.hh"
@ -39,6 +40,7 @@
#include "mem/ruby/system/System.hh" #include "mem/ruby/system/System.hh"
using namespace std; using namespace std;
using m5::stl_helpers::deletePointers;
#if 0 #if 0
// ***BIG HACK*** - This is actually code that _should_ be in Network.cc // ***BIG HACK*** - This is actually code that _should_ be in Network.cc
@ -59,21 +61,21 @@ SimpleNetwork::SimpleNetwork(const Params *p)
// SimpleNetwork child constructor. Therefore, the member variables // SimpleNetwork child constructor. Therefore, the member variables
// used below should already be initialized. // used below should already be initialized.
m_endpoint_switches.setSize(m_nodes); m_endpoint_switches.resize(m_nodes);
m_in_use.setSize(m_virtual_networks); m_in_use.resize(m_virtual_networks);
m_ordered.setSize(m_virtual_networks); m_ordered.resize(m_virtual_networks);
for (int i = 0; i < m_virtual_networks; i++) { for (int i = 0; i < m_virtual_networks; i++) {
m_in_use[i] = false; m_in_use[i] = false;
m_ordered[i] = false; m_ordered[i] = false;
} }
// Allocate to and from queues // Allocate to and from queues
m_toNetQueues.setSize(m_nodes); m_toNetQueues.resize(m_nodes);
m_fromNetQueues.setSize(m_nodes); m_fromNetQueues.resize(m_nodes);
for (int node = 0; node < m_nodes; node++) { for (int node = 0; node < m_nodes; node++) {
m_toNetQueues[node].setSize(m_virtual_networks); m_toNetQueues[node].resize(m_virtual_networks);
m_fromNetQueues[node].setSize(m_virtual_networks); m_fromNetQueues[node].resize(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] = m_toNetQueues[node][j] =
new MessageBuffer(csprintf("toNet node %d j %d", node, j)); new MessageBuffer(csprintf("toNet node %d j %d", node, j));
@ -93,7 +95,7 @@ SimpleNetwork::init()
assert(m_topology_ptr != NULL); assert(m_topology_ptr != NULL);
int number_of_switches = m_topology_ptr->numSwitches(); int number_of_switches = m_topology_ptr->numSwitches();
for (int i = 0; i < number_of_switches; i++) { for (int i = 0; i < number_of_switches; i++) {
m_switch_ptr_vector.insertAtBottom(new Switch(i, this)); m_switch_ptr_vector.push_back(new Switch(i, this));
} }
// false because this isn't a reconfiguration // false because this isn't a reconfiguration
@ -118,11 +120,11 @@ SimpleNetwork::reset()
SimpleNetwork::~SimpleNetwork() SimpleNetwork::~SimpleNetwork()
{ {
for (int i = 0; i < m_nodes; i++) { for (int i = 0; i < m_nodes; i++) {
m_toNetQueues[i].deletePointers(); deletePointers(m_toNetQueues[i]);
m_fromNetQueues[i].deletePointers(); deletePointers(m_fromNetQueues[i]);
} }
m_switch_ptr_vector.deletePointers(); deletePointers(m_switch_ptr_vector);
m_buffers_to_free.deletePointers(); deletePointers(m_buffers_to_free);
// delete m_topology_ptr; // delete m_topology_ptr;
} }
@ -173,17 +175,17 @@ SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest,
} }
// Create a set of new MessageBuffers // Create a set of new MessageBuffers
Vector<MessageBuffer*> queues; std::vector<MessageBuffer*> queues;
for (int i = 0; i < m_virtual_networks; i++) { for (int i = 0; i < m_virtual_networks; i++) {
// allocate a buffer // allocate a buffer
MessageBuffer* buffer_ptr = new MessageBuffer; MessageBuffer* buffer_ptr = new MessageBuffer;
buffer_ptr->setOrdering(true); buffer_ptr->setOrdering(true);
if (m_buffer_size > 0) { if (m_buffer_size > 0) {
buffer_ptr->setSize(m_buffer_size); buffer_ptr->resize(m_buffer_size);
} }
queues.insertAtBottom(buffer_ptr); queues.push_back(buffer_ptr);
// remember to deallocate it // remember to deallocate it
m_buffers_to_free.insertAtBottom(buffer_ptr); m_buffers_to_free.push_back(buffer_ptr);
} }
// Connect it to the two switches // Connect it to the two switches
m_switch_ptr_vector[dest]->addInPort(queues); m_switch_ptr_vector[dest]->addInPort(queues);
@ -217,7 +219,7 @@ SimpleNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num)
return m_fromNetQueues[id][network_num]; return m_fromNetQueues[id][network_num];
} }
const Vector<Throttle*>* const std::vector<Throttle*>*
SimpleNetwork::getThrottles(NodeID id) const SimpleNetwork::getThrottles(NodeID id) const
{ {
assert(id >= 0); assert(id >= 0);

View file

@ -64,8 +64,8 @@
#define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ #define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
#include <iostream> #include <iostream>
#include <vector>
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
#include "mem/ruby/network/Network.hh" #include "mem/ruby/network/Network.hh"
#include "mem/ruby/system/NodeID.hh" #include "mem/ruby/system/NodeID.hh"
@ -96,7 +96,7 @@ class SimpleNetwork : public Network
// returns the queue requested for the given component // returns the queue requested for the given component
MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num); MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num);
MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num); MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num);
virtual const Vector<Throttle*>* getThrottles(NodeID id) const; virtual const std::vector<Throttle*>* getThrottles(NodeID id) const;
bool isVNetOrdered(int vnet) { return m_ordered[vnet]; } bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; } bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
@ -130,14 +130,14 @@ class SimpleNetwork : public Network
SimpleNetwork& operator=(const SimpleNetwork& obj); SimpleNetwork& operator=(const SimpleNetwork& obj);
// vector of queues from the components // vector of queues from the components
Vector<Vector<MessageBuffer*> > m_toNetQueues; std::vector<std::vector<MessageBuffer*> > m_toNetQueues;
Vector<Vector<MessageBuffer*> > m_fromNetQueues; std::vector<std::vector<MessageBuffer*> > m_fromNetQueues;
Vector<bool> m_in_use; std::vector<bool> m_in_use;
Vector<bool> m_ordered; std::vector<bool> m_ordered;
Vector<Switch*> m_switch_ptr_vector; std::vector<Switch*> m_switch_ptr_vector;
Vector<MessageBuffer*> m_buffers_to_free; std::vector<MessageBuffer*> m_buffers_to_free;
Vector<Switch*> m_endpoint_switches; std::vector<Switch*> m_endpoint_switches;
}; };
inline std::ostream& inline std::ostream&

View file

@ -26,6 +26,9 @@
* 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 <numeric>
#include "base/stl_helpers.hh"
#include "mem/protocol/MessageSizeType.hh" #include "mem/protocol/MessageSizeType.hh"
#include "mem/protocol/Protocol.hh" #include "mem/protocol/Protocol.hh"
#include "mem/ruby/buffers/MessageBuffer.hh" #include "mem/ruby/buffers/MessageBuffer.hh"
@ -35,12 +38,13 @@
#include "mem/ruby/network/simple/Throttle.hh" #include "mem/ruby/network/simple/Throttle.hh"
using namespace std; using namespace std;
using m5::stl_helpers::deletePointers;
using m5::stl_helpers::operator<<;
Switch::Switch(SwitchID sid, SimpleNetwork* network_ptr) Switch::Switch(SwitchID sid, SimpleNetwork* network_ptr)
{ {
m_perfect_switch_ptr = new PerfectSwitch(sid, network_ptr); m_perfect_switch_ptr = new PerfectSwitch(sid, network_ptr);
m_switch_id = sid; m_switch_id = sid;
m_throttles.setSize(0);
} }
Switch::~Switch() Switch::~Switch()
@ -48,20 +52,20 @@ Switch::~Switch()
delete m_perfect_switch_ptr; delete m_perfect_switch_ptr;
// Delete throttles (one per output port) // Delete throttles (one per output port)
m_throttles.deletePointers(); deletePointers(m_throttles);
// Delete MessageBuffers // Delete MessageBuffers
m_buffers_to_free.deletePointers(); deletePointers(m_buffers_to_free);
} }
void void
Switch::addInPort(const Vector<MessageBuffer*>& in) Switch::addInPort(const vector<MessageBuffer*>& in)
{ {
m_perfect_switch_ptr->addInPort(in); m_perfect_switch_ptr->addInPort(in);
} }
void void
Switch::addOutPort(const Vector<MessageBuffer*>& out, Switch::addOutPort(const vector<MessageBuffer*>& out,
const NetDest& routing_table_entry, int link_latency, int bw_multiplier) const NetDest& routing_table_entry, int link_latency, int bw_multiplier)
{ {
Throttle* throttle_ptr = NULL; Throttle* throttle_ptr = NULL;
@ -69,20 +73,20 @@ Switch::addOutPort(const Vector<MessageBuffer*>& out,
// Create a throttle // Create a throttle
throttle_ptr = new Throttle(m_switch_id, m_throttles.size(), link_latency, throttle_ptr = new Throttle(m_switch_id, m_throttles.size(), link_latency,
bw_multiplier); bw_multiplier);
m_throttles.insertAtBottom(throttle_ptr); m_throttles.push_back(throttle_ptr);
// Create one buffer per vnet (these are intermediaryQueues) // Create one buffer per vnet (these are intermediaryQueues)
Vector<MessageBuffer*> intermediateBuffers; vector<MessageBuffer*> intermediateBuffers;
for (int i = 0; i < out.size(); i++) { for (int i = 0; i < out.size(); i++) {
MessageBuffer* buffer_ptr = new MessageBuffer; MessageBuffer* buffer_ptr = new MessageBuffer;
// Make these queues ordered // Make these queues ordered
buffer_ptr->setOrdering(true); buffer_ptr->setOrdering(true);
Network* net_ptr = RubySystem::getNetwork(); Network* net_ptr = RubySystem::getNetwork();
if (net_ptr->getBufferSize() > 0) { if (net_ptr->getBufferSize() > 0) {
buffer_ptr->setSize(net_ptr->getBufferSize()); buffer_ptr->resize(net_ptr->getBufferSize());
} }
intermediateBuffers.insertAtBottom(buffer_ptr); intermediateBuffers.push_back(buffer_ptr);
m_buffers_to_free.insertAtBottom(buffer_ptr); m_buffers_to_free.push_back(buffer_ptr);
} }
// Hook the queues to the PerfectSwitch // Hook the queues to the PerfectSwitch
@ -122,7 +126,7 @@ Switch::getThrottle(LinkID link_number) const
return m_throttles[link_number]; return m_throttles[link_number];
} }
const Vector<Throttle*>* const vector<Throttle*>*
Switch::getThrottles() const Switch::getThrottles() const
{ {
return &m_throttles; return &m_throttles;
@ -172,18 +176,21 @@ Switch::printStats(std::ostream& out) const
if (!throttle_ptr) if (!throttle_ptr)
continue; continue;
const Vector<Vector<int> >& message_counts = const vector<vector<int> >& message_counts =
throttle_ptr->getCounters(); throttle_ptr->getCounters();
for (int int_type = 0; int_type < MessageSizeType_NUM; int_type++) { for (int int_type = 0; int_type < MessageSizeType_NUM; int_type++) {
MessageSizeType type = MessageSizeType(int_type); MessageSizeType type = MessageSizeType(int_type);
int sum = message_counts[type].sum(); const vector<int> &mct = message_counts[type];
int sum = accumulate(mct.begin(), mct.end(), 0);
if (sum == 0) if (sum == 0)
continue; continue;
out << " outgoing_messages_switch_" << m_switch_id out << " outgoing_messages_switch_" << m_switch_id
<< "_link_" << link << "_" << type << ": " << sum << " " << "_link_" << link << "_" << type << ": " << sum << " "
<< sum * RubySystem::getNetwork()->MessageSizeType_to_int(type) << sum * RubySystem::getNetwork()->MessageSizeType_to_int(type)
<< " " << message_counts[type] << " base_latency: " << " ";
out << mct;
out << " base_latency: "
<< throttle_ptr->getLatency() << endl; << throttle_ptr->getLatency() << endl;
} }
} }

View file

@ -40,8 +40,8 @@
#define __MEM_RUBY_NETWORK_SIMPLE_SWITCH_HH__ #define __MEM_RUBY_NETWORK_SIMPLE_SWITCH_HH__
#include <iostream> #include <iostream>
#include <vector>
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
class MessageBuffer; class MessageBuffer;
@ -57,12 +57,12 @@ class Switch
Switch(SwitchID sid, SimpleNetwork* network_ptr); Switch(SwitchID sid, SimpleNetwork* network_ptr);
~Switch(); ~Switch();
void addInPort(const Vector<MessageBuffer*>& in); void addInPort(const std::vector<MessageBuffer*>& in);
void addOutPort(const Vector<MessageBuffer*>& out, void addOutPort(const std::vector<MessageBuffer*>& out,
const NetDest& routing_table_entry, int link_latency, const NetDest& routing_table_entry, int link_latency,
int bw_multiplier); int bw_multiplier);
const Throttle* getThrottle(LinkID link_number) const; const Throttle* getThrottle(LinkID link_number) const;
const Vector<Throttle*>* getThrottles() const; const std::vector<Throttle*>* getThrottles() const;
void clearRoutingTables(); void clearRoutingTables();
void clearBuffers(); void clearBuffers();
void reconfigureOutPort(const NetDest& routing_table_entry); void reconfigureOutPort(const NetDest& routing_table_entry);
@ -80,8 +80,8 @@ class Switch
PerfectSwitch* m_perfect_switch_ptr; PerfectSwitch* m_perfect_switch_ptr;
Network* m_network_ptr; Network* m_network_ptr;
Vector<Throttle*> m_throttles; std::vector<Throttle*> m_throttles;
Vector<MessageBuffer*> m_buffers_to_free; std::vector<MessageBuffer*> m_buffers_to_free;
SwitchID m_switch_id; SwitchID m_switch_id;
}; };

View file

@ -85,17 +85,17 @@ Throttle::clear()
} }
void void
Throttle::addLinks(const Vector<MessageBuffer*>& in_vec, Throttle::addLinks(const std::vector<MessageBuffer*>& in_vec,
const Vector<MessageBuffer*>& out_vec) const std::vector<MessageBuffer*>& out_vec)
{ {
assert(in_vec.size() == out_vec.size()); assert(in_vec.size() == out_vec.size());
for (int i=0; i<in_vec.size(); i++) { for (int i=0; i<in_vec.size(); i++) {
addVirtualNetwork(in_vec[i], out_vec[i]); addVirtualNetwork(in_vec[i], out_vec[i]);
} }
m_message_counters.setSize(MessageSizeType_NUM); m_message_counters.resize(MessageSizeType_NUM);
for (int i = 0; i < MessageSizeType_NUM; i++) { for (int i = 0; i < MessageSizeType_NUM; i++) {
m_message_counters[i].setSize(in_vec.size()); m_message_counters[i].resize(in_vec.size());
for (int j = 0; j<m_message_counters[i].size(); j++) { for (int j = 0; j<m_message_counters[i].size(); j++) {
m_message_counters[i][j] = 0; m_message_counters[i][j] = 0;
} }
@ -105,9 +105,9 @@ Throttle::addLinks(const Vector<MessageBuffer*>& in_vec,
void void
Throttle::addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr) Throttle::addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr)
{ {
m_units_remaining.insertAtBottom(0); m_units_remaining.push_back(0);
m_in.insertAtBottom(in_ptr); m_in.push_back(in_ptr);
m_out.insertAtBottom(out_ptr); m_out.push_back(out_ptr);
// Set consumer and description // Set consumer and description
m_in[m_vnets]->setConsumer(this); m_in[m_vnets]->setConsumer(this);

View file

@ -39,8 +39,8 @@
#define __MEM_RUBY_NETWORK_SIMPLE_THROTTLE_HH__ #define __MEM_RUBY_NETWORK_SIMPLE_THROTTLE_HH__
#include <iostream> #include <iostream>
#include <vector>
#include "mem/gems_common/Vector.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"
#include "mem/ruby/network/Network.hh" #include "mem/ruby/network/Network.hh"
@ -57,8 +57,8 @@ class Throttle : public Consumer
Throttle(NodeID node, int link_latency, int link_bandwidth_multiplier); Throttle(NodeID node, int link_latency, int link_bandwidth_multiplier);
~Throttle() {} ~Throttle() {}
void addLinks(const Vector<MessageBuffer*>& in_vec, void addLinks(const std::vector<MessageBuffer*>& in_vec,
const Vector<MessageBuffer*>& out_vec); const std::vector<MessageBuffer*>& out_vec);
void wakeup(); void wakeup();
void printStats(std::ostream& out) const; void printStats(std::ostream& out) const;
@ -74,7 +74,7 @@ class Throttle : public Consumer
} }
int getLatency() const { return m_link_latency; } int getLatency() const { return m_link_latency; }
const Vector<Vector<int> >& const std::vector<std::vector<int> >&
getCounters() const getCounters() const
{ {
return m_message_counters; return m_message_counters;
@ -93,11 +93,11 @@ class Throttle : public Consumer
Throttle(const Throttle& obj); Throttle(const Throttle& obj);
Throttle& operator=(const Throttle& obj); Throttle& operator=(const Throttle& obj);
Vector<MessageBuffer*> m_in; std::vector<MessageBuffer*> m_in;
Vector<MessageBuffer*> m_out; std::vector<MessageBuffer*> m_out;
Vector<Vector<int> > m_message_counters; std::vector<std::vector<int> > m_message_counters;
int m_vnets; int m_vnets;
Vector<int> m_units_remaining; std::vector<int> m_units_remaining;
int m_sID; int m_sID;
NodeID m_node; NodeID m_node;
int m_link_bandwidth_multiplier; int m_link_bandwidth_multiplier;

View file

@ -63,8 +63,8 @@ Topology::Topology(const Params *p)
m_print_config = p->print_config; m_print_config = p->print_config;
m_number_of_switches = p->num_int_nodes; m_number_of_switches = p->num_int_nodes;
// initialize component latencies record // initialize component latencies record
m_component_latencies.setSize(0); m_component_latencies.resize(0);
m_component_inter_switches.setSize(0); m_component_inter_switches.resize(0);
// Total nodes/controllers in network // Total nodes/controllers in network
// Must make sure this is called after the State Machine constructors // Must make sure this is called after the State Machine constructors
@ -85,7 +85,7 @@ Topology::Topology(const Params *p)
AbstractController *c = p->ext_node; AbstractController *c = p->ext_node;
// Store the controller pointers for later // Store the controller pointers for later
m_controller_vector.insertAtBottom(c); m_controller_vector.push_back(c);
int ext_idx1 = int ext_idx1 =
MachineType_base_number(c->getMachineType()) + c->getVersion(); MachineType_base_number(c->getMachineType()) + c->getVersion();
@ -133,24 +133,24 @@ Topology::createLinks(Network *net, bool isReconfiguration)
Matrix topology_latency; Matrix topology_latency;
Matrix topology_bw_multis; Matrix topology_bw_multis;
int num_switches = max_switch_id+1; int num_switches = max_switch_id+1;
topology_weights.setSize(num_switches); topology_weights.resize(num_switches);
topology_latency.setSize(num_switches); topology_latency.resize(num_switches);
topology_bw_multis.setSize(num_switches); topology_bw_multis.resize(num_switches);
// FIXME setting the size of a member variable here is a HACK! // FIXME setting the size of a member variable here is a HACK!
m_component_latencies.setSize(num_switches); m_component_latencies.resize(num_switches);
// FIXME setting the size of a member variable here is a HACK! // FIXME setting the size of a member variable here is a HACK!
m_component_inter_switches.setSize(num_switches); m_component_inter_switches.resize(num_switches);
for (int i = 0; i < topology_weights.size(); i++) { for (int i = 0; i < topology_weights.size(); i++) {
topology_weights[i].setSize(num_switches); topology_weights[i].resize(num_switches);
topology_latency[i].setSize(num_switches); topology_latency[i].resize(num_switches);
topology_bw_multis[i].setSize(num_switches); topology_bw_multis[i].resize(num_switches);
m_component_latencies[i].setSize(num_switches); m_component_latencies[i].resize(num_switches);
// FIXME setting the size of a member variable here is a HACK! // FIXME setting the size of a member variable here is a HACK!
m_component_inter_switches[i].setSize(num_switches); m_component_inter_switches[i].resize(num_switches);
for (int j = 0; j < topology_weights[i].size(); j++) { for (int j = 0; j < topology_weights[i].size(); j++) {
topology_weights[i][j] = INFINITE_LATENCY; topology_weights[i][j] = INFINITE_LATENCY;
@ -226,11 +226,11 @@ Topology::addLink(SwitchID src, SwitchID dest, int link_latency,
{ {
ASSERT(src <= m_number_of_switches+m_nodes+m_nodes); ASSERT(src <= m_number_of_switches+m_nodes+m_nodes);
ASSERT(dest <= m_number_of_switches+m_nodes+m_nodes); ASSERT(dest <= m_number_of_switches+m_nodes+m_nodes);
m_links_src_vector.insertAtBottom(src); m_links_src_vector.push_back(src);
m_links_dest_vector.insertAtBottom(dest); m_links_dest_vector.push_back(dest);
m_links_latency_vector.insertAtBottom(link_latency); m_links_latency_vector.push_back(link_latency);
m_links_weight_vector.insertAtBottom(link_weight); m_links_weight_vector.push_back(link_weight);
m_bw_multiplier_vector.insertAtBottom(bw_multiplier); m_bw_multiplier_vector.push_back(bw_multiplier);
} }
void void

View file

@ -42,8 +42,8 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
#include "mem/ruby/system/NodeID.hh" #include "mem/ruby/system/NodeID.hh"
#include "params/ExtLink.hh" #include "params/ExtLink.hh"
@ -55,7 +55,7 @@
class Network; class Network;
class NetDest; class NetDest;
typedef Vector<Vector<int> > Matrix; typedef std::vector<std::vector<int> > Matrix;
class Link : public SimObject class Link : public SimObject
{ {
@ -111,8 +111,9 @@ class Topology : public SimObject
const NetDest& routing_table_entry, int link_latency, int weight, const NetDest& routing_table_entry, int link_latency, int weight,
int bw_multiplier, bool isReconfiguration); int bw_multiplier, bool isReconfiguration);
//void makeSwitchesPerChip(Vector<Vector< SwitchID> > &nodePairs, //void makeSwitchesPerChip(std::vector<std::vector<SwitchID > > &nodePairs,
// Vector<int> &latencies, Vector<int> &bw_multis, int numberOfChips); // std::vector<int> &latencies, std::vector<int> &bw_multis,
// int numberOfChips);
std::string getDesignStr(); std::string getDesignStr();
// Private copy constructor and assignment operator // Private copy constructor and assignment operator
@ -124,13 +125,13 @@ class Topology : public SimObject
NodeID m_nodes; NodeID m_nodes;
int m_number_of_switches; int m_number_of_switches;
Vector<AbstractController*> m_controller_vector; std::vector<AbstractController*> m_controller_vector;
Vector<SwitchID> m_links_src_vector; std::vector<SwitchID> m_links_src_vector;
Vector<SwitchID> m_links_dest_vector; std::vector<SwitchID> m_links_dest_vector;
Vector<int> m_links_latency_vector; std::vector<int> m_links_latency_vector;
Vector<int> m_links_weight_vector; std::vector<int> m_links_weight_vector;
Vector<int> m_bw_multiplier_vector; std::vector<int> m_bw_multiplier_vector;
Matrix m_component_latencies; Matrix m_component_latencies;
Matrix m_component_inter_switches; Matrix m_component_inter_switches;

View file

@ -26,6 +26,9 @@
* 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/stl_helpers.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/protocol/CacheMsg.hh" #include "mem/protocol/CacheMsg.hh"
@ -37,6 +40,8 @@
using namespace std; using namespace std;
typedef AddressProfiler::AddressMap AddressMap; typedef AddressProfiler::AddressMap AddressMap;
using m5::stl_helpers::operator<<;
// Helper functions // Helper functions
AccessTraceForAddress& AccessTraceForAddress&
lookupTraceForAddress(const Address& addr, AddressMap* record_map) lookupTraceForAddress(const Address& addr, AddressMap* record_map)
@ -55,7 +60,7 @@ printSorted(ostream& out, int num_of_sequencers, const AddressMap* record_map,
uint64 misses = 0; uint64 misses = 0;
PrioHeap<AccessTraceForAddress*> heap; PrioHeap<AccessTraceForAddress*> heap;
Vector<Address> keys = record_map->keys(); std::vector<Address> keys = record_map->keys();
for (int i = 0; i < keys.size(); i++) { for (int i = 0; i < keys.size(); i++) {
AccessTraceForAddress* record = &(record_map->lookup(keys[i])); AccessTraceForAddress* record = &(record_map->lookup(keys[i]));
misses += record->getTotal(); misses += record->getTotal();
@ -77,10 +82,10 @@ printSorted(ostream& out, int num_of_sequencers, const AddressMap* record_map,
Histogram all_records_log(-1); Histogram all_records_log(-1);
// Allows us to track how many lines where touched by n processors // Allows us to track how many lines where touched by n processors
Vector<int64> m_touched_vec; std::vector<int64> m_touched_vec;
Vector<int64> m_touched_weighted_vec; std::vector<int64> m_touched_weighted_vec;
m_touched_vec.setSize(num_of_sequencers+1); m_touched_vec.resize(num_of_sequencers+1);
m_touched_weighted_vec.setSize(num_of_sequencers+1); m_touched_weighted_vec.resize(num_of_sequencers+1);
for (int i = 0; i < m_touched_vec.size(); i++) { for (int i = 0; i < m_touched_vec.size(); i++) {
m_touched_vec[i] = 0; m_touched_vec[i] = 0;
m_touched_weighted_vec[i] = 0; m_touched_weighted_vec[i] = 0;

View file

@ -27,7 +27,6 @@
*/ */
#include "mem/gems_common/PrioHeap.hh" #include "mem/gems_common/PrioHeap.hh"
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/profiler/AccessTraceForAddress.hh" #include "mem/ruby/profiler/AccessTraceForAddress.hh"
#include "mem/ruby/profiler/CacheProfiler.hh" #include "mem/ruby/profiler/CacheProfiler.hh"
#include "mem/ruby/profiler/Profiler.hh" #include "mem/ruby/profiler/Profiler.hh"
@ -36,17 +35,15 @@
using namespace std; using namespace std;
CacheProfiler::CacheProfiler(const string& description) CacheProfiler::CacheProfiler(const string& description)
: m_requestTypeVec(int(CacheRequestType_NUM))
{ {
m_description = description; m_description = description;
m_requestTypeVec_ptr = new Vector<int>;
m_requestTypeVec_ptr->setSize(int(CacheRequestType_NUM));
clearStats(); clearStats();
} }
CacheProfiler::~CacheProfiler() CacheProfiler::~CacheProfiler()
{ {
delete m_requestTypeVec_ptr;
} }
void void
@ -65,18 +62,18 @@ CacheProfiler::printStats(ostream& out) const
int requests = 0; int requests = 0;
for (int i = 0; i < int(CacheRequestType_NUM); i++) { for (int i = 0; i < int(CacheRequestType_NUM); i++) {
requests += m_requestTypeVec_ptr->ref(i); requests += m_requestTypeVec[i];
} }
assert(m_misses == requests); assert(m_misses == requests);
if (requests > 0) { if (requests > 0) {
for (int i = 0; i < int(CacheRequestType_NUM); i++) { for (int i = 0; i < int(CacheRequestType_NUM); i++) {
if (m_requestTypeVec_ptr->ref(i) > 0) { if (m_requestTypeVec[i] > 0) {
out << description << "_request_type_" out << description << "_request_type_"
<< CacheRequestType_to_string(CacheRequestType(i)) << CacheRequestType_to_string(CacheRequestType(i))
<< ": " << ": "
<< 100.0 * (double)m_requestTypeVec_ptr->ref(i) / << 100.0 * (double)m_requestTypeVec[i] /
(double)requests (double)requests
<< "%" << endl; << "%" << endl;
} }
@ -103,7 +100,7 @@ void
CacheProfiler::clearStats() CacheProfiler::clearStats()
{ {
for (int i = 0; i < int(CacheRequestType_NUM); i++) { for (int i = 0; i < int(CacheRequestType_NUM); i++) {
m_requestTypeVec_ptr->ref(i) = 0; m_requestTypeVec[i] = 0;
} }
m_requestSize.clear(); m_requestSize.clear();
m_misses = 0; m_misses = 0;
@ -123,7 +120,7 @@ CacheProfiler::addStatSample(CacheRequestType requestType,
{ {
m_misses++; m_misses++;
m_requestTypeVec_ptr->ref(requestType)++; m_requestTypeVec[requestType]++;
m_accessModeTypeHistogram[type]++; m_accessModeTypeHistogram[type]++;
m_requestSize.add(msgSize); m_requestSize.add(msgSize);

View file

@ -31,6 +31,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/protocol/AccessModeType.hh" #include "mem/protocol/AccessModeType.hh"
#include "mem/protocol/CacheRequestType.hh" #include "mem/protocol/CacheRequestType.hh"
@ -39,8 +40,6 @@
#include "mem/ruby/common/Histogram.hh" #include "mem/ruby/common/Histogram.hh"
#include "mem/ruby/system/NodeID.hh" #include "mem/ruby/system/NodeID.hh"
template <class TYPE> class Vector;
class CacheProfiler class CacheProfiler
{ {
public: public:
@ -69,7 +68,7 @@ class CacheProfiler
int64 m_hw_prefetches; int64 m_hw_prefetches;
int64 m_accessModeTypeHistogram[AccessModeType_NUM]; int64 m_accessModeTypeHistogram[AccessModeType_NUM];
Vector <int>* m_requestTypeVec_ptr; std::vector<int> m_requestTypeVec;
}; };
inline std::ostream& inline std::ostream&

View file

@ -39,7 +39,7 @@ MemCntrlProfiler::MemCntrlProfiler(const string& description,
m_dimms_per_channel = dimms_per_channel; m_dimms_per_channel = dimms_per_channel;
int totalBanks = banks_per_rank * ranks_per_dimm * dimms_per_channel; int totalBanks = banks_per_rank * ranks_per_dimm * dimms_per_channel;
m_memBankCount.setSize(totalBanks); m_memBankCount.resize(totalBanks);
clearStats(); clearStats();
} }

View file

@ -31,12 +31,10 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/gems_common/Vector.hh"
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
template <class TYPE> class Vector;
class MemCntrlProfiler class MemCntrlProfiler
{ {
public: public:
@ -86,7 +84,7 @@ private:
uint64 m_memArbWait; uint64 m_memArbWait;
uint64 m_memRandBusy; uint64 m_memRandBusy;
uint64 m_memNotOld; uint64 m_memNotOld;
Vector<uint64> m_memBankCount; std::vector<uint64> m_memBankCount;
int m_banks_per_rank; int m_banks_per_rank;
int m_ranks_per_dimm; int m_ranks_per_dimm;
int m_dimms_per_channel; int m_dimms_per_channel;

View file

@ -46,6 +46,9 @@
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/times.h> #include <sys/times.h>
#include <algorithm>
#include "base/stl_helpers.hh"
#include "base/str.hh" #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"
@ -60,6 +63,7 @@
#include "mem/ruby/system/System.hh" #include "mem/ruby/system/System.hh"
using namespace std; using namespace std;
using m5::stl_helpers::operator<<;
extern ostream* debug_cout_ptr; extern ostream* debug_cout_ptr;
@ -111,8 +115,7 @@ Profiler::wakeup()
{ {
// FIXME - avoid the repeated code // FIXME - avoid the repeated code
Vector<integer_t> perProcCycleCount; vector<integer_t> perProcCycleCount(m_num_of_sequencers);
perProcCycleCount.setSize(m_num_of_sequencers);
for (int i = 0; i < m_num_of_sequencers; i++) { for (int i = 0; i < m_num_of_sequencers; i++) {
perProcCycleCount[i] = perProcCycleCount[i] =
@ -235,8 +238,7 @@ Profiler::printStats(ostream& out, bool short_stats)
out << endl; out << endl;
} }
Vector<integer_t> perProcCycleCount; vector<integer_t> perProcCycleCount(m_num_of_sequencers);
perProcCycleCount.setSize(m_num_of_sequencers);
for (int i = 0; i < m_num_of_sequencers; i++) { for (int i = 0; i < m_num_of_sequencers; i++) {
perProcCycleCount[i] = perProcCycleCount[i] =
@ -353,8 +355,8 @@ Profiler::printStats(ostream& out, bool short_stats)
out << "--------------------------------" << endl; out << "--------------------------------" << endl;
out << endl; out << endl;
Vector<string> requestProfileKeys = m_requestProfileMap_ptr->keys(); vector<string> requestProfileKeys = m_requestProfileMap_ptr->keys();
requestProfileKeys.sortVector(); sort(requestProfileKeys.begin(), requestProfileKeys.end());
for (int i = 0; i < requestProfileKeys.size(); i++) { for (int i = 0; i < requestProfileKeys.size(); i++) {
int temp_int = int temp_int =
@ -423,7 +425,7 @@ Profiler::clearStats()
{ {
m_ruby_start = g_eventQueue_ptr->getTime(); m_ruby_start = g_eventQueue_ptr->getTime();
m_cycles_executed_at_start.setSize(m_num_of_sequencers); m_cycles_executed_at_start.resize(m_num_of_sequencers);
for (int i = 0; i < m_num_of_sequencers; i++) { for (int i = 0; i < m_num_of_sequencers; i++) {
if (g_system_ptr == NULL) { if (g_system_ptr == NULL) {
m_cycles_executed_at_start[i] = 0; m_cycles_executed_at_start[i] = 0;
@ -432,10 +434,10 @@ Profiler::clearStats()
} }
} }
m_busyControllerCount.setSize(MachineType_NUM); // all machines m_busyControllerCount.resize(MachineType_NUM); // all machines
for (int i = 0; i < MachineType_NUM; i++) { for (int i = 0; i < MachineType_NUM; i++) {
int size = MachineType_base_count((MachineType)i); int size = MachineType_base_count((MachineType)i);
m_busyControllerCount[i].setSize(size); m_busyControllerCount[i].resize(size);
for (int j = 0; j < size; j++) { for (int j = 0; j < size; j++) {
m_busyControllerCount[i][j] = 0; m_busyControllerCount[i][j] = 0;
} }
@ -445,26 +447,26 @@ Profiler::clearStats()
m_delayedCyclesHistogram.clear(); m_delayedCyclesHistogram.clear();
m_delayedCyclesNonPFHistogram.clear(); m_delayedCyclesNonPFHistogram.clear();
int size = RubySystem::getNetwork()->getNumberOfVirtualNetworks(); int size = RubySystem::getNetwork()->getNumberOfVirtualNetworks();
m_delayedCyclesVCHistograms.setSize(size); m_delayedCyclesVCHistograms.resize(size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
m_delayedCyclesVCHistograms[i].clear(); m_delayedCyclesVCHistograms[i].clear();
} }
m_missLatencyHistograms.setSize(RubyRequestType_NUM); m_missLatencyHistograms.resize(RubyRequestType_NUM);
for (int i = 0; i < m_missLatencyHistograms.size(); i++) { for (int i = 0; i < m_missLatencyHistograms.size(); i++) {
m_missLatencyHistograms[i].clear(200); m_missLatencyHistograms[i].clear(200);
} }
m_machLatencyHistograms.setSize(GenericMachineType_NUM+1); m_machLatencyHistograms.resize(GenericMachineType_NUM+1);
for (int i = 0; i < m_machLatencyHistograms.size(); i++) { for (int i = 0; i < m_machLatencyHistograms.size(); i++) {
m_machLatencyHistograms[i].clear(200); m_machLatencyHistograms[i].clear(200);
} }
m_allMissLatencyHistogram.clear(200); m_allMissLatencyHistogram.clear(200);
m_SWPrefetchLatencyHistograms.setSize(CacheRequestType_NUM); m_SWPrefetchLatencyHistograms.resize(CacheRequestType_NUM);
for (int i = 0; i < m_SWPrefetchLatencyHistograms.size(); i++) { for (int i = 0; i < m_SWPrefetchLatencyHistograms.size(); i++) {
m_SWPrefetchLatencyHistograms[i].clear(200); m_SWPrefetchLatencyHistograms[i].clear(200);
} }
m_SWPrefetchMachLatencyHistograms.setSize(GenericMachineType_NUM+1); m_SWPrefetchMachLatencyHistograms.resize(GenericMachineType_NUM+1);
for (int i = 0; i < m_SWPrefetchMachLatencyHistograms.size(); i++) { for (int i = 0; i < m_SWPrefetchMachLatencyHistograms.size(); i++) {
m_SWPrefetchMachLatencyHistograms[i].clear(200); m_SWPrefetchMachLatencyHistograms[i].clear(200);
} }

View file

@ -47,6 +47,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
#include "mem/protocol/AccessModeType.hh" #include "mem/protocol/AccessModeType.hh"
#include "mem/protocol/AccessType.hh" #include "mem/protocol/AccessType.hh"
@ -166,8 +167,8 @@ class Profiler : public SimObject, public Consumer
AddressProfiler* m_address_profiler_ptr; AddressProfiler* m_address_profiler_ptr;
AddressProfiler* m_inst_profiler_ptr; AddressProfiler* m_inst_profiler_ptr;
Vector<int64> m_instructions_executed_at_start; std::vector<int64> m_instructions_executed_at_start;
Vector<int64> m_cycles_executed_at_start; std::vector<int64> m_cycles_executed_at_start;
std::ostream* m_periodic_output_file_ptr; std::ostream* m_periodic_output_file_ptr;
integer_t m_stats_period; integer_t m_stats_period;
@ -175,7 +176,7 @@ class Profiler : public SimObject, public Consumer
Time m_ruby_start; Time m_ruby_start;
time_t m_real_time_start_time; time_t m_real_time_start_time;
Vector <Vector<integer_t> > m_busyControllerCount; std::vector<std::vector<integer_t> > m_busyControllerCount;
integer_t m_busyBankCount; integer_t m_busyBankCount;
Histogram m_multicast_retry_histogram; Histogram m_multicast_retry_histogram;
@ -191,18 +192,18 @@ class Profiler : public SimObject, public Consumer
Histogram m_prefetchWaitHistogram; Histogram m_prefetchWaitHistogram;
Vector<Histogram> m_missLatencyHistograms; std::vector<Histogram> m_missLatencyHistograms;
Vector<Histogram> m_machLatencyHistograms; std::vector<Histogram> m_machLatencyHistograms;
Histogram m_allMissLatencyHistogram; Histogram m_allMissLatencyHistogram;
Histogram m_allSWPrefetchLatencyHistogram; Histogram m_allSWPrefetchLatencyHistogram;
Histogram m_SWPrefetchL2MissLatencyHistogram; Histogram m_SWPrefetchL2MissLatencyHistogram;
Vector<Histogram> m_SWPrefetchLatencyHistograms; std::vector<Histogram> m_SWPrefetchLatencyHistograms;
Vector<Histogram> m_SWPrefetchMachLatencyHistograms; std::vector<Histogram> m_SWPrefetchMachLatencyHistograms;
Histogram m_delayedCyclesHistogram; Histogram m_delayedCyclesHistogram;
Histogram m_delayedCyclesNonPFHistogram; Histogram m_delayedCyclesNonPFHistogram;
Vector<Histogram> m_delayedCyclesVCHistograms; std::vector<Histogram> m_delayedCyclesVCHistograms;
Histogram m_outstanding_requests; Histogram m_outstanding_requests;
Histogram m_outstanding_persistent_requests; Histogram m_outstanding_persistent_requests;

View file

@ -73,11 +73,11 @@ CacheMemory::init()
else else
assert(false); assert(false);
m_cache.setSize(m_cache_num_sets); m_cache.resize(m_cache_num_sets);
m_locked.setSize(m_cache_num_sets); m_locked.resize(m_cache_num_sets);
for (int i = 0; i < m_cache_num_sets; i++) { for (int i = 0; i < m_cache_num_sets; i++) {
m_cache[i].setSize(m_cache_assoc); m_cache[i].resize(m_cache_assoc);
m_locked[i].setSize(m_cache_assoc); m_locked[i].resize(m_cache_assoc);
for (int j = 0; j < m_cache_assoc; j++) { for (int j = 0; j < m_cache_assoc; j++) {
m_cache[i][j] = NULL; m_cache[i][j] = NULL;
m_locked[i][j] = -1; m_locked[i][j] = -1;
@ -266,7 +266,7 @@ CacheMemory::allocate(const Address& address, AbstractCacheEntry* entry)
// Find the first open slot // Find the first open slot
Index cacheSet = addressToCacheSet(address); Index cacheSet = addressToCacheSet(address);
Vector<AbstractCacheEntry*> &set = m_cache[cacheSet]; std::vector<AbstractCacheEntry*> &set = m_cache[cacheSet];
for (int i = 0; i < m_cache_assoc; i++) { for (int i = 0; i < m_cache_assoc; i++) {
if (!set[i] || set[i]->m_Permission == AccessPermission_NotPresent) { if (!set[i] || set[i]->m_Permission == AccessPermission_NotPresent) {
set[i] = entry; // Init entry set[i] = entry; // Init entry

View file

@ -34,7 +34,6 @@
#include <vector> #include <vector>
#include "base/hashmap.hh" #include "base/hashmap.hh"
#include "mem/gems_common/Vector.hh"
#include "mem/protocol/AccessPermission.hh" #include "mem/protocol/AccessPermission.hh"
#include "mem/protocol/CacheMsg.hh" #include "mem/protocol/CacheMsg.hh"
#include "mem/protocol/CacheRequestType.hh" #include "mem/protocol/CacheRequestType.hh"
@ -153,8 +152,8 @@ class CacheMemory : public SimObject
// The first index is the # of cache lines. // The first index is the # of cache lines.
// The second index is the the amount associativity. // The second index is the the amount associativity.
m5::hash_map<Address, int> m_tag_index; m5::hash_map<Address, int> m_tag_index;
Vector<Vector<AbstractCacheEntry*> > m_cache; std::vector<std::vector<AbstractCacheEntry*> > m_cache;
Vector<Vector<int> > m_locked; std::vector<std::vector<int> > m_locked;
AbstractReplacementPolicy *m_replacementPolicy_ptr; AbstractReplacementPolicy *m_replacementPolicy_ptr;

View file

@ -44,7 +44,7 @@ class MemoryVector
~MemoryVector(); ~MemoryVector();
friend class DirectoryMemory; friend class DirectoryMemory;
void setSize(uint32 size); // destructive void resize(uint32 size); // destructive
void write(const Address & paddr, uint8* data, int len); void write(const Address & paddr, uint8* data, int len);
uint8* read(const Address & paddr, uint8* data, int len); uint8* read(const Address & paddr, uint8* data, int len);
@ -71,7 +71,7 @@ inline
MemoryVector::MemoryVector(uint32 size) MemoryVector::MemoryVector(uint32 size)
: m_page_offset_mask(4095) : m_page_offset_mask(4095)
{ {
setSize(size); resize(size);
} }
inline inline
@ -86,7 +86,7 @@ MemoryVector::~MemoryVector()
} }
inline void inline void
MemoryVector::setSize(uint32 size) MemoryVector::resize(uint32 size)
{ {
if (m_pages != NULL){ if (m_pages != NULL){
for (int i = 0; i < m_num_pages; i++) { for (int i = 0; i < m_num_pages; i++) {

View file

@ -92,7 +92,7 @@ Sequencer::wakeup()
// Check across all outstanding requests // Check across all outstanding requests
int total_outstanding = 0; int total_outstanding = 0;
Vector<Address> keys = m_readRequestTable.keys(); std::vector<Address> keys = m_readRequestTable.keys();
for (int i = 0; i < keys.size(); i++) { for (int i = 0; i < keys.size(); i++) {
SequencerRequest* request = m_readRequestTable.lookup(keys[i]); SequencerRequest* request = m_readRequestTable.lookup(keys[i]);
if (current_time - request->issue_time >= m_deadlock_threshold) { if (current_time - request->issue_time >= m_deadlock_threshold) {
@ -160,7 +160,7 @@ Sequencer::printProgress(ostream& out) const
out << "---------------" << endl; out << "---------------" << endl;
out << "outstanding requests" << endl; out << "outstanding requests" << endl;
Vector<Address> rkeys = m_readRequestTable.keys(); std::vector<Address> rkeys = m_readRequestTable.keys();
int read_size = rkeys.size(); int read_size = rkeys.size();
out << "proc " << m_version << " Read Requests = " << read_size << endl; out << "proc " << m_version << " Read Requests = " << read_size << endl;
@ -174,7 +174,7 @@ Sequencer::printProgress(ostream& out) const
total_demand++; total_demand++;
} }
Vector<Address> wkeys = m_writeRequestTable.keys(); std::vector<Address> wkeys = m_writeRequestTable.keys();
int write_size = wkeys.size(); int write_size = wkeys.size();
out << "proc " << m_version << " Write Requests = " << write_size << endl; out << "proc " << m_version << " Write Requests = " << write_size << endl;

View file

@ -85,7 +85,7 @@ RubySystem::RubySystem(const Params *p)
m_mem_vec_ptr = NULL; m_mem_vec_ptr = NULL;
} else { } else {
m_mem_vec_ptr = new MemoryVector; m_mem_vec_ptr = new MemoryVector;
m_mem_vec_ptr->setSize(m_memory_size_bytes); m_mem_vec_ptr->resize(m_memory_size_bytes);
} }
// //

View file

@ -36,7 +36,6 @@
#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ #define __MEM_RUBY_SYSTEM_SYSTEM_HH__
#include "base/callback.hh" #include "base/callback.hh"
#include "mem/gems_common/Vector.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"
#include "mem/ruby/system/RubyPort.hh" #include "mem/ruby/system/RubyPort.hh"

View file

@ -108,7 +108,7 @@ TimerTable::updateNext() const
return; return;
} }
Vector<Address> addresses = m_map.keys(); std::vector<Address> addresses = m_map.keys();
m_next_address = addresses[0]; m_next_address = addresses[0];
m_next_time = m_map.lookup(m_next_address); m_next_time = m_map.lookup(m_next_address);

View file

@ -39,6 +39,8 @@
//#include "DMAGenerator.hh" //#include "DMAGenerator.hh"
#include "mem/ruby/tester/DetermGETXGenerator.hh" #include "mem/ruby/tester/DetermGETXGenerator.hh"
using namespace std;
#define DATA_BLOCK_BYTES 64 #define DATA_BLOCK_BYTES 64
DeterministicDriver::DeterministicDriver(string generator_type, int num_completions, int num_procs, Time g_think_time, Time g_wait_time, int g_tester_length) DeterministicDriver::DeterministicDriver(string generator_type, int num_completions, int num_procs, Time g_think_time, Time g_wait_time, int g_tester_length)
@ -56,22 +58,22 @@ DeterministicDriver::DeterministicDriver(string generator_type, int num_completi
m_wait_time = g_wait_time; m_wait_time = g_wait_time;
m_tester_length = g_tester_length; m_tester_length = g_tester_length;
m_last_progress_vector.setSize(num_procs); m_last_progress_vector.resize(num_procs);
for (int i=0; i<m_last_progress_vector.size(); i++) { for (int i=0; i<m_last_progress_vector.size(); i++) {
m_last_progress_vector[i] = 0; m_last_progress_vector[i] = 0;
} }
m_load_vector.setSize(10); m_load_vector.resize(10);
for (int i=0; i<m_load_vector.size(); i++) { for (int i=0; i<m_load_vector.size(); i++) {
m_load_vector[i] = -1; // No processor last held it m_load_vector[i] = -1; // No processor last held it
} }
m_store_vector.setSize(10); m_store_vector.resize(10);
for (int i=0; i<m_store_vector.size(); i++) { for (int i=0; i<m_store_vector.size(); i++) {
m_store_vector[i] = -1; // No processor last held it m_store_vector[i] = -1; // No processor last held it
} }
m_generator_vector.setSize(num_procs); m_generator_vector.resize(num_procs);
int generator = string_to_SpecifiedGeneratorType(generator_type); int generator = string_to_SpecifiedGeneratorType(generator_type);
@ -156,7 +158,7 @@ bool DeterministicDriver::isLoadReady(NodeID node, Address addr)
} }
// searches for any address in the addr_vector // searches for any address in the addr_vector
bool DeterministicDriver::isAddrReady(NodeID node, Vector<NodeID> addr_vector) bool DeterministicDriver::isAddrReady(NodeID node, vector<NodeID> addr_vector)
{ {
for (int i=0; i<addr_vector.size(); i++) { for (int i=0; i<addr_vector.size(); i++) {
if (((addr_vector[i]+1)%m_num_procs == node) && if (((addr_vector[i]+1)%m_num_procs == node) &&
@ -170,7 +172,7 @@ bool DeterministicDriver::isAddrReady(NodeID node, Vector<NodeID> addr_vector)
} }
// test for a particular addr // test for a particular addr
bool DeterministicDriver::isAddrReady(NodeID node, Vector<NodeID> addr_vector, Address addr) bool DeterministicDriver::isAddrReady(NodeID node, vector<NodeID> addr_vector, Address addr)
{ {
int addr_number = addr.getAddress()/DATA_BLOCK_BYTES; int addr_number = addr.getAddress()/DATA_BLOCK_BYTES;
@ -197,7 +199,7 @@ void DeterministicDriver::storeCompleted(NodeID node, Address addr)
setNextAddr(node, addr, m_store_vector); setNextAddr(node, addr, m_store_vector);
} }
void DeterministicDriver::setNextAddr(NodeID node, Address addr, Vector<NodeID>& addr_vector) void DeterministicDriver::setNextAddr(NodeID node, Address addr, vector<NodeID>& addr_vector)
{ {
// mark the addr vector that this proc was the last to use the particular address // mark the addr vector that this proc was the last to use the particular address
int addr_number = addr.getAddress()/DATA_BLOCK_BYTES; int addr_number = addr.getAddress()/DATA_BLOCK_BYTES;
@ -214,7 +216,7 @@ Address DeterministicDriver::getNextStoreAddr(NodeID node)
return getNextAddr(node, m_store_vector); return getNextAddr(node, m_store_vector);
} }
Address DeterministicDriver::getNextAddr(NodeID node, Vector<NodeID> addr_vector) Address DeterministicDriver::getNextAddr(NodeID node, vector<NodeID> addr_vector)
{ {
// This method deterministically picks the next addr the node should acquirer // This method deterministically picks the next addr the node should acquirer

View file

@ -36,7 +36,10 @@
#ifndef DETERMINISTICDRIVER_H #ifndef DETERMINISTICDRIVER_H
#define DETERMINISTICDRIVER_H #define DETERMINISTICDRIVER_H
#include <map> #include <map>
#include <vector>
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
#include "mem/ruby/tester/Tester_Globals.hh" #include "mem/ruby/tester/Tester_Globals.hh"
#include "mem/ruby/common/Histogram.hh" // includes global, but doesn't use anything, so it should be fine #include "mem/ruby/common/Histogram.hh" // includes global, but doesn't use anything, so it should be fine
@ -96,18 +99,18 @@ public:
private: private:
// Private Methods // Private Methods
Address getNextAddr(NodeID node, Vector<NodeID> addr_vector); Address getNextAddr(NodeID node, std::vector<NodeID> addr_vector);
bool isAddrReady(NodeID node, Vector<NodeID> addr_vector); bool isAddrReady(NodeID node, std::vector<NodeID> addr_vector);
bool isAddrReady(NodeID node, Vector<NodeID> addr_vector, Address addr); bool isAddrReady(NodeID node, std::vector<NodeID> addr_vector, Address addr);
void setNextAddr(NodeID node, Address addr, Vector<NodeID>& addr_vector); void setNextAddr(NodeID node, Address addr, std::vector<NodeID>& addr_vector);
// Data Members (m_ prefix) // Data Members (m_ prefix)
Vector<Time> m_last_progress_vector; std::vector<Time> m_last_progress_vector;
Vector<SpecifiedGenerator*> m_generator_vector; std::vector<SpecifiedGenerator*> m_generator_vector;
//DMAGenerator* m_dma_generator; //DMAGenerator* m_dma_generator;
Vector<NodeID> m_load_vector; // Processor last to load the addr std::vector<NodeID> m_load_vector; // Processor last to load the addr
Vector<NodeID> m_store_vector; // Processor last to store the addr std::vector<NodeID> m_store_vector; // Processor last to store the addr
int last_proc; int last_proc;
int m_done_counter; int m_done_counter;

View file

@ -50,7 +50,7 @@ RaceyDriver::RaceyDriver(int num_procs, int tester_length)
assert(m_num_procs >= 2); assert(m_num_procs >= 2);
// init all racey pseudo threads // init all racey pseudo threads
m_racey_pseudo_threads.setSize(m_num_procs); m_racey_pseudo_threads.resize(m_num_procs);
for (int i=0; i<m_racey_pseudo_threads.size(); i++) { for (int i=0; i<m_racey_pseudo_threads.size(); i++) {
m_racey_pseudo_threads[i] = new RaceyPseudoThread(i, *this); m_racey_pseudo_threads[i] = new RaceyPseudoThread(i, *this);
} }

View file

@ -37,11 +37,13 @@
#ifndef RACEYDRIVER_H #ifndef RACEYDRIVER_H
#define RACEYDRIVER_H #define RACEYDRIVER_H
#include <map>
#include <vector>
#include "mem/ruby/common/Global.hh" #include "mem/ruby/common/Global.hh"
#include "mem/ruby/tester/Tester_Globals.hh" #include "mem/ruby/tester/Tester_Globals.hh"
#include "mem/ruby/common/Driver.hh" #include "mem/ruby/common/Driver.hh"
#include "mem/ruby/tester/RaceyPseudoThread.hh" #include "mem/ruby/tester/RaceyPseudoThread.hh"
#include <map>
#include "mem/ruby/libruby.hh" #include "mem/ruby/libruby.hh"
#define g_DEADLOCK_THRESHOLD 5000 #define g_DEADLOCK_THRESHOLD 5000
@ -100,7 +102,7 @@ private:
RaceyDriver& operator=(const RaceyDriver& obj); RaceyDriver& operator=(const RaceyDriver& obj);
// Data Members (m_ prefix) // Data Members (m_ prefix)
Vector<RaceyPseudoThread*> m_racey_pseudo_threads; std::vector<RaceyPseudoThread*> m_racey_pseudo_threads;
int m_done_counter; int m_done_counter;
bool m_wakeup_thread0; bool m_wakeup_thread0;
Time m_finish_time; Time m_finish_time;

View file

@ -521,7 +521,7 @@ $vid = m_net_ptr->get${network}NetQueue(m_version + base, $ordered, $vnet);
if vtype.isBuffer: if vtype.isBuffer:
code(''' code('''
if (m_buffer_size > 0) { if (m_buffer_size > 0) {
$vid->setSize(m_buffer_size); $vid->resize(m_buffer_size);
} }
''') ''')