12 #include "Teuchos_Assert.hpp"
13 #include "Teuchos_CommHelpers.hpp"
30 TEUCHOS_ASSERT( PAPI_library_init(PAPI_VER_CURRENT) == PAPI_VER_CURRENT );
34 for (std::vector<int>::const_iterator event =
m_events.begin();
44 std::map<std::string,InternalCounter2>::const_iterator counter;
71 std::vector<long_long>::const_iterator start = c.
start_counters.begin();
72 std::vector<long_long>::const_iterator stop = c.
stop_counters.begin();
74 *accum += *stop - *start;
82 "Error - cannot add event after PAPICounter is initialized!");
101 os <<
"************************************************************" << std::endl;
102 os <<
"* PAPI Counter Report (over all processes) " << std::endl;
103 os <<
"************************************************************" << std::endl;
105 for (std::map<std::string,InternalCounter2>::const_iterator timer =
m_counters.begin();
110 const std::vector<long long int>& accum = timer->second.accumulated_counters;
111 std::vector<long long int> global_min(accum.size(),0);
112 std::vector<long long int> global_max(accum.size(),0);
113 std::vector<long long int> global_sum(accum.size(),0);
114 std::vector<long long int> global_avg(accum.size(),0);
115 long long int average_time = 0;
117 Teuchos::reduceAll(comm,
Teuchos::REDUCE_MIN, static_cast<int>(accum.size()), &accum[0], &global_min[0]);
118 Teuchos::reduceAll(comm,
Teuchos::REDUCE_MAX, static_cast<int>(accum.size()), &accum[0], &global_max[0]);
119 Teuchos::reduceAll(comm,
Teuchos::REDUCE_SUM, static_cast<int>(accum.size()), &accum[0], &global_sum[0]);
120 Teuchos::reduceAll(comm,
Teuchos::REDUCE_SUM, static_cast<int>(accum.size()), &accum[0], &global_avg[0]);
122 for (std::vector<long long int>::iterator i = global_avg.begin();
123 i != global_avg.end(); ++i)
124 (*i) = *i / Teuchos::as<long long int>(comm.
getSize());
126 Teuchos::reduceAll(comm,
Teuchos::REDUCE_SUM, 1, &(timer->second.accumulated_time), &average_time);
127 average_time /= Teuchos::as<long long int>(comm.
getSize());
129 os << timer->first<<
": Average Process Time (seconds) = "
130 << timer->second.accumulated_time / 1.0e6 << std::endl;
131 os << timer->first<<
": Number of Calls = " << timer->second.num_calls << std::endl;
134 for (std::vector<long_long>::const_iterator event=timer->second.accumulated_counters.begin();
135 event != timer->second.accumulated_counters.end(); ++event,++i) {
136 char event_name[PAPI_MAX_STR_LEN];
138 std::string string_event_name(event_name);
139 os << timer->first <<
": " << string_event_name <<
" = "
140 <<
"min:" << global_min[i]
141 <<
", max:" << global_max[i]
142 <<
", total:" << global_sum[i]
143 <<
", avg:" << global_avg[i]
149 os <<
"************************************************************" << std::endl;
PAPICounter2(const std::string)
static void stopCounters()
virtual int getSize() const =0
std::vector< long_long > stop_counters
long_long accumulated_time
static bool m_is_initialized
true if the static members have been intitialized
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
std::vector< long_long > start_counters
std::string m_name
name of this counter
static std::map< std::string, InternalCounter2 > m_counters
maps the counter name to the data object
static void addEventCounter(const int event)
static void report(std::ostream &os, const Teuchos::Comm< int > &comm)
static std::vector< int > m_events
papi event index
static int m_event_set
PAPI event set.
static void startCounters()
std::vector< long_long > accumulated_counters
#define TEUCHOS_ASSERT(assertion_test)