HPCToolkit
CCT-Tree.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 // $HeadURL$
51 //
52 // Purpose:
53 // [The purpose of this file]
54 //
55 // Description:
56 // [The set of functions, macros, etc. defined in the file]
57 //
58 //***************************************************************************
59 
60 #ifndef prof_Prof_CCT_Tree_hpp
61 #define prof_Prof_CCT_Tree_hpp
62 
63 //************************* System Include Files ****************************
64 
65 #include <iostream>
66 
67 #include <string>
68 #include <vector>
69 #include <list>
70 #include <set>
71 
72 #include <typeinfo>
73 
74 #include <cstring> // for memcpy
75 
76 //*************************** User Include Files ****************************
77 
78 #include <include/uint.h>
79 
80 #include "CCT-Merge.hpp"
81 
82 #include "Metric-Mgr.hpp"
83 #include "Metric-ADesc.hpp"
84 #include "Metric-IData.hpp"
85 
86 #include "Struct-Tree.hpp"
87 
88 #include "LoadMap.hpp"
89 #include "Metric-Mgr.hpp"
90 
91 #include <lib/isa/ISATypes.hpp>
92 
95 
96 #include <lib/binutils/VMAInterval.hpp> // TODO
97 
98 #include <lib/xml/xml.hpp>
99 
100 #include <lib/support/diagnostics.h>
102 #include <lib/support/SrcFile.hpp>
103 #include <lib/support/Unique.hpp>
104 
105 
106 //*************************** Forward Declarations ***************************
107 
108 inline std::ostream&
109 operator<<(std::ostream& os, const hpcrun_metricVal_t x)
110 {
111  os << "[" << x.i << " " << x.r << "]";
112  return os;
113 }
114 
115 
116 //***************************************************************************
117 // Tree
118 //***************************************************************************
119 
120 namespace Prof {
121 
122 namespace CallPath {
123  class Profile;
124 }
125 
126 
127 namespace CCT {
128 
129 class ANode;
130 
131 
132 class Tree
133  : public Unique
134 {
135 public:
136 
137  enum {
138  // Output flags
139  OFlg_Compressed = (1 << 0), // Write in compressed format
140  OFlg_LeafMetricsOnly = (1 << 1), // Write metrics only at leaves (outdated)
141  OFlg_Debug = (1 << 2), // Debug: show xtra source line info
142  OFlg_DebugAll = (1 << 3), // Debug: (may be invalid format)
143  OFlg_StructId = (1 << 4) // Add hpcstruct node id (for debug)
144  };
145 
146 
147 public:
148  // -------------------------------------------------------
149  // Constructor/Destructor
150  // -------------------------------------------------------
151 
152  Tree(const CallPath::Profile* metadata);
153 
154  virtual ~Tree();
155 
156  // -------------------------------------------------------
157  // Tree data
158  // -------------------------------------------------------
159  ANode*
160  root() const
161  { return m_root; }
162 
163  void
165  { m_root = x; }
166 
167  bool
168  empty() const
169  { return (m_root == NULL); }
170 
171  const CallPath::Profile*
172  metadata() const
173  { return m_metadata; }
174 
175  // -------------------------------------------------------
176  // Given a Tree, merge into 'this'
177  // -------------------------------------------------------
179  merge(const Tree* y, uint x_newMetricBegIdx,
180  uint mrgFlag = 0, uint oFlag = 0);
181 
182  // -------------------------------------------------------
183  // dense ids (only used when explicitly requested)
184  // -------------------------------------------------------
185 
186  // makeDensePreorderIds: deterministically creates dense ids,
187  // reserving 0 as a NULL (unused) id; returns maxDenseId()
188  uint
189  makeDensePreorderIds();
190 
191  // maxDenseId(): returns the maximum id actually used
192  uint
193  maxDenseId() const
194  { return m_maxDenseId; }
195 
196  // -------------------------------------------------------
197  // nodeId -> ANode map (built on demand)
198  // -------------------------------------------------------
199 
200  ANode*
201  findNode(uint nodeId) const;
202 
203  // -------------------------------------------------------
204  //
205  // -------------------------------------------------------
206 
207  // pruneCCTByNodeId
208  void
209  pruneCCTByNodeId(const uint8_t* prunedNodes);
210 
211  // -------------------------------------------------------
212  //
213  // -------------------------------------------------------
214 
215  // verifyUniqueCPIds: Ensure all the cpIds in the Tree are unique.
216  bool
217  verifyUniqueCPIds();
218 
219  // -------------------------------------------------------
220  // Write contents
221  // -------------------------------------------------------
222  std::ostream&
223  writeXML(std::ostream& os,
224  const Metric::Mgr *metricMgr,
225  uint metricBeg = Metric::IData::npos,
226  uint metricEnd = Metric::IData::npos,
227  uint oFlags = 0) const;
228 
229  std::ostream&
230  dump(const Metric::Mgr *metricMgr, std::ostream& os = std::cerr, uint oFlags = 0) const;
231 
232  void
233  ddump(const Metric::Mgr *metricMgr) const;
234 
235  int getNumNodeId() {
236  if (m_nodeidMap)
237  return m_nodeidMap->size();
238  return 0;
239  }
240 
241  // Given a set of flags 'flags', determines whether we need to
242  // ensure that certain characters are escaped. Returns xml::ESC_TRUE
243  // or xml::ESC_FALSE.
244  static int
245  doXMLEscape(uint oFlags);
246 
247 public:
248  typedef std::map<uint, ANode*> NodeIdToANodeMap;
249 
250 
251 private:
252  // CCT and metadata for interpreting CCT (e.g., metrics)
254  const CallPath::Profile* m_metadata; // does not own
255 
256  // dense id
258  mutable NodeIdToANodeMap* m_nodeidMap;
259 
260  // merge information, cached here for performance
262 };
263 
264 
265 } // namespace CCT
266 
267 } // namespace Prof
268 
269 
270 //***************************************************************************
271 // ANode
272 //***************************************************************************
273 
274 namespace Prof {
275 
276 namespace CCT {
277 
278 class ANode; // Everyone's base class
279 class ADynNode;
280 class AProcNode;
281 
282 class Root;
283 
284 class ProcFrm;
285 class Proc;
286 class Loop;
287 class Call;
288 class Stmt;
289 
290 // ---------------------------------------------------------
291 // ANode: The base node for a call stack profile tree.
292 // ---------------------------------------------------------
293 class ANode
294  : public NonUniformDegreeTreeNode,
295  public Metric::IData,
296  public Unique
297 {
298 public:
299  typedef std::vector<ANode*> Vec;
300 
301 public:
302  enum ANodeTy {
303  TyRoot = 0,
310  TyNUMBER
311  };
312 
313  static const std::string&
314  ANodeTyToName(ANodeTy tp);
315 
316  static ANodeTy
317  IntToANodeType(long i);
318 
319 
320 private:
321  static const std::string NodeNames[TyNUMBER];
322 
323 
324 public:
325  ANode(ANodeTy type, ANode* parent, Struct::ACodeNode* strct = NULL)
326  : NonUniformDegreeTreeNode(parent),
327  Metric::IData(),
328  m_type(type), m_hpcrun_type(NODE_TYPE_REGULAR), m_id(s_nextUniqueId), m_strct(strct)
329  {
330  s_nextUniqueId += 2; // cf. HPCRUN_FMT_RetainIdFlag
331  }
332 
334  ANode* parent, Struct::ACodeNode* strct, const Metric::IData& metrics)
335  : NonUniformDegreeTreeNode(parent),
336  Metric::IData(metrics),
337  m_type(type), m_hpcrun_type(NODE_TYPE_REGULAR),m_id(s_nextUniqueId), m_strct(strct)
338  {
339  s_nextUniqueId += 2; // cf. HPCRUN_FMT_RetainIdFlag
340  }
341 
342  virtual ~ANode()
343  { }
344 
345  // deep copy of internals (but without children)
346  ANode(const ANode& x)
348  Metric::IData(x),
349  m_type(x.m_type), m_hpcrun_type(NODE_TYPE_REGULAR), /*m_id: skip*/ m_strct(x.m_strct)
350  {
351  zeroLinks();
352  s_nextUniqueId += 2; // cf. HPCRUN_FMT_RetainIdFlag
353  }
354 
355  // deep copy of internals (but without children)
356  ANode&
357  operator=(const ANode& x)
358  {
359  if (this != &x) {
360  //NonUniformDegreeTreeNode::operator=(x);
362  m_type = x.m_type;
363  // m_id: skip
364  m_strct = x.m_strct;
365  }
366  return *this;
367  }
368 
369 
370  // --------------------------------------------------------
371  // General data
372  // --------------------------------------------------------
373  ANodeTy
374  type() const
375  { return m_type; }
376 
377 
378  // id: a unique id; 0 is reserved for a NULL value
379  //
380  // N.B.: To support reading/writing, ids must be consistent with
381  // HPCRUN_FMT_RetainIdFlag.
382  uint
383  id() const
384  { return m_id; }
385 
386 
387  void
388  id(uint id)
389  { m_id = id; }
390 
391 
392  // 'name()' is overridden by some derived classes
393  virtual const std::string&
394  name() const
395  { return ANodeTyToName(type()); }
396 
397 
398  // structure: static structure id for this node; the same static
399  // structure will have the same structure().
401  structure() const
402  { return m_strct; }
403 
404  void
406  { m_strct = const_cast<Struct::ACodeNode*>(strct); }
407 
408  uint
409  structureId() const
410  { return (m_strct) ? m_strct->id() : 0; }
411 
413  begLine() const
414  { return (m_strct) ? m_strct->begLine() : ln_NULL; }
415 
417  endLine() const
418  { return (m_strct) ? m_strct->endLine() : ln_NULL; }
419 
420 
421  void
422  hpcrun_node_type(uint16_t type)
423  { m_hpcrun_type = type; }
424 
425  uint16_t
427  { return m_hpcrun_type; }
428 
429 
430  // --------------------------------------------------------
431  // Tree navigation
432  // --------------------------------------------------------
433  ANode*
434  parent() const
435  { return static_cast<ANode*>(NonUniformDegreeTreeNode::Parent()); }
436 
437  ANode*
438  firstChild() const
439  { return static_cast<ANode*>(NonUniformDegreeTreeNode::FirstChild()); }
440 
441  ANode*
442  lastChild() const
443  { return static_cast<ANode*>(NonUniformDegreeTreeNode::LastChild()); }
444 
445  ANode*
446  nextSibling() const
447  {
448  // siblings are linked in a circular list
449  if (parent()->lastChild() != this) {
450  return dynamic_cast<ANode*>(NonUniformDegreeTreeNode::NextSibling());
451  }
452  return NULL;
453  }
454 
455  ANode*
456  prevSibling() const
457  {
458  // siblings are linked in a circular list
459  if (parent()->firstChild() != this) {
460  return dynamic_cast<ANode*>(NonUniformDegreeTreeNode::PrevSibling());
461  }
462  return NULL;
463  }
464 
465 
466  // --------------------------------------------------------
467  // ancestor: find first ANode in path from this to root with given type
468  // (Note: We assume that a node *can* be an ancestor of itself.)
469  // --------------------------------------------------------
470  ANode*
471  ancestor(ANodeTy tp) const;
472 
473  Root*
474  ancestorRoot() const;
475 
476  ProcFrm*
477  ancestorProcFrm() const;
478 
479  Proc*
480  ancestorProc() const;
481 
482  Loop*
483  ancestorLoop() const;
484 
485  Call*
486  ancestorCall() const;
487 
488  Stmt*
489  ancestorStmt() const;
490 
491 
492  // --------------------------------------------------------
493  // Metrics (cf. Struct::ANode)
494  // N.B.: Intervals are in the form: [mBegId, mEndId)
495  // --------------------------------------------------------
496 
497  void
498  zeroMetricsDeep(uint mBegId, uint mEndId);
499 
500 
501  // aggregateMetricsIncl: aggregates metrics for inclusive CCT
502  // metrics. [mBegId, mEndId) forms an interval for batch processing.
503  void
504  aggregateMetricsIncl(uint mBegId, uint mEndId);
505 
506  void
507  aggregateMetricsIncl(const VMAIntervalSet& ivalset);
508 
509  void
511  { aggregateMetricsIncl(mBegId, mBegId + 1); }
512 
513 
514  // aggregateMetricsExcl: aggregates metrics for exclusive CCT
515  // metrics. [mBegId, mEndId) forms an interval for batch processing.
516  void
517  aggregateMetricsExcl(uint mBegId, uint mEndId);
518 
519  void
520  aggregateMetricsExcl(const VMAIntervalSet& ivalset);
521 
522  void
524  { aggregateMetricsExcl(mBegId, mBegId + 1); }
525 
526 private:
527  //
528  // laks 2015.10.21: we don't want accumulate the exclusive cost of
529  // an inlined statement to the caller. Instead, we assume an inline
530  // function (Proc) as the same as a normal procedure (ProcFrm).
531  // And the lowest common ancestor for Proc and ProcFrm is AProcNode.
532  void
533  aggregateMetricsExcl(AProcNode* frame, const VMAIntervalSet& ivalset);
534 
535 public:
536  // computeMetrics: compute this subtree's Metric::DerivedDesc metric
537  // values for metric ids [mBegId, mEndId)
538  // computeMetricsMe: same, but for the node (not the subtree)
539  void
540  computeMetrics(const Metric::Mgr& mMgr, uint mBegId, uint mEndId,
541  bool doFinal);
542 
543  void
544  computeMetricsMe(const Metric::Mgr& mMgr, uint mBegId, uint mEndId,
545  bool doFinal);
546 
547 
548  // computeMetricsIncr: compute this subtree's Metric::DerivedIncrDesc metric
549  // values for metric ids [mBegId, mEndId)
550  // computeMetricsIncrMe: same, but for the node (not the subtree)
551  void
552  computeMetricsIncr(const Metric::Mgr& mMgr, uint mBegId, uint mEndId,
554 
555  void
556  computeMetricsIncrMe(const Metric::Mgr& mMgr, uint mBegId, uint mEndId,
558 
559  // pruneByMetrics: TODO: make this static for consistency
560  void
561  pruneByMetrics(const Metric::Mgr& mMgr, const VMAIntervalSet& ivalset,
562  const ANode* root, double thresholdPct,
563  uint8_t* prunedNodes = NULL);
564 
565  // pruneChildrenByNodeId:
566  void
567  pruneChildrenByNodeId(const uint8_t* prunedNodes);
568 
569  // pruneByNodeId: Note that 'x' may be deleted
570  static void
571  pruneByNodeId(ANode*& x, const uint8_t* prunedNodes);
572 
573  // deleteChaff: deletes all subtrees y in x for which y has no
574  // persistant 'cpId'. Returns true if subtree x was deleted; false
575  // otherwise. If 'deletedNodes' is non-NULL, records all deleted
576  // nodes (assuming dense node ids).
577  static bool
578  deleteChaff(ANode* x, uint8_t* deletedNodes = NULL);
579 
580 public:
581 
582  // --------------------------------------------------------
583  // merging
584  // --------------------------------------------------------
585 
586  // mergeDeep: Let 'this' = x and let y be a node corresponding to x
587  // in the sense that we may think of y as being locally merged
588  // with x (according to ADynNode::isMergable()). Given y,
589  // recursively merge y's children into x.
590  // N.B.: assume we can destroy y.
591  // N.B.: assume x already has space to store merged metrics
592  std::list<MergeEffect>*
593  mergeDeep(ANode* y, uint x_numMetrics, MergeContext& mrgCtxt, uint oFlag = 0);
594 
595 
596  // merge: Let 'this' = x and let y be a node corresponding to x.
597  // Merge y into x.
598  // N.B.: assume we can destroy y.
600  merge(ANode* y);
601 
602 
603  virtual MergeEffect
604  mergeMe(const ANode& y, MergeContext* mrgCtxt = NULL, uint metricBegIdx = 0, bool mayConflict = true);
605 
606 
607  // findDynChild: Let z = 'this' be an interior ADynNode (otherwise the
608  // return value is trivially NULL). Given an ADynNode y_dyn, finds
609  // the first direct ADynNode descendent x_dyn, if any, for which
610  // ADynNode::isMergable(x_dyn, y_dyn) holds.
611  //
612  // If the CCT does not have structure information, we only need to
613  // inspect the children of z. Otherwise, it is necessary to find
614  // the collection of z's direct ADynNode descendents.
616  findDynChild(const ADynNode& y_dyn);
617 
618 
619  // --------------------------------------------------------
620  //
621  // --------------------------------------------------------
622 
623  // makeDensePreorderIds: given the *next* id to use, return the
624  // *next* id to use
625  uint
626  makeDensePreorderIds(uint nextId);
627 
628 
629  // --------------------------------------------------------
630  // Output
631  // --------------------------------------------------------
632 
633  virtual std::string
634  toString(const Metric::Mgr *metricMgr, uint oFlags = 0, const char* pfx = "") const;
635 
636  virtual std::string
637  toStringMe(uint oFlags = 0) const;
638 
639  std::ostream&
640  writeXML(std::ostream& os,
641  const Metric::Mgr *metricMgr,
642  uint metricBeg = Metric::IData::npos,
643  uint metricEnd = Metric::IData::npos,
644  uint oFlags = 0, const char* pfx = "") const;
645 
646 
647  std::ostream&
648  writeXML_path(std::ostream& os,
649  const Metric::Mgr *metricMgr,
650  uint metricBeg = Metric::IData::npos,
651  uint metricEnd = Metric::IData::npos,
652  uint oFlags = 0, const char* pfx = "") const;
653 
654  std::ostream&
655  dump(const Metric::Mgr *metricMgr,
656  std::ostream& os = std::cerr, uint oFlags = 0, const char* pfx = "") const;
657 
658  void
659  adump(const Metric::Mgr *metricMgr) const;
660 
661  void
662  ddump(const Metric::Mgr *metricMgr) const;
663 
664  void
665  ddumpMe() const;
666 
667  virtual std::string
668  codeName() const;
669 
670 protected:
671 
672  bool
673  writeXML_pre(std::ostream& os, const Metric::Mgr *metricMgr,
674  uint metricBeg = Metric::IData::npos,
675  uint metricEnd = Metric::IData::npos,
676  uint oFlags = 0,
677  const char* pfx = "") const;
678  void
679  writeXML_post(std::ostream& os, uint oFlags = 0, const char* pfx = "") const;
680 
681  // --------------------------------------------------------
682  // Makes room for new metrics. Also checks and resolves
683  // any cpId conflicts between 2 trees.
684  // --------------------------------------------------------
685 
687  mergeDeep_fixInsert(int newMetrics, MergeContext& mrgCtxt);
688 
689 
690 private:
692 
693 protected:
694  ANodeTy m_type; // obsolete with typeid(), but hard to replace
695  uint16_t m_hpcrun_type; // hpcrun's node type: memory access, root, variable declaration, ...
697 
699 };
700 
701 
702 // - if x < y; 0 if x == y; + otherwise
703 int ANodeLineComp(ANode* x, ANode* y);
704 
705 
706 //***************************************************************************
707 // ADynNode
708 //***************************************************************************
709 
710 // ---------------------------------------------------------
711 // ADynNode: represents dynamic nodes
712 // ---------------------------------------------------------
713 class ADynNode
714  : public ANode
715 {
716 public:
717 
718  // -------------------------------------------------------
719  //
720  // -------------------------------------------------------
721 
722  ADynNode(ANodeTy type, ANode* parent, Struct::ACodeNode* strct, uint cpId)
723  : ANode(type, parent, strct),
724  m_cpId(cpId),
725  m_as_info(lush_assoc_info_NULL),
726  m_lmId(LoadMap::LMId_NULL), m_lmIP(0), m_opIdx(0), m_lip(NULL)
727  { }
728 
729  ADynNode(ANodeTy type, ANode* parent, Struct::ACodeNode* strct,
730  uint cpId, hpcrun_fmt_cct_node_t node_fmt,
731  LoadMap::LMId_t lmId, VMA ip, ushort opIdx, lush_lip_t* lip)
732  : ANode(type, parent, strct),
733  m_cpId(cpId),
734  m_as_info(node_fmt.as_info),
735  m_lmId(lmId), m_lmIP(ip), m_opIdx(opIdx), m_lip(lip)
736  { m_hpcrun_type = node_fmt.node_type; }
737 
738  ADynNode(ANodeTy type, ANode* parent, Struct::ACodeNode* strct,
739  uint cpId, hpcrun_fmt_cct_node_t node_fmt,
740  LoadMap::LMId_t lmId, VMA ip, ushort opIdx, lush_lip_t* lip,
741  const Metric::IData& metrics)
742  : ANode(type, parent, strct, metrics),
743  m_cpId(cpId),
744  m_as_info(node_fmt.as_info),
745  m_lmId(lmId), m_lmIP(ip), m_opIdx(opIdx), m_lip(lip)
746  { m_hpcrun_type = node_fmt.node_type; }
747 
748  virtual ~ADynNode()
749  { delete m_lip; }
750 
751  // deep copy of internals (but without children)
752  ADynNode(const ADynNode& x)
753  : ANode(x),
754  m_cpId(x.m_cpId),
755  m_as_info(x.m_as_info),
756  m_lmId(x.m_lmId),
757  m_lmIP(x.m_lmIP), m_opIdx(x.m_opIdx),
758  m_lip(clone_lip(x.m_lip))
759  {
760  m_hpcrun_type = x.m_hpcrun_type;
761  }
762 
763  // deep copy of internals (but without children)
764  ADynNode&
765  operator=(const ADynNode& x)
766  {
767  if (this != &x) {
768  ANode::operator=(x);
769  m_cpId = x.m_cpId;
770  m_as_info = x.m_as_info;
771  m_hpcrun_type = x.m_hpcrun_type;
772  m_lmId = x.m_lmId;
773  m_lmIP = x.m_lmIP;
774  m_opIdx = x.m_opIdx;
775  delete m_lip;
776  m_lip = clone_lip(x.m_lip);
777  }
778  return *this;
779  }
780 
781 
782  // -------------------------------------------------------
783  // call path id
784  // -------------------------------------------------------
785 
786  // call path id: a persistent call path id (persistent in the sense
787  // that it must be consistent with hpctrace). 0 is reserved as a
788  // NULL value.
789 
790  uint
791  cpId() const
792  { return m_cpId; }
793 
794 
795  void
796  cpId(uint id)
797  { m_cpId = id; }
798 
799 
800  // -------------------------------------------------------
801  // logical unwinding association
802  // -------------------------------------------------------
803 
805  assocInfo() const
806  { return m_as_info; }
807 
808  void
810  { m_as_info = x; }
811 
813  assoc() const
814  { return lush_assoc_info__get_assoc(m_as_info); }
815 
816 
817  // -------------------------------------------------------
818  // load-module id, ip
819  // (N.B.: a load-module-ip is a static ip as opposed to a run-time ip)
820  // -------------------------------------------------------
821 
823  lmId() const
824  {
825  if (isValid_lip()) { return lush_lip_getLMId(m_lip); }
826  return m_lmId;
827  }
828 
830  lmId_real() const
831  { return m_lmId; }
832 
833  void
835  {
836  if (isValid_lip()) { lush_lip_setLMId(m_lip, (uint16_t)x); return; }
837  m_lmId = x;
838  }
839 
840  void
842  { m_lmId = x; }
843 
844  virtual VMA
845  lmIP() const
846  {
847  if (isValid_lip()) {
848  return lush_lip_getLMIP(m_lip);
849  }
850  return m_lmIP;
851  }
852 
853  VMA
854  lmIP_real() const
855  { return m_lmIP; }
856 
857  void
858  lmIP(VMA lmIP, ushort opIdx)
859  {
860  if (isValid_lip()) {
861  lush_lip_setLMIP(m_lip, lmIP);
862  m_opIdx = 0;
863  return;
864  }
865  m_lmIP = lmIP;
866  m_opIdx = opIdx;
867  }
868 
869  ushort
870  opIndex() const
871  { return m_opIdx; }
872 
873 
874  // -------------------------------------------------------
875  // logical ip
876  // -------------------------------------------------------
877 
878  lush_lip_t*
879  lip() const
880  { return m_lip; }
881 
882  void
883  lip(const lush_lip_t* lip)
884  { m_lip = const_cast<lush_lip_t*>(lip); }
885 
886  static lush_lip_t*
888  {
889  lush_lip_t* x_clone = NULL;
890  if (x) {
891  x_clone = new lush_lip_t;
892  memcpy(x_clone, x, sizeof(lush_lip_t));
893  }
894  return x_clone;
895  }
896 
897  bool
898  isValid_lip() const
899  { return (m_lip && (lush_lip_getLMId(m_lip) != 0)); }
900 
901  // -------------------------------------------------------
902  //
903  // -------------------------------------------------------
904 
905  bool
907  {
908  return (m_lmId == LoadMap::LMId_NULL && m_lmIP == HPCRUN_FMT_LMIp_NULL);
909  }
910 
911 
912  bool
914  {
915  return (m_lmId == LoadMap::LMId_NULL && m_lmIP == HPCRUN_FMT_LMIp_Flag1);
916  }
917 
918 
919  // -------------------------------------------------------
920  // merging
921  // -------------------------------------------------------
922 
923  static Struct::ACodeNode *
925  {
926  if (n->type() != Struct::ANode::TyProc) n = n->ACodeNodeParent();
927  return n;
928  }
929 
930  static bool
931  isMergable(const ADynNode& x, const ADynNode& y)
932  {
933  if (x.isLeaf() == y.isLeaf()
934  && x.lmId_real() == y.lmId_real()) {
935 
936  // 1. additional tests for standard merge condition (N.B.: order
937  // is based on early failure rather than conceptual grouping)
938  if (x.lmIP_real() == y.lmIP_real()
939  && lush_lip_eq(x.lip(), y.lip())
940  && lush_assoc_class_eq(x.assoc(), y.assoc())
942  return true;
943  }
944 
945  // 2. special merge condition for hpcprof-mpi when IPs have been
946  // lost after Analysis::CallPath::coalesceStmts(CallPath::Profile).
947  // (Typically, merges occur before structure information is
948  // added, so this will turn into a nop in the common case.)
949  Struct::ACodeNode* x_strct = x.structure();
950  Struct::ACodeNode* y_strct = y.structure();
951  if (x.isLeaf() && (x_strct && y_strct) // x & y are structured leaves
952  // fast and slow cases when (a) CCT scopes obey
953  // Non-Overlapping Principle and (b) when they don't.
954  && ((x_strct == y_strct) ||
955  (ancestorIfNotProc(x_strct) == ancestorIfNotProc(y_strct)
956  && x_strct->begLine() == y_strct->begLine()) )) {
957  return true;
958  }
959  }
960 
961  return false;
962  }
963 
964 
965  static bool
966  hasMergeEffects(const ADynNode& x, const ADynNode& y)
967  {
968  // form 1: !( (x == y) || (x == 0) || (y == 0) )
969  // form 2: (x != y) && (x != 0) && (y != 0)
970  return (x.cpId() != y.cpId()
972  && y.cpId() != HPCRUN_FMT_CCTNodeId_NULL);
973  }
974 
975 
976  virtual MergeEffect
977  mergeMe(const ANode& y, MergeContext* mrgCtxt = NULL, uint metricBegIdx = 0, bool mayConflict = true);
978 
979 
980  // -------------------------------------------------------
981  // Dump contents for inspection
982  // -------------------------------------------------------
983 
984  std::string
985  assocInfo_str() const;
986 
987  std::string
988  lip_str() const;
989 
990  std::string
991  nameDyn() const;
992 
993  void
994  writeDyn(std::ostream& os, uint oFlags = 0, const char* prefix = "") const;
995 
996 
997 private:
998  uint m_cpId; // dynamic id
999 
1001 
1002  LoadMap::LMId_t m_lmId; // LoadMap::LM id
1003  VMA m_lmIP; // static instruction pointer
1004  ushort m_opIdx; // index in the instruction [OBSOLETE]
1005 
1006  lush_lip_t* m_lip; // logical ip
1007 };
1008 
1009 
1010 //***************************************************************************
1011 // AProcNode
1012 //***************************************************************************
1013 
1014 // ---------------------------------------------------------
1015 // AProcNode: represents procedure nodes
1016 // ---------------------------------------------------------
1018  : public ANode
1019 {
1020 public:
1021 
1022  // -------------------------------------------------------
1023  //
1024  // -------------------------------------------------------
1025 
1026  AProcNode(ANodeTy type, ANode* parent, Struct::ACodeNode* strct)
1027  : ANode(type, parent, strct)
1028  { }
1029 
1030  virtual ~AProcNode()
1031  { }
1032 
1033  // deep copy of internals (but without children)
1035  : ANode(x)
1036  { }
1037 
1038  // deep copy of internals (but without children)
1039  AProcNode&
1041  {
1042  if (this != &x) {
1043  ANode::operator=(x);
1044  }
1045  return *this;
1046  }
1047 
1048 
1049  // --------------------------------------------------------
1050  // Static structure for ProcFrm/Proc
1051  // --------------------------------------------------------
1052 
1053  virtual const std::string&
1054  lmName() const
1055  { return (m_strct) ? m_strct->ancestorLM()->name() : BOGUS; }
1056 
1057  virtual uint
1058  lmId() const
1059  { return (m_strct) ? m_strct->ancestorLM()->id() : 0; }
1060 
1061 
1062  virtual const std::string&
1063  fileName() const
1064  {
1065  if (m_strct) {
1066  return (isAlien()) ?
1067  static_cast<Struct::Alien*>(m_strct)->fileName() :
1068  m_strct->ancestorFile()->name();
1069  }
1070  else {
1071  return BOGUS;
1072  }
1073  }
1074 
1075  virtual uint
1076  fileId() const
1077  {
1078  uint id = 0;
1079  if (m_strct) {
1080  id = (isAlien()) ? m_strct->id() : m_strct->ancestorFile()->id();
1081  }
1082  return id;
1083  }
1084 
1085  virtual const std::string&
1086  procName() const
1087  { return (m_strct) ? m_strct->name() : BOGUS; }
1088 
1089  virtual uint
1090  procId() const
1091  { return (m_strct) ? m_strct->id() : 0; }
1092 
1093 
1094  virtual bool
1095  isAlien() const = 0;
1096 
1097 
1098 protected:
1099  static std::string BOGUS;
1100 
1101 private:
1102 };
1103 
1104 
1105 //***************************************************************************
1106 //
1107 //***************************************************************************
1108 
1109 // --------------------------------------------------------------------------
1110 // Root
1111 // --------------------------------------------------------------------------
1112 
1113 class Root
1114  : public ANode
1115 {
1116 public:
1117  // Constructor/Destructor
1118  Root(const std::string& nm)
1119  : ANode(TyRoot, NULL),
1120  m_name(nm)
1121  { }
1122 
1123  Root(const char* nm)
1124  : ANode(TyRoot, NULL),
1125  m_name((nm) ? nm : "")
1126  { }
1127 
1128  virtual ~Root()
1129  { }
1130 
1131  const std::string&
1132  name() const { return m_name; }
1133 
1134  // Dump contents for inspection
1135  virtual std::string
1136  toStringMe(uint oFlags = 0) const;
1137 
1138 protected:
1139 private:
1140  std::string m_name; // the program name
1141 };
1142 
1143 
1144 // --------------------------------------------------------------------------
1145 // ProcFrm
1146 // --------------------------------------------------------------------------
1147 
1148 class ProcFrm
1149  : public AProcNode
1150 {
1151 public:
1152  // Constructor/Destructor
1154  : AProcNode(TyProcFrm, parent, strct)
1155  { }
1156 
1157  virtual ~ProcFrm()
1158  { }
1159 
1160  // shallow copy (in the sense the children are not copied)
1161  ProcFrm(const ProcFrm& x)
1162  : AProcNode(x)
1163  { }
1164 
1165 
1166  // -------------------------------------------------------
1167  // Static structure (NOTE: m_strct is always Struct::Proc)
1168  // -------------------------------------------------------
1169 
1170  virtual const std::string&
1171  fileName() const
1172  { return (m_strct) ? m_strct->ancestorFile()->name() : BOGUS; }
1173 
1174  virtual uint
1175  fileId() const
1176  { return (m_strct) ? m_strct->ancestorFile()->id() : 0; }
1177 
1178  virtual bool
1179  isAlien() const
1180  { return false; }
1181 
1182  std::string
1183  procNameDbg() const;
1184 
1185 
1186  // -------------------------------------------------------
1187  //
1188  // -------------------------------------------------------
1189 
1190  virtual std::string
1191  toStringMe(uint oFlags = 0) const;
1192 
1193  virtual std::string
1194  codeName() const;
1195 
1196 private:
1197 };
1198 
1199 
1200 // --------------------------------------------------------------------------
1201 // Proc:
1202 // --------------------------------------------------------------------------
1203 
1204 class Proc
1205  : public AProcNode
1206 {
1207 public:
1208  // Constructor/Destructor
1209  Proc(ANode* parent, Struct::ACodeNode* strct = NULL)
1210  : AProcNode(TyProc, parent, strct)
1211  { }
1212 
1213  virtual ~Proc()
1214  { }
1215 
1216 
1217  // -------------------------------------------------------
1218  // Static structure (NOTE: m_strct is either Struct::Proc or Struct::Alien)
1219  // -------------------------------------------------------
1220 
1221  virtual bool
1222  isAlien() const
1223  { return (m_strct && typeid(*m_strct) == typeid(Struct::Alien)); }
1224 
1225 
1226  // -------------------------------------------------------
1227  //
1228  // -------------------------------------------------------
1229 
1230  virtual std::string
1231  toStringMe(uint oFlags = 0) const;
1232 
1233 private:
1234 };
1235 
1236 
1237 // --------------------------------------------------------------------------
1238 // Loop
1239 // --------------------------------------------------------------------------
1240 
1241 class Loop
1242  : public ANode
1243 {
1244 public:
1245  // Constructor/Destructor
1246  Loop(ANode* parent, Struct::ACodeNode* strct = NULL)
1247  : ANode(TyLoop, parent, strct)
1248  { }
1249 
1250  virtual uint
1251  fileId() const
1252  {
1253  uint id = 0;
1254  if (m_strct) {
1255  id = m_strct->id();
1256  }
1257  return id;
1258  }
1259 
1260  virtual ~Loop()
1261  { }
1262 
1263  // Dump contents for inspection
1264  virtual std::string
1265  toStringMe(uint oFlags = 0) const;
1266 
1267 private:
1268 };
1269 
1270 
1271 // --------------------------------------------------------------------------
1272 // Call (callsite)
1273 // --------------------------------------------------------------------------
1274 
1275 class Call
1276  : public ADynNode
1277 {
1278 public:
1279  // Constructor/Destructor
1280  Call(ANode* parent, uint cpId)
1281  : ADynNode(TyCall, parent, NULL, cpId)
1282  { }
1283 
1284  Call(ANode* parent,
1285  uint cpId, hpcrun_fmt_cct_node_t node_fmt,
1286  LoadMap::LMId_t lmId, VMA ip, ushort opIdx, lush_lip_t* lip,
1287  const Metric::IData& metrics)
1288  : ADynNode(TyCall, parent, NULL,
1289  cpId, node_fmt, lmId, ip, opIdx, lip,
1290  metrics)
1291  { }
1292 
1293  virtual ~Call()
1294  { }
1295 
1296  // Node data
1297  virtual VMA
1298  lmIP() const
1299  {
1300  VMA ip = ADynNode::lmIP_real();
1301  if (isValid_lip()) {
1302  ip = lush_lip_getLMIP(lip());
1303  }
1304  // if IP is non-zero, subtract 1 from IP of return
1305  // to move it into range for the preceeding call instruction
1306  return (ip != 0) ? (ip - 1) : 0;
1307  }
1308 
1309  // lmRA(): static (as opposed to run-time) return address
1310  VMA
1311  lmRA() const
1312  { return ADynNode::lmIP_real(); }
1313 
1314  // Dump contents for inspection
1315  virtual std::string
1316  toStringMe(uint oFlags = 0) const;
1317 
1318 };
1319 
1320 
1321 // --------------------------------------------------------------------------
1322 // Stmt
1323 // --------------------------------------------------------------------------
1324 
1325 class Stmt
1326  : public ADynNode
1327 {
1328  public:
1329  // Constructor/Destructor
1330  Stmt(ANode* parent, uint cpId)
1331  : ADynNode(TyStmt, parent, NULL, cpId),
1332  m_id_node_alloc(0), m_node_alloc(NULL), m_start_address(0)
1333  { }
1334 
1335  Stmt(ANode* parent,
1336  uint cpId, hpcrun_fmt_cct_node_t node_fmt,
1337  LoadMap::LMId_t lmId, VMA ip, ushort opIdx, lush_lip_t* lip,
1338  const Metric::IData& metrics)
1339  : ADynNode(TyStmt, parent, NULL,
1340  cpId, node_fmt, lmId, ip, opIdx, lip,
1341  metrics), m_id_node_alloc(0), m_node_alloc(NULL), m_start_address(0)
1342  { }
1343 
1344  virtual ~Stmt()
1345  { }
1346 
1347  Stmt&
1348  operator=(const Stmt& x)
1349  {
1350  if (this != &x) {
1351  ADynNode::operator=(x);
1352  }
1353  return *this;
1354  }
1355 
1356  void
1358  {
1359  m_id_node_alloc = id;
1360  }
1361 
1362  uint
1364  {
1365  return m_id_node_alloc;
1366  }
1367 
1368  void
1369  start_address(uint64_t address)
1370  {
1371  m_start_address = address;
1372  }
1373 
1374  uint64_t
1376  {
1377  return m_start_address;
1378  }
1379 
1380  void
1382  {
1383  m_node_alloc = node;
1384  }
1385 
1386  ANode *
1388  {
1389  return m_node_alloc;
1390  }
1391 
1392  // Dump contents for inspection
1393  virtual std::string
1394  toStringMe(uint oFlags = 0) const;
1395 
1396  private:
1397  uint m_id_node_alloc; // id of allocated node (temporary storage)
1398  ANode *m_node_alloc; // pointer to the allocated variable node. Only for dynamic variables
1399  uint64_t m_start_address; // start of the variable address. Useful for static variables
1400 };
1401 
1402 
1403 } // namespace CCT
1404 
1405 } // namespace Prof
1406 
1407 
1408 //***************************************************************************
1409 
1410 #include "CCT-TreeIterator.hpp"
1411 
1412 //***************************************************************************
1413 
1414 
1415 #endif /* prof_Prof_CCT_Tree_hpp */
Struct::ACodeNode * structure() const
Definition: CCT-Tree.hpp:401
uint16_t hpcrun_node_type() const
Definition: CCT-Tree.hpp:426
int getNumNodeId()
Definition: CCT-Tree.hpp:235
lush_lip_t * m_lip
Definition: CCT-Tree.hpp:1006
ANode * node_alloc()
Definition: CCT-Tree.hpp:1387
ANode * parent() const
Definition: CCT-Tree.hpp:434
uint structureId() const
Definition: CCT-Tree.hpp:409
ADynNode & operator=(const ADynNode &x)
Definition: CCT-Tree.hpp:765
AProcNode(ANodeTy type, ANode *parent, Struct::ACodeNode *strct)
Definition: CCT-Tree.hpp:1026
static void lush_lip_setLMId(lush_lip_t *x, uint16_t lmId)
Definition: lush-support.h:374
unsigned int ln
Definition: SrcFile.hpp:66
void aggregateMetricsExcl(uint mBegId)
Definition: CCT-Tree.hpp:523
virtual const std::string & fileName() const
Definition: CCT-Tree.hpp:1171
bfd_vma VMA
Definition: ISATypes.hpp:79
virtual uint procId() const
Definition: CCT-Tree.hpp:1090
Call(ANode *parent, uint cpId)
Definition: CCT-Tree.hpp:1280
lush_lip_t * lip() const
Definition: CCT-Tree.hpp:879
ADynNode(const ADynNode &x)
Definition: CCT-Tree.hpp:752
NonUniformDegreeTreeNode * NextSibling() const
virtual bool isAlien() const
Definition: CCT-Tree.hpp:1179
const std::string & name() const
Definition: CCT-Tree.hpp:1132
static bool hasMergeEffects(const ADynNode &x, const ADynNode &y)
Definition: CCT-Tree.hpp:966
Struct::ACodeNode * m_strct
Definition: CCT-Tree.hpp:698
void writeXML(std::ostream &os, const Prof::Struct::Tree &strctTree, bool prettyPrint)
std::list< MergeEffect > MergeEffectList
Definition: CCT-Merge.hpp:126
ANode * m_node_alloc
Definition: CCT-Tree.hpp:1398
ANode * root() const
Definition: CCT-Tree.hpp:160
bool empty() const
Definition: CCT-Tree.hpp:168
virtual ~ADynNode()
Definition: CCT-Tree.hpp:748
ANode(ANodeTy type, ANode *parent, Struct::ACodeNode *strct=NULL)
Definition: CCT-Tree.hpp:325
Proc(ANode *parent, Struct::ACodeNode *strct=NULL)
Definition: CCT-Tree.hpp:1209
static uint16_t lush_lip_getLMId(const lush_lip_t *x)
Definition: lush-support.h:367
uint64_t m_start_address
Definition: CCT-Tree.hpp:1399
void root(ANode *x)
Definition: CCT-Tree.hpp:164
NonUniformDegreeTreeNode * FirstChild() const
virtual ~Call()
Definition: CCT-Tree.hpp:1293
Stmt(ANode *parent, uint cpId, hpcrun_fmt_cct_node_t node_fmt, LoadMap::LMId_t lmId, VMA ip, ushort opIdx, lush_lip_t *lip, const Metric::IData &metrics)
Definition: CCT-Tree.hpp:1335
SrcFile::ln endLine() const
Definition: CCT-Tree.hpp:417
uint16_t m_hpcrun_type
Definition: CCT-Tree.hpp:695
lush_assoc_info_t lush_assoc_info_NULL
Definition: lush-support.c:83
static bool isMergable(const ADynNode &x, const ADynNode &y)
Definition: CCT-Tree.hpp:931
virtual ~Root()
Definition: CCT-Tree.hpp:1128
LoadMap::LMId_t lmId_real() const
Definition: CCT-Tree.hpp:830
virtual ~Stmt()
Definition: CCT-Tree.hpp:1344
cct_node_t * node
Definition: cct.c:128
Stmt & operator=(const Stmt &x)
Definition: CCT-Tree.hpp:1348
ANode * lastChild() const
Definition: CCT-Tree.hpp:442
ACodeNode * ACodeNodeParent() const
virtual uint fileId() const
Definition: CCT-Tree.hpp:1175
bool isPrimarySynthRoot() const
Definition: CCT-Tree.hpp:906
virtual ~ProcFrm()
Definition: CCT-Tree.hpp:1157
virtual const std::string & name() const
LoadMap::LMId_t m_lmId
Definition: CCT-Tree.hpp:1002
lush_assoc_info_t m_as_info
Definition: CCT-Tree.hpp:1000
ushort opIndex() const
Definition: CCT-Tree.hpp:870
NonUniformDegreeTreeNode * LastChild() const
virtual VMA lmIP() const
Definition: CCT-Tree.hpp:845
ADynNode(ANodeTy type, ANode *parent, Struct::ACodeNode *strct, uint cpId, hpcrun_fmt_cct_node_t node_fmt, LoadMap::LMId_t lmId, VMA ip, ushort opIdx, lush_lip_t *lip)
Definition: CCT-Tree.hpp:729
ADynNode(ANodeTy type, ANode *parent, Struct::ACodeNode *strct, uint cpId)
Definition: CCT-Tree.hpp:722
ANode * firstChild() const
Definition: CCT-Tree.hpp:438
std::ostream & operator<<(std::ostream &os, const hpcrun_metricVal_t x)
Definition: CCT-Tree.hpp:109
NonUniformDegreeTreeNode * PrevSibling() const
static char * prefix
Definition: common.c:164
virtual ~Proc()
Definition: CCT-Tree.hpp:1213
static void lush_lip_setLMIP(lush_lip_t *x, uint64_t lm_ip)
Definition: lush-support.h:388
uint cpId() const
Definition: CCT-Tree.hpp:791
unsigned short int ushort
Definition: uint.h:120
static uint64_t lush_lip_getLMIP(const lush_lip_t *x)
Definition: lush-support.h:381
unsigned int uint
Definition: uint.h:124
static uint s_nextUniqueId
Definition: CCT-Tree.hpp:691
virtual bool isAlien() const
Definition: CCT-Tree.hpp:1222
virtual const std::string & name() const
Definition: CCT-Tree.hpp:394
ANode * nextSibling() const
Definition: CCT-Tree.hpp:446
SrcFile::ln begLine() const
AProcNode(const AProcNode &x)
Definition: CCT-Tree.hpp:1034
union lush_lip lush_lip_t
Definition: lush-support.h:305
void structure(const Struct::ACodeNode *strct)
Definition: CCT-Tree.hpp:405
virtual uint fileId() const
Definition: CCT-Tree.hpp:1076
std::map< uint, ANode * > NodeIdToANodeMap
Definition: CCT-Tree.hpp:248
#define HPCRUN_FMT_LMIp_Flag1
Definition: hpcrun-fmt.h:526
ProcFrm(const ProcFrm &x)
Definition: CCT-Tree.hpp:1161
static const LMId_t LMId_NULL
Definition: LoadMap.hpp:108
lush_assoc_t assoc() const
Definition: CCT-Tree.hpp:813
const CallPath::Profile * m_metadata
Definition: CCT-Tree.hpp:254
virtual const std::string & procName() const
Definition: CCT-Tree.hpp:1086
virtual ~ANode()
Definition: CCT-Tree.hpp:342
File * ancestorFile() const
virtual const std::string & lmName() const
Definition: CCT-Tree.hpp:1054
int ANodeLineComp(ANode *x, ANode *y)
Definition: CCT-Tree.cpp:1527
ANode(const ANode &x)
Definition: CCT-Tree.hpp:346
uint maxDenseId() const
Definition: CCT-Tree.hpp:193
void aggregateMetricsIncl(uint mBegId)
Definition: CCT-Tree.hpp:510
virtual uint lmId() const
Definition: CCT-Tree.hpp:1058
uint id_node_alloc()
Definition: CCT-Tree.hpp:1363
static lush_assoc_t lush_assoc_info__get_assoc(lush_assoc_info_t x)
Definition: lush-support.h:215
LoadMap::LMId_t lmId() const
Definition: CCT-Tree.hpp:823
ANode(ANodeTy type, ANode *parent, Struct::ACodeNode *strct, const Metric::IData &metrics)
Definition: CCT-Tree.hpp:333
lush_assoc_info_t assocInfo() const
Definition: CCT-Tree.hpp:805
bool isSecondarySynthRoot() const
Definition: CCT-Tree.hpp:913
AProcNode & operator=(const AProcNode &x)
Definition: CCT-Tree.hpp:1040
uint64_t start_address()
Definition: CCT-Tree.hpp:1375
static bool lush_lip_eq(const lush_lip_t *x, const lush_lip_t *y)
Definition: lush-support.h:327
void lmIP(VMA lmIP, ushort opIdx)
Definition: CCT-Tree.hpp:858
enum lush_assoc lush_assoc_t
Definition: lush-support.h:164
const CallPath::Profile * metadata() const
Definition: CCT-Tree.hpp:172
bool isValid_lip() const
Definition: CCT-Tree.hpp:898
void hpcrun_node_type(uint16_t type)
Definition: CCT-Tree.hpp:422
Call(ANode *parent, uint cpId, hpcrun_fmt_cct_node_t node_fmt, LoadMap::LMId_t lmId, VMA ip, ushort opIdx, lush_lip_t *lip, const Metric::IData &metrics)
Definition: CCT-Tree.hpp:1284
virtual ~Loop()
Definition: CCT-Tree.hpp:1260
void cpId(uint id)
Definition: CCT-Tree.hpp:796
virtual uint fileId() const
Definition: CCT-Tree.hpp:1251
void lmId(LoadMap::LMId_t x)
Definition: CCT-Tree.hpp:834
void start_address(uint64_t address)
Definition: CCT-Tree.hpp:1369
#define NULL
Definition: ElfHelper.cpp:85
int metrics[MAX_EVENTS][MAX_METRICS]
Definition: generic.c:147
static bool lush_assoc_info__path_len_eq(lush_assoc_info_t x, lush_assoc_info_t y)
Definition: lush-support.h:224
Root(const std::string &nm)
Definition: CCT-Tree.hpp:1118
std::vector< ANode * > Vec
Definition: CCT-Tree.hpp:299
Stmt(ANode *parent, uint cpId)
Definition: CCT-Tree.hpp:1330
#define NODE_TYPE_REGULAR
Definition: hpcrun-fmt.h:515
virtual const std::string & fileName() const
Definition: CCT-Tree.hpp:1063
void assocInfo(lush_assoc_info_t x)
Definition: CCT-Tree.hpp:809
uint id() const
Definition: CCT-Tree.hpp:383
ANode & operator=(const ANode &x)
Definition: CCT-Tree.hpp:357
void id_node_alloc(uint id)
Definition: CCT-Tree.hpp:1357
virtual VMA lmIP() const
Definition: CCT-Tree.hpp:1298
void lip(const lush_lip_t *lip)
Definition: CCT-Tree.hpp:883
NonUniformDegreeTreeNode * Parent() const
VMA lmIP_real() const
Definition: CCT-Tree.hpp:854
static Struct::ACodeNode * ancestorIfNotProc(Struct::ACodeNode *n)
Definition: CCT-Tree.hpp:924
SrcFile::ln begLine() const
Definition: CCT-Tree.hpp:413
IData & operator=(const IData &x)
static std::string BOGUS
Definition: CCT-Tree.hpp:1099
ANode * prevSibling() const
Definition: CCT-Tree.hpp:456
std::string m_name
Definition: CCT-Tree.hpp:1140
void node_alloc(ANode *node)
Definition: CCT-Tree.hpp:1381
static lush_lip_t * clone_lip(const lush_lip_t *x)
Definition: CCT-Tree.hpp:887
static bool lush_assoc_class_eq(lush_assoc_t x, lush_assoc_t y)
Definition: lush-support.h:230
<!-- ********************************************************************--> n<!-- HPCToolkit Experiment DTD --> n<!-- Version 2.1 --> n<!-- ********************************************************************--> n<!ELEMENT HPCToolkitExperiment(Header,(SecCallPathProfile|SecFlatProfile) *)> n<!ATTLIST HPCToolkitExperiment\n version CDATA #REQUIRED > n n<!-- ******************************************************************--> n n<!-- Info/NV:flexible name-value pairs:(n) ame;(t) ype;(v) alue --> n<!ELEMENT Info(NV *)> n<!ATTLIST Info\n n CDATA #IMPLIED > n<!ELEMENT NV EMPTY > n<!ATTLIST NV\n n CDATA #REQUIRED\n t CDATA #IMPLIED\n v CDATA #REQUIRED > n n<!-- ******************************************************************--> n<!-- Header --> n<!-- ******************************************************************--> n<!ELEMENT Header(Info *)> n<!ATTLIST Header\n n CDATA #REQUIRED > n n<!-- ******************************************************************--> n<!-- Section Header --> n<!-- ******************************************************************--> n<!ELEMENT SecHeader(MetricTable?, MetricDBTable?, TraceDBTable?, LoadModuleTable?, FileTable?, ProcedureTable?, Info *)> n n<!-- MetricTable:--> n<!ELEMENT MetricTable(Metric) * > n n<!-- Metric:(i) d;(n) ame --> n<!--(v) alue-type:transient type of values --> n<!--(t) ype:persistent type of metric --> n<!-- fmt:format;show;--> n<!ELEMENT Metric(MetricFormula *, Info?)> n<!ATTLIST Metric\n i CDATA #REQUIRED\n n CDATA #REQUIRED\n es CDATA #IMPLIED\n em CDATA #IMPLIED\n ep CDATA #IMPLIED\n v(raw|final|derived-incr|derived) \"raw\\ t (inclusive|exclusive|nil) \nil\\ partner CDATA #IMPLIED\ fmt CDATA #IMPLIED\ show (1|0) \1\\ show-percent (1|0) \1> n n<!-- MetricFormula represents derived metrics: (t)ype; (frm): formula --> n<!ELEMENT MetricFormula (Info?)> n<!ATTLIST MetricFormula\ t (combine|finalize) \finalize\\ i CDATA #IMPLIED\ frm CDATA #REQUIRED> n n<!-- Metric data, used in sections: (n)ame [from Metric]; (v)alue --> n<!ELEMENT M EMPTY> n<!ATTLIST M\ n CDATA #REQUIRED\ v CDATA #REQUIRED> n n<!-- MetricDBTable: --> n<!ELEMENT MetricDBTable (MetricDB)*> n n<!-- MetricDB: (i)d; (n)ame --> n<!-- (t)ype: persistent type of metric --> n<!-- db-glob: file glob describing files in metric db --> n<!-- db-id: id within metric db --> n<!-- db-num-metrics: number of metrics in db --> n<!-- db-header-sz: size (in bytes) of a db file header --> n<!ELEMENT MetricDB EMPTY> n<!ATTLIST MetricDB\ i CDATA #REQUIRED\ n CDATA #REQUIRED\ t (inclusive|exclusive|nil) \nil\\ partner CDATA #IMPLIED\ db-glob CDATA #IMPLIED\ db-id CDATA #IMPLIED\ db-num-metrics CDATA #IMPLIED\ db-header-sz CDATA #IMPLIED> n n<!-- TraceDBTable: --> n<!ELEMENT TraceDBTable (TraceDB)> n n<!-- TraceDB: (i)d --> n<!-- db-min-time: min beginning time stamp (global) --> n<!-- db-max-time: max ending time stamp (global) --> n<!ELEMENT TraceDB EMPTY> n<!ATTLIST TraceDB\ i CDATA #REQUIRED\ db-glob CDATA #IMPLIED\ db-min-time CDATA #IMPLIED\ db-max-time CDATA #IMPLIED\ db-header-sz CDATA #IMPLIED> n n<!-- LoadModuleTable assigns a short name to a load module --> n<!ELEMENT LoadModuleTable (LoadModule)*> n n<!ELEMENT LoadModule (Info?)> n<!ATTLIST LoadModule\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!-- FileTable assigns a short name to a file --> n<!ELEMENT FileTable (File)*> n n<!ELEMENT File (Info?)> n<!ATTLIST File\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!-- ProcedureTable assigns a short name to a procedure --> n<!ELEMENT ProcedureTable (Procedure)*> n n<!-- Info/NV: flexible name-value pairs: (n)ame; (t)ype; (v)alue --> n<!-- f: family of the procedure (fake, root, ...)--> n<!ELEMENT Procedure (Info?)> n<!ATTLIST Procedure\ i CDATA #REQUIRED\ n CDATA #REQUIRED\ f CDATA #IMPLIED> n n<!-- ****************************************************************** --> n<!-- Section: Call path profile --> n<!-- ****************************************************************** --> n<!ELEMENT SecCallPathProfile (SecHeader, SecCallPathProfileData)> n<!ATTLIST SecCallPathProfile\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!ELEMENT SecCallPathProfileData (PF|M)*> n<!-- Procedure frame --> n<!-- (i)d: unique identifier for cross referencing --> n<!-- (s)tatic scope id --> n<!-- (n)ame: a string or an id in ProcedureTable --> n<!-- (lm) load module: a string or an id in LoadModuleTable --> n<!-- (f)ile name: a string or an id in LoadModuleTable --> n<!-- (l)ine range: \beg-end\ (inclusive range) --> n<!-- (a)lien: whether frame is alien to enclosing P --> n<!-- (str)uct: hpcstruct node id --> n<!-- (t)ype: hpcrun node type: memory access, variable declaration, ... --> n<!-- (v)ma-range-set: \{[beg-end), [beg-end)...}\ --> n<!ELEMENT PF (PF|Pr|L|C|S|M)*> n<!ATTLIST PF\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ n CDATA #REQUIRED\ lm CDATA #IMPLIED\ f CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Procedure (static): GOAL: replace with 'P' --> n<!ELEMENT Pr (Pr|L|C|S|M)*> n<!ATTLIST Pr\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ n CDATA #REQUIRED\ lm CDATA #IMPLIED\ f CDATA #IMPLIED\ l CDATA #IMPLIED\ a (1|0) \0\\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Callsite (a special StatementRange) --> n<!ELEMENT C (PF|M)*> n<!ATTLIST C\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n n<!-- ****************************************************************** --> n<!-- Section: Flat profile --> n<!-- ****************************************************************** --> n<!ELEMENT SecFlatProfile (SecHeader, SecFlatProfileData)> n<!ATTLIST SecFlatProfile\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!ELEMENT SecFlatProfileData (LM|M)*> n<!-- Load module: (i)d; (n)ame; (v)ma-range-set --> n<!ELEMENT LM (F|P|M)*> n<!ATTLIST LM\ i CDATA #IMPLIED\ n CDATA #REQUIRED\ v CDATA #IMPLIED> n<!-- File --> n<!ELEMENT F (P|L|S|M)*> n<!ATTLIST F\ i CDATA #IMPLIED\ n CDATA #REQUIRED> n<!-- Procedure (Note 1) --> n<!ELEMENT P (P|A|L|S|C|M)*> n<!ATTLIST P\ i CDATA #IMPLIED\ n CDATA #REQUIRED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Alien (Note 1) --> n<!ELEMENT A (A|L|S|C|M)*> n<!ATTLIST A\ i CDATA #IMPLIED\ f CDATA #IMPLIED\ n CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Loop (Note 1,2) --> n<!ELEMENT L (A|Pr|L|S|C|M)*> n<!ATTLIST L\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ l CDATA #IMPLIED\ f CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Statement (Note 2) --> n<!-- (it): trace record identifier --> n<!ELEMENT S (S|M)*> n<!ATTLIST S\ i CDATA #IMPLIED\ it CDATA #IMPLIED\ s CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Note 1: Contained Cs may not contain PFs --> n<!-- Note 2: The 's' attribute is not used for flat profiles --> n
ProcFrm(ANode *parent, Struct::ACodeNode *strct=NULL)
Definition: CCT-Tree.hpp:1153
MergeContext * m_mergeCtxt
Definition: CCT-Tree.hpp:261
void lmId_real(LoadMap::LMId_t x)
Definition: CCT-Tree.hpp:841
ANode * m_root
Definition: CCT-Tree.hpp:253
Root(const char *nm)
Definition: CCT-Tree.hpp:1123
VMA lmRA() const
Definition: CCT-Tree.hpp:1311
ANodeTy type() const
Definition: CCT-Tree.hpp:374
#define HPCRUN_FMT_LMIp_NULL
Definition: hpcrun-fmt.h:525
NodeIdToANodeMap * m_nodeidMap
Definition: CCT-Tree.hpp:258
ANodeTy type() const
#define HPCRUN_FMT_CCTNodeId_NULL
Definition: hpcrun-fmt.h:497
Loop(ANode *parent, Struct::ACodeNode *strct=NULL)
Definition: CCT-Tree.hpp:1246
const ln ln_NULL
Definition: SrcFile.hpp:67
void id(uint id)
Definition: CCT-Tree.hpp:388
static const uint npos
ADynNode(ANodeTy type, ANode *parent, Struct::ACodeNode *strct, uint cpId, hpcrun_fmt_cct_node_t node_fmt, LoadMap::LMId_t lmId, VMA ip, ushort opIdx, lush_lip_t *lip, const Metric::IData &metrics)
Definition: CCT-Tree.hpp:738