| OLD | NEW |
| 1 //===- subzero/src/IceTimerTree.h - Pass timer defs -------------*- C++ -*-===// | 1 //===- subzero/src/IceTimerTree.h - Pass timer defs -------------*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 /// |
| 10 // This file declares the TimerTree class, which allows flat and | 10 /// \file |
| 11 // cumulative execution time collection of call chains. | 11 /// This file declares the TimerTree class, which allows flat and |
| 12 // | 12 /// cumulative execution time collection of call chains. |
| 13 /// |
| 13 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 14 | 15 |
| 15 #ifndef SUBZERO_SRC_ICETIMERTREE_H | 16 #ifndef SUBZERO_SRC_ICETIMERTREE_H |
| 16 #define SUBZERO_SRC_ICETIMERTREE_H | 17 #define SUBZERO_SRC_ICETIMERTREE_H |
| 17 | 18 |
| 18 // TODO(jpp): Refactor IceDefs. | 19 // TODO(jpp): Refactor IceDefs. |
| 19 #include "IceDefs.h" | 20 #include "IceDefs.h" |
| 20 #include "IceTimerTree.def" | 21 #include "IceTimerTree.def" |
| 21 | 22 |
| 22 namespace Ice { | 23 namespace Ice { |
| 23 | 24 |
| 24 class TimerStack { | 25 class TimerStack { |
| 25 TimerStack() = delete; | 26 TimerStack() = delete; |
| 26 TimerStack &operator=(const TimerStack &) = delete; | 27 TimerStack &operator=(const TimerStack &) = delete; |
| 27 | 28 |
| 28 // Timer tree index type. A variable of this type is used to access | 29 /// Timer tree index type. A variable of this type is used to access |
| 29 // an interior, not-necessarily-leaf node of the tree. | 30 /// an interior, not-necessarily-leaf node of the tree. |
| 30 typedef std::vector<class TimerTreeNode>::size_type TTindex; | 31 typedef std::vector<class TimerTreeNode>::size_type TTindex; |
| 31 // Representation of a path of leaf values leading to a particular | 32 /// Representation of a path of leaf values leading to a particular |
| 32 // node. The representation happens to be in "reverse" order, | 33 /// node. The representation happens to be in "reverse" order, |
| 33 // i.e. from leaf/interior to root, for implementation efficiency. | 34 /// i.e. from leaf/interior to root, for implementation efficiency. |
| 34 typedef llvm::SmallVector<TTindex, 8> PathType; | 35 typedef llvm::SmallVector<TTindex, 8> PathType; |
| 35 // Representation of a mapping of leaf node indexes from one timer | 36 /// Representation of a mapping of leaf node indexes from one timer |
| 36 // stack to another. | 37 /// stack to another. |
| 37 typedef std::vector<TimerIdT> TranslationType; | 38 typedef std::vector<TimerIdT> TranslationType; |
| 38 | 39 |
| 39 // TimerTreeNode represents an interior or leaf node in the call tree. | 40 /// TimerTreeNode represents an interior or leaf node in the call tree. |
| 40 // It contains a list of children, a pointer to its parent, and the | 41 /// It contains a list of children, a pointer to its parent, and the |
| 41 // timer ID for the node. It also holds the cumulative time spent at | 42 /// timer ID for the node. It also holds the cumulative time spent at |
| 42 // this node and below. The children are always at a higher index in | 43 /// this node and below. The children are always at a higher index in |
| 43 // the TimerTreeNode::Nodes array, and the parent is always at a lower | 44 /// the TimerTreeNode::Nodes array, and the parent is always at a lower |
| 44 // index. | 45 /// index. |
| 45 class TimerTreeNode { | 46 class TimerTreeNode { |
| 46 TimerTreeNode &operator=(const TimerTreeNode &) = delete; | 47 TimerTreeNode &operator=(const TimerTreeNode &) = delete; |
| 47 | 48 |
| 48 public: | 49 public: |
| 49 TimerTreeNode() = default; | 50 TimerTreeNode() = default; |
| 50 TimerTreeNode(const TimerTreeNode &) = default; | 51 TimerTreeNode(const TimerTreeNode &) = default; |
| 51 std::vector<TTindex> Children; // indexed by TimerIdT | 52 std::vector<TTindex> Children; // indexed by TimerIdT |
| 52 TTindex Parent = 0; | 53 TTindex Parent = 0; |
| 53 TimerIdT Interior = 0; | 54 TimerIdT Interior = 0; |
| 54 double Time = 0; | 55 double Time = 0; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 77 void update(bool UpdateCounts); | 78 void update(bool UpdateCounts); |
| 78 static double timestamp(); | 79 static double timestamp(); |
| 79 TranslationType translateIDsFrom(const TimerStack &Src); | 80 TranslationType translateIDsFrom(const TimerStack &Src); |
| 80 PathType getPath(TTindex Index, const TranslationType &Mapping) const; | 81 PathType getPath(TTindex Index, const TranslationType &Mapping) const; |
| 81 TTindex getChildIndex(TTindex Parent, TimerIdT ID); | 82 TTindex getChildIndex(TTindex Parent, TimerIdT ID); |
| 82 TTindex findPath(const PathType &Path); | 83 TTindex findPath(const PathType &Path); |
| 83 IceString Name; | 84 IceString Name; |
| 84 double FirstTimestamp; | 85 double FirstTimestamp; |
| 85 double LastTimestamp; | 86 double LastTimestamp; |
| 86 uint64_t StateChangeCount = 0; | 87 uint64_t StateChangeCount = 0; |
| 87 // IDsIndex maps a symbolic timer name to its integer ID. | 88 /// IDsIndex maps a symbolic timer name to its integer ID. |
| 88 std::map<IceString, TimerIdT> IDsIndex; | 89 std::map<IceString, TimerIdT> IDsIndex; |
| 89 std::vector<IceString> IDs; // indexed by TimerIdT | 90 std::vector<IceString> IDs; /// indexed by TimerIdT |
| 90 std::vector<TimerTreeNode> Nodes; // indexed by TTindex | 91 std::vector<TimerTreeNode> Nodes; /// indexed by TTindex |
| 91 std::vector<double> LeafTimes; // indexed by TimerIdT | 92 std::vector<double> LeafTimes; /// indexed by TimerIdT |
| 92 std::vector<size_t> LeafCounts; // indexed by TimerIdT | 93 std::vector<size_t> LeafCounts; /// indexed by TimerIdT |
| 93 TTindex StackTop = 0; | 94 TTindex StackTop = 0; |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 } // end of namespace Ice | 97 } // end of namespace Ice |
| 97 | 98 |
| 98 #endif // SUBZERO_SRC_ICETIMERTREE_H | 99 #endif // SUBZERO_SRC_ICETIMERTREE_H |
| OLD | NEW |