HPCToolkit
DCPIProfile.hpp
Go to the documentation of this file.
1 // -*-Mode: C++;-*-
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 //***************************************************************************
48 //
49 // File:
50 // DCPIProfile.h
51 //
52 // Purpose:
53 // [The purpose of this file]
54 //
55 // Description:
56 // See, in particular, the comments associated with 'DCPIProfile'.
57 //
58 //***************************************************************************
59 
60 #ifndef DCPIProfile_H
61 #define DCPIProfile_H
62 
63 //************************* System Include Files ****************************
64 
65 #include <vector>
66 #include <map>
67 
68 //*************************** User Include Files ****************************
69 
70 #include <include/uint.h>
71 
72 #include "PCProfile.hpp"
73 #include "DCPIProfileMetric.hpp"
74 #include "DCPIProfileFilter.hpp"
75 
76 #include <lib/isa/ISATypes.hpp>
77 
78 //*************************** Forward Declarations ***************************
79 
80 //****************************************************************************
81 // DCPIProfile
82 //****************************************************************************
83 
84 // 'DCPIProfile' extensions to 'PCProfile' for representing data
85 // resulting from DEC/Compaq/HP DCPI profiles (including ProfileMe).
86 class DCPIProfile : public PCProfile
87 {
88 public:
89  enum PMMode {
90  PM_NONE, // No ProfileMe events
91  PM0, // ProfileMe mode 0
92  PM1, // ProfileMe mode 1
93  PM2, // ProfileMe mode 2
94  PM3 // ProfileMe mode 3
95  };
96 
97 public:
98  DCPIProfile(ISA* isa_, unsigned int sz = 256);
99  virtual ~DCPIProfile();
100 
101  // Access to 'DCPIProfileMetric' (includes casts)
102  const DCPIProfileMetric* DCPIGetMetric(unsigned int i) const {
103  return dynamic_cast<const DCPIProfileMetric*>(Index(i));
104  }
105  void SetDCPIMetric(unsigned int i, DCPIProfileMetric* m) { Assign(i, m); }
106 
107  PMMode GetPMMode() const { return pmmode; }
108  void SetPMMode(PMMode x) { pmmode = x; }
109 
110  void dump(std::ostream& o = std::cerr);
111  void ddump();
112 
113 private:
114  // Should not be used
115  DCPIProfile(const DCPIProfile& p);
116  DCPIProfile& operator=(const DCPIProfile& p) { return *this; }
117 
119 
120 protected:
121 private:
123 };
124 
125 // 'DCPIProfileMetricSetIterator' iterates over all 'DCPIProfileMetric'
126 // within a 'DCPIProfile'.
128 {
129 public:
131  : p(x), it(x) { }
133 
135  return dynamic_cast<DCPIProfileMetric*>(it.Current());
136  }
137 
138  void operator++() { it++; } // prefix
139  void operator++(int) { ++it; } // postfix
140 
141  bool IsValid() const { return it.IsValid(); }
142  bool IsEmpty() const { return it.IsEmpty(); }
143 
144  // Reset and prepare for iteration again
145  void Reset() { it.Reset(); }
146 
147 private:
148  // Should not be used
152  { return *this; }
153 
154 protected:
155 private:
156  const DCPIProfile& p;
158 };
159 
160 //****************************************************************************
161 
162 #endif
163 
void Assign(unsigned int i, const PCProfileMetric *m)
Definition: PCProfile.hpp:119
const PCProfileMetric * Index(unsigned int i) const
Definition: PCProfile.hpp:116
const DCPIProfileMetric * DCPIGetMetric(unsigned int i) const
friend class DCPIProfileMetricSetIterator
void dump(std::ostream &o=std::cerr)
Definition: DCPIProfile.cpp:88
virtual ~DCPIProfile()
Definition: DCPIProfile.cpp:83
DCPIProfile & operator=(const DCPIProfile &p)
void SetDCPIMetric(unsigned int i, DCPIProfileMetric *m)
PMMode GetPMMode() const
DCPIProfileMetricSetIterator(const DCPIProfile &x)
DCPIProfileMetricSetIterator & operator=(const DCPIProfileMetricSetIterator &x)
Definition: ISA.hpp:106
DCPIProfile(ISA *isa_, unsigned int sz=256)
Definition: DCPIProfile.cpp:78
void SetPMMode(PMMode x)
PCProfileMetricSetIterator it
DCPIProfileMetric * Current()
void ddump()
Definition: DCPIProfile.cpp:95