diff options
author | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:07 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:07 -0700 |
commit | 006818aeea6176c4500c5f7414e9f2a822c77062 (patch) | |
tree | 74adbd6cc14951943bd6eafc4aba2fb98be7a526 /src/mem/ruby/profiler | |
parent | bc87fa30d72df7db6265be50b2c39dc218076f9f (diff) | |
download | gem5-006818aeea6176c4500c5f7414e9f2a822c77062.tar.xz |
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
Diffstat (limited to 'src/mem/ruby/profiler')
-rw-r--r-- | src/mem/ruby/profiler/AddressProfiler.cc | 15 | ||||
-rw-r--r-- | src/mem/ruby/profiler/CacheProfiler.cc | 15 | ||||
-rw-r--r-- | src/mem/ruby/profiler/CacheProfiler.hh | 5 | ||||
-rw-r--r-- | src/mem/ruby/profiler/MemCntrlProfiler.cc | 2 | ||||
-rw-r--r-- | src/mem/ruby/profiler/MemCntrlProfiler.hh | 6 | ||||
-rw-r--r-- | src/mem/ruby/profiler/Profiler.cc | 30 | ||||
-rw-r--r-- | src/mem/ruby/profiler/Profiler.hh | 17 |
7 files changed, 46 insertions, 44 deletions
diff --git a/src/mem/ruby/profiler/AddressProfiler.cc b/src/mem/ruby/profiler/AddressProfiler.cc index d11e74b01..2c099a914 100644 --- a/src/mem/ruby/profiler/AddressProfiler.cc +++ b/src/mem/ruby/profiler/AddressProfiler.cc @@ -26,6 +26,9 @@ * 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/PrioHeap.hh" #include "mem/protocol/CacheMsg.hh" @@ -37,6 +40,8 @@ using namespace std; typedef AddressProfiler::AddressMap AddressMap; +using m5::stl_helpers::operator<<; + // Helper functions AccessTraceForAddress& 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; PrioHeap<AccessTraceForAddress*> heap; - Vector<Address> keys = record_map->keys(); + std::vector<Address> keys = record_map->keys(); for (int i = 0; i < keys.size(); i++) { AccessTraceForAddress* record = &(record_map->lookup(keys[i])); misses += record->getTotal(); @@ -77,10 +82,10 @@ printSorted(ostream& out, int num_of_sequencers, const AddressMap* record_map, Histogram all_records_log(-1); // Allows us to track how many lines where touched by n processors - Vector<int64> m_touched_vec; - Vector<int64> m_touched_weighted_vec; - m_touched_vec.setSize(num_of_sequencers+1); - m_touched_weighted_vec.setSize(num_of_sequencers+1); + std::vector<int64> m_touched_vec; + std::vector<int64> m_touched_weighted_vec; + m_touched_vec.resize(num_of_sequencers+1); + m_touched_weighted_vec.resize(num_of_sequencers+1); for (int i = 0; i < m_touched_vec.size(); i++) { m_touched_vec[i] = 0; m_touched_weighted_vec[i] = 0; diff --git a/src/mem/ruby/profiler/CacheProfiler.cc b/src/mem/ruby/profiler/CacheProfiler.cc index f359314c1..7dc925322 100644 --- a/src/mem/ruby/profiler/CacheProfiler.cc +++ b/src/mem/ruby/profiler/CacheProfiler.cc @@ -27,7 +27,6 @@ */ #include "mem/gems_common/PrioHeap.hh" -#include "mem/gems_common/Vector.hh" #include "mem/ruby/profiler/AccessTraceForAddress.hh" #include "mem/ruby/profiler/CacheProfiler.hh" #include "mem/ruby/profiler/Profiler.hh" @@ -36,17 +35,15 @@ using namespace std; CacheProfiler::CacheProfiler(const string& description) + : m_requestTypeVec(int(CacheRequestType_NUM)) { m_description = description; - m_requestTypeVec_ptr = new Vector<int>; - m_requestTypeVec_ptr->setSize(int(CacheRequestType_NUM)); clearStats(); } CacheProfiler::~CacheProfiler() { - delete m_requestTypeVec_ptr; } void @@ -65,18 +62,18 @@ CacheProfiler::printStats(ostream& out) const int requests = 0; for (int i = 0; i < int(CacheRequestType_NUM); i++) { - requests += m_requestTypeVec_ptr->ref(i); + requests += m_requestTypeVec[i]; } assert(m_misses == requests); if (requests > 0) { 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_" << CacheRequestType_to_string(CacheRequestType(i)) << ": " - << 100.0 * (double)m_requestTypeVec_ptr->ref(i) / + << 100.0 * (double)m_requestTypeVec[i] / (double)requests << "%" << endl; } @@ -103,7 +100,7 @@ void CacheProfiler::clearStats() { for (int i = 0; i < int(CacheRequestType_NUM); i++) { - m_requestTypeVec_ptr->ref(i) = 0; + m_requestTypeVec[i] = 0; } m_requestSize.clear(); m_misses = 0; @@ -123,7 +120,7 @@ CacheProfiler::addStatSample(CacheRequestType requestType, { m_misses++; - m_requestTypeVec_ptr->ref(requestType)++; + m_requestTypeVec[requestType]++; m_accessModeTypeHistogram[type]++; m_requestSize.add(msgSize); diff --git a/src/mem/ruby/profiler/CacheProfiler.hh b/src/mem/ruby/profiler/CacheProfiler.hh index 7dcdf57f0..fad60711b 100644 --- a/src/mem/ruby/profiler/CacheProfiler.hh +++ b/src/mem/ruby/profiler/CacheProfiler.hh @@ -31,6 +31,7 @@ #include <iostream> #include <string> +#include <vector> #include "mem/protocol/AccessModeType.hh" #include "mem/protocol/CacheRequestType.hh" @@ -39,8 +40,6 @@ #include "mem/ruby/common/Histogram.hh" #include "mem/ruby/system/NodeID.hh" -template <class TYPE> class Vector; - class CacheProfiler { public: @@ -69,7 +68,7 @@ class CacheProfiler int64 m_hw_prefetches; int64 m_accessModeTypeHistogram[AccessModeType_NUM]; - Vector <int>* m_requestTypeVec_ptr; + std::vector<int> m_requestTypeVec; }; inline std::ostream& diff --git a/src/mem/ruby/profiler/MemCntrlProfiler.cc b/src/mem/ruby/profiler/MemCntrlProfiler.cc index e25719666..632842a2e 100644 --- a/src/mem/ruby/profiler/MemCntrlProfiler.cc +++ b/src/mem/ruby/profiler/MemCntrlProfiler.cc @@ -39,7 +39,7 @@ MemCntrlProfiler::MemCntrlProfiler(const string& description, m_dimms_per_channel = dimms_per_channel; int totalBanks = banks_per_rank * ranks_per_dimm * dimms_per_channel; - m_memBankCount.setSize(totalBanks); + m_memBankCount.resize(totalBanks); clearStats(); } diff --git a/src/mem/ruby/profiler/MemCntrlProfiler.hh b/src/mem/ruby/profiler/MemCntrlProfiler.hh index 85c39e0ad..e6d64a2b5 100644 --- a/src/mem/ruby/profiler/MemCntrlProfiler.hh +++ b/src/mem/ruby/profiler/MemCntrlProfiler.hh @@ -31,12 +31,10 @@ #include <iostream> #include <string> +#include <vector> -#include "mem/gems_common/Vector.hh" #include "mem/ruby/common/Global.hh" -template <class TYPE> class Vector; - class MemCntrlProfiler { public: @@ -86,7 +84,7 @@ private: uint64 m_memArbWait; uint64 m_memRandBusy; uint64 m_memNotOld; - Vector<uint64> m_memBankCount; + std::vector<uint64> m_memBankCount; int m_banks_per_rank; int m_ranks_per_dimm; int m_dimms_per_channel; diff --git a/src/mem/ruby/profiler/Profiler.cc b/src/mem/ruby/profiler/Profiler.cc index aa23388ee..bbc3c5846 100644 --- a/src/mem/ruby/profiler/Profiler.cc +++ b/src/mem/ruby/profiler/Profiler.cc @@ -46,6 +46,9 @@ #include <sys/resource.h> #include <sys/times.h> +#include <algorithm> + +#include "base/stl_helpers.hh" #include "base/str.hh" #include "mem/gems_common/Map.hh" #include "mem/gems_common/PrioHeap.hh" @@ -60,6 +63,7 @@ #include "mem/ruby/system/System.hh" using namespace std; +using m5::stl_helpers::operator<<; extern ostream* debug_cout_ptr; @@ -111,8 +115,7 @@ Profiler::wakeup() { // FIXME - avoid the repeated code - Vector<integer_t> perProcCycleCount; - perProcCycleCount.setSize(m_num_of_sequencers); + vector<integer_t> perProcCycleCount(m_num_of_sequencers); for (int i = 0; i < m_num_of_sequencers; i++) { perProcCycleCount[i] = @@ -235,8 +238,7 @@ Profiler::printStats(ostream& out, bool short_stats) out << endl; } - Vector<integer_t> perProcCycleCount; - perProcCycleCount.setSize(m_num_of_sequencers); + vector<integer_t> perProcCycleCount(m_num_of_sequencers); for (int i = 0; i < m_num_of_sequencers; i++) { perProcCycleCount[i] = @@ -353,8 +355,8 @@ Profiler::printStats(ostream& out, bool short_stats) out << "--------------------------------" << endl; out << endl; - Vector<string> requestProfileKeys = m_requestProfileMap_ptr->keys(); - requestProfileKeys.sortVector(); + vector<string> requestProfileKeys = m_requestProfileMap_ptr->keys(); + sort(requestProfileKeys.begin(), requestProfileKeys.end()); for (int i = 0; i < requestProfileKeys.size(); i++) { int temp_int = @@ -423,7 +425,7 @@ Profiler::clearStats() { 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++) { if (g_system_ptr == NULL) { 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++) { int size = MachineType_base_count((MachineType)i); - m_busyControllerCount[i].setSize(size); + m_busyControllerCount[i].resize(size); for (int j = 0; j < size; j++) { m_busyControllerCount[i][j] = 0; } @@ -445,26 +447,26 @@ Profiler::clearStats() m_delayedCyclesHistogram.clear(); m_delayedCyclesNonPFHistogram.clear(); int size = RubySystem::getNetwork()->getNumberOfVirtualNetworks(); - m_delayedCyclesVCHistograms.setSize(size); + m_delayedCyclesVCHistograms.resize(size); for (int i = 0; i < size; i++) { m_delayedCyclesVCHistograms[i].clear(); } - m_missLatencyHistograms.setSize(RubyRequestType_NUM); + m_missLatencyHistograms.resize(RubyRequestType_NUM); for (int i = 0; i < m_missLatencyHistograms.size(); i++) { 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++) { m_machLatencyHistograms[i].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++) { 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++) { m_SWPrefetchMachLatencyHistograms[i].clear(200); } diff --git a/src/mem/ruby/profiler/Profiler.hh b/src/mem/ruby/profiler/Profiler.hh index bb2187488..5d8650dec 100644 --- a/src/mem/ruby/profiler/Profiler.hh +++ b/src/mem/ruby/profiler/Profiler.hh @@ -47,6 +47,7 @@ #include <iostream> #include <string> +#include <vector> #include "mem/protocol/AccessModeType.hh" #include "mem/protocol/AccessType.hh" @@ -166,8 +167,8 @@ class Profiler : public SimObject, public Consumer AddressProfiler* m_address_profiler_ptr; AddressProfiler* m_inst_profiler_ptr; - Vector<int64> m_instructions_executed_at_start; - Vector<int64> m_cycles_executed_at_start; + std::vector<int64> m_instructions_executed_at_start; + std::vector<int64> m_cycles_executed_at_start; std::ostream* m_periodic_output_file_ptr; integer_t m_stats_period; @@ -175,7 +176,7 @@ class Profiler : public SimObject, public Consumer Time m_ruby_start; 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; Histogram m_multicast_retry_histogram; @@ -191,18 +192,18 @@ class Profiler : public SimObject, public Consumer Histogram m_prefetchWaitHistogram; - Vector<Histogram> m_missLatencyHistograms; - Vector<Histogram> m_machLatencyHistograms; + std::vector<Histogram> m_missLatencyHistograms; + std::vector<Histogram> m_machLatencyHistograms; Histogram m_allMissLatencyHistogram; Histogram m_allSWPrefetchLatencyHistogram; Histogram m_SWPrefetchL2MissLatencyHistogram; - Vector<Histogram> m_SWPrefetchLatencyHistograms; - Vector<Histogram> m_SWPrefetchMachLatencyHistograms; + std::vector<Histogram> m_SWPrefetchLatencyHistograms; + std::vector<Histogram> m_SWPrefetchMachLatencyHistograms; Histogram m_delayedCyclesHistogram; Histogram m_delayedCyclesNonPFHistogram; - Vector<Histogram> m_delayedCyclesVCHistograms; + std::vector<Histogram> m_delayedCyclesVCHistograms; Histogram m_outstanding_requests; Histogram m_outstanding_persistent_requests; |