Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoopStatistics.h
Go to the documentation of this file.
1 /*
2  * This file belongs to the Galois project, a C++ library for exploiting
3  * parallelism. The code is being released under the terms of the 3-Clause BSD
4  * License (a copy is located in LICENSE.txt at the top-level directory).
5  *
6  * Copyright (C) 2018, The University of Texas at Austin. All rights reserved.
7  * UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS
8  * SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY,
9  * FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF
10  * PERFORMANCE, AND ANY WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF
11  * DEALING OR USAGE OF TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH
12  * RESPECT TO THE USE OF THE SOFTWARE OR DOCUMENTATION. Under no circumstances
13  * shall University be liable for incidental, special, indirect, direct or
14  * consequential damages or loss of profits, interruption of business, or
15  * related expenses which may arise from use of Software or Documentation,
16  * including but not limited to those resulting from defects in Software and/or
17  * Documentation, or loss or inaccuracy of data of any kind.
18  */
19 
20 #ifndef GALOIS_RUNTIME_LOOPSTATISTICS_H
21 #define GALOIS_RUNTIME_LOOPSTATISTICS_H
22 
23 #include "galois/config.h"
25 
26 namespace galois {
27 namespace runtime {
28 
29 // Usually instantiated per thread
30 template <bool Enabled>
32 
33 protected:
34  size_t m_iterations;
35  size_t m_pushes;
36  size_t m_conflicts;
37  const char* loopname;
38 
39 public:
40  explicit LoopStatistics(const char* ln)
41  : m_iterations(0), m_pushes(0), m_conflicts(0), loopname(ln) {}
42 
44  reportStat_Tsum(loopname, "Iterations", m_iterations);
46  reportStat_Tsum(loopname, "Pushes", m_pushes);
47  reportStat_Tsum(loopname, "Conflicts", m_conflicts);
48  }
49 
50  size_t iterations(void) const { return m_iterations; }
51  size_t pushes(void) const { return m_pushes; }
52  size_t conflicts(void) const { return m_conflicts; }
53 
54  inline void inc_pushes(size_t v = 1) { m_pushes += v; }
55 
56  inline void inc_iterations() { ++m_iterations; }
57 
58  inline void inc_conflicts() { ++m_conflicts; }
59 };
60 
61 template <>
62 class LoopStatistics<false> {
63 public:
64  explicit LoopStatistics(const char*) {}
65 
66  size_t iterations(void) const { return 0; }
67  size_t pushes(void) const { return 0; }
68  size_t conflicts(void) const { return 0; }
69 
70  inline void inc_iterations() const {}
71  inline void inc_pushes(size_t = 0) const {}
72  inline void inc_conflicts() const {}
73 };
74 
75 } // namespace runtime
76 } // namespace galois
77 #endif
Definition: LoopStatistics.h:31
LoopStatistics(const char *)
Definition: LoopStatistics.h:64
size_t iterations(void) const
Definition: LoopStatistics.h:50
void inc_iterations() const
Definition: LoopStatistics.h:70
size_t conflicts(void) const
Definition: LoopStatistics.h:52
Definition: Traits.h:197
void inc_conflicts() const
Definition: LoopStatistics.h:72
size_t m_iterations
Definition: LoopStatistics.h:34
LoopStatistics(const char *ln)
Definition: LoopStatistics.h:40
void reportStat_Tsum(const S1 &region, const S2 &category, const T &value)
Definition: Statistics.h:562
const char * loopname
Definition: LoopStatistics.h:37
size_t m_conflicts
Definition: LoopStatistics.h:36
void inc_pushes(size_t v=1)
Definition: LoopStatistics.h:54
size_t pushes(void) const
Definition: LoopStatistics.h:51
~LoopStatistics()
Definition: LoopStatistics.h:43
size_t m_pushes
Definition: LoopStatistics.h:35
void inc_iterations()
Definition: LoopStatistics.h:56
void inc_pushes(size_t=0) const
Definition: LoopStatistics.h:71
size_t conflicts(void) const
Definition: LoopStatistics.h:68
size_t pushes(void) const
Definition: LoopStatistics.h:67
void inc_conflicts()
Definition: LoopStatistics.h:58
size_t iterations(void) const
Definition: LoopStatistics.h:66