Profiler.cc (7565:9fc3475e8175) | Profiler.cc (7832:de7601e6e19d) |
---|---|
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; --- 33 unchanged lines hidden (view full) --- 42 ---------------------------------------------------------------------- 43*/ 44 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> | 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; --- 33 unchanged lines hidden (view full) --- 42 ---------------------------------------------------------------------- 43*/ 44 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#include <fstream> |
|
50 51#include "base/stl_helpers.hh" 52#include "base/str.hh" 53#include "mem/protocol/CacheMsg.hh" 54#include "mem/protocol/MachineType.hh" 55#include "mem/protocol/Protocol.hh" | 51 52#include "base/stl_helpers.hh" 53#include "base/str.hh" 54#include "mem/protocol/CacheMsg.hh" 55#include "mem/protocol/MachineType.hh" 56#include "mem/protocol/Protocol.hh" |
56#include "mem/ruby/common/Debug.hh" | |
57#include "mem/ruby/network/Network.hh" 58#include "mem/ruby/profiler/AddressProfiler.hh" 59#include "mem/ruby/profiler/Profiler.hh" 60#include "mem/ruby/system/System.hh" 61#include "mem/ruby/system/System.hh" 62 63using namespace std; 64using m5::stl_helpers::operator<<; 65 | 57#include "mem/ruby/network/Network.hh" 58#include "mem/ruby/profiler/AddressProfiler.hh" 59#include "mem/ruby/profiler/Profiler.hh" 60#include "mem/ruby/system/System.hh" 61#include "mem/ruby/system/System.hh" 62 63using namespace std; 64using m5::stl_helpers::operator<<; 65 |
66extern ostream* debug_cout_ptr; 67 | |
68static double process_memory_total(); 69static double process_memory_resident(); 70 71Profiler::Profiler(const Params *p) 72 : SimObject(p) 73{ 74 m_inst_profiler_ptr = NULL; 75 m_address_profiler_ptr = NULL; --- 616 unchanged lines hidden (view full) --- 692 m_SWPrefetchLatencyHistograms[type].add(cycles); 693 m_SWPrefetchMachLatencyHistograms[respondingMach].add(cycles); 694 if (respondingMach == GenericMachineType_Directory || 695 respondingMach == GenericMachineType_NUM) { 696 m_SWPrefetchL2MissLatencyHistogram.add(cycles); 697 } 698} 699 | 66static double process_memory_total(); 67static double process_memory_resident(); 68 69Profiler::Profiler(const Params *p) 70 : SimObject(p) 71{ 72 m_inst_profiler_ptr = NULL; 73 m_address_profiler_ptr = NULL; --- 616 unchanged lines hidden (view full) --- 690 m_SWPrefetchLatencyHistograms[type].add(cycles); 691 m_SWPrefetchMachLatencyHistograms[respondingMach].add(cycles); 692 if (respondingMach == GenericMachineType_Directory || 693 respondingMach == GenericMachineType_NUM) { 694 m_SWPrefetchL2MissLatencyHistogram.add(cycles); 695 } 696} 697 |
700void 701Profiler::profileTransition(const string& component, NodeID version, 702 Address addr, const string& state, const string& event, 703 const string& next_state, const string& note) 704{ 705 const int EVENT_SPACES = 20; 706 const int ID_SPACES = 3; 707 const int TIME_SPACES = 7; 708 const int COMP_SPACES = 10; 709 const int STATE_SPACES = 6; 710 711 if (g_debug_ptr->getDebugTime() <= 0 || 712 g_eventQueue_ptr->getTime() < g_debug_ptr->getDebugTime()) 713 return; 714 715 ostream &out = *debug_cout_ptr; 716 out.flags(ios::right); 717 out << setw(TIME_SPACES) << g_eventQueue_ptr->getTime() << " "; 718 out << setw(ID_SPACES) << version << " "; 719 out << setw(COMP_SPACES) << component; 720 out << setw(EVENT_SPACES) << event << " "; 721 722 out.flags(ios::right); 723 out << setw(STATE_SPACES) << state; 724 out << ">"; 725 out.flags(ios::left); 726 out << setw(STATE_SPACES) << next_state; 727 728 out << " " << addr << " " << note; 729 730 out << endl; 731} 732 | |
733// Helper function 734static double 735process_memory_total() 736{ 737 // 4kB page size, 1024*1024 bytes per MB, 738 const double MULTIPLIER = 4096.0 / (1024.0 * 1024.0); 739 ifstream proc_file; 740 proc_file.open("/proc/self/statm"); --- 18 unchanged lines hidden (view full) --- 759 return double(res_size_in_pages) * MULTIPLIER; // size in megabytes 760} 761 762void 763Profiler::rubyWatch(int id) 764{ 765 uint64 tr = 0; 766 Address watch_address = Address(tr); | 698// Helper function 699static double 700process_memory_total() 701{ 702 // 4kB page size, 1024*1024 bytes per MB, 703 const double MULTIPLIER = 4096.0 / (1024.0 * 1024.0); 704 ifstream proc_file; 705 proc_file.open("/proc/self/statm"); --- 18 unchanged lines hidden (view full) --- 724 return double(res_size_in_pages) * MULTIPLIER; // size in megabytes 725} 726 727void 728Profiler::rubyWatch(int id) 729{ 730 uint64 tr = 0; 731 Address watch_address = Address(tr); |
767 const int ID_SPACES = 3; 768 const int TIME_SPACES = 7; | |
769 | 732 |
770 ostream &out = *debug_cout_ptr; | 733 DPRINTFN("%7s %3s RUBY WATCH %d\n", g_eventQueue_ptr->getTime(), id, 734 watch_address); |
771 | 735 |
772 out.flags(ios::right); 773 out << setw(TIME_SPACES) << g_eventQueue_ptr->getTime() << " "; 774 out << setw(ID_SPACES) << id << " " 775 << "RUBY WATCH " << watch_address << endl; 776 | |
777 // don't care about success or failure 778 m_watch_address_set.insert(watch_address); 779} 780 781bool 782Profiler::watchAddress(Address addr) 783{ 784 return m_watch_address_set.count(addr) > 0; 785} 786 787Profiler * 788RubyProfilerParams::create() 789{ 790 return new Profiler(this); 791} | 736 // don't care about success or failure 737 m_watch_address_set.insert(watch_address); 738} 739 740bool 741Profiler::watchAddress(Address addr) 742{ 743 return m_watch_address_set.count(addr) > 0; 744} 745 746Profiler * 747RubyProfilerParams::create() 748{ 749 return new Profiler(this); 750} |