1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 36 unchanged lines hidden (view full) ---

45// Allows use of times() library call, which determines virtual runtime
46#include <sys/resource.h>
47#include <sys/times.h>
48
49#include <algorithm>
50
51#include "base/stl_helpers.hh"
52#include "base/str.hh"
53#include "mem/gems_common/Map.hh"
53#include "mem/gems_common/PrioHeap.hh"
54#include "mem/protocol/CacheMsg.hh"
55#include "mem/protocol/MachineType.hh"
56#include "mem/protocol/Protocol.hh"
57#include "mem/ruby/common/Debug.hh"
58#include "mem/ruby/network/Network.hh"
59#include "mem/ruby/profiler/AddressProfiler.hh"
60#include "mem/ruby/profiler/Profiler.hh"

--- 6 unchanged lines hidden (view full) ---

67extern ostream* debug_cout_ptr;
68
69static double process_memory_total();
70static double process_memory_resident();
71
72Profiler::Profiler(const Params *p)
73 : SimObject(p)
74{
76 m_requestProfileMap_ptr = new Map<string, int>;
77
75 m_inst_profiler_ptr = NULL;
76 m_address_profiler_ptr = NULL;
77
78 m_real_time_start_time = time(NULL); // Not reset in clearStats()
79 m_stats_period = 1000000; // Default
80 m_periodic_output_file_ptr = &cerr;
81
82 m_hot_lines = p->hot_lines;

--- 15 unchanged lines hidden (view full) ---

98 }
99}
100
101Profiler::~Profiler()
102{
103 if (m_periodic_output_file_ptr != &cerr) {
104 delete m_periodic_output_file_ptr;
105 }
109
110 delete m_requestProfileMap_ptr;
106}
107
108void
109Profiler::wakeup()
110{
111 // FIXME - avoid the repeated code
112
113 vector<integer_t> perProcCycleCount(m_num_of_sequencers);

--- 231 unchanged lines hidden (view full) ---

345 }
346 }
347
348 if (!short_stats) {
349 out << "Request vs. RubySystem State Profile" << endl;
350 out << "--------------------------------" << endl;
351 out << endl;
352
358 vector<string> requestProfileKeys = m_requestProfileMap_ptr->keys();
359 sort(requestProfileKeys.begin(), requestProfileKeys.end());
353 map<string, int>::const_iterator i = m_requestProfileMap.begin();
354 map<string, int>::const_iterator end = m_requestProfileMap.end();
355 for (; i != end; ++i) {
356 const string &key = i->first;
357 int count = i->second;
358
361 for (int i = 0; i < requestProfileKeys.size(); i++) {
362 int temp_int =
363 m_requestProfileMap_ptr->lookup(requestProfileKeys[i]);
364 double percent = (100.0 * double(temp_int)) / double(m_requests);
359 double percent = (100.0 * double(count)) / double(m_requests);
360 vector<string> items;
366 tokenize(items, requestProfileKeys[i], ':');
367 vector<string>::iterator i = items.begin();
361 tokenize(items, key, ':');
362 vector<string>::iterator j = items.begin();
363 vector<string>::iterator end = items.end();
369 for (; i != end; ++i)
370 out << setw(10) << *i;
371 out << setw(11) << temp_int;
364 for (; j != end; ++i)
365 out << setw(10) << *j;
366 out << setw(11) << count;
367 out << setw(14) << percent << endl;
368 }
369 out << endl;
370
371 out << "filter_action: " << m_filter_action_histogram << endl;
372
373 if (!m_all_instructions) {
374 m_address_profiler_ptr->printStats(out);

--- 95 unchanged lines hidden (view full) ---

470 m_sequencer_requests.clear();
471 m_read_sharing_histogram.clear();
472 m_write_sharing_histogram.clear();
473 m_all_sharing_histogram.clear();
474 m_cache_to_cache = 0;
475 m_memory_to_cache = 0;
476
477 // clear HashMaps
483 m_requestProfileMap_ptr->clear();
478 m_requestProfileMap.clear();
479
480 // count requests profiled
481 m_requests = 0;
482
483 m_outstanding_requests.clear();
484 m_outstanding_persistent_requests.clear();
485
486 // Flush the prefetches through the system - used so that there

--- 58 unchanged lines hidden (view full) ---

545}
546
547// profiles original cache requests including PUTs
548void
549Profiler::profileRequest(const string& requestStr)
550{
551 m_requests++;
552
558 if (m_requestProfileMap_ptr->exist(requestStr)) {
559 (m_requestProfileMap_ptr->lookup(requestStr))++;
560 } else {
561 m_requestProfileMap_ptr->add(requestStr, 1);
562 }
553 // if it doesn't exist, conveniently, it will be created with the
554 // default value which is 0
555 m_requestProfileMap[requestStr]++;
556}
557
558void
559Profiler::controllerBusy(MachineID machID)
560{
561 m_busyControllerCount[(int)machID.type][(int)machID.num]++;
562}
563

--- 103 unchanged lines hidden (view full) ---

667
668 ostream &out = *debug_cout_ptr;
669
670 out.flags(ios::right);
671 out << setw(TIME_SPACES) << g_eventQueue_ptr->getTime() << " ";
672 out << setw(ID_SPACES) << id << " "
673 << "RUBY WATCH " << watch_address << endl;
674
682 if (!m_watch_address_list_ptr->exist(watch_address)) {
683 m_watch_address_list_ptr->add(watch_address, 1);
684 }
675 // don't care about success or failure
676 m_watch_address_set.insert(watch_address);
677}
678
679bool
680Profiler::watchAddress(Address addr)
681{
690 if (m_watch_address_list_ptr->exist(addr))
691 return true;
692 else
693 return false;
682 return m_watch_address_set.count(addr) > 0;
683}
684
685Profiler *
686RubyProfilerParams::create()
687{
688 return new Profiler(this);
689}