44 #include "Teuchos_Assert.hpp"
45 #include "Teuchos_CommHelpers.hpp"
62 TEUCHOS_ASSERT( PAPI_library_init(PAPI_VER_CURRENT) == PAPI_VER_CURRENT );
66 for (std::vector<int>::const_iterator event =
m_events.begin();
76 std::map<std::string,InternalCounter2>::const_iterator counter;
103 std::vector<long_long>::const_iterator start = c.
start_counters.begin();
104 std::vector<long_long>::const_iterator stop = c.
stop_counters.begin();
106 *accum += *stop - *start;
114 "Error - cannot add event after PAPICounter is initialized!");
133 os <<
"************************************************************" << std::endl;
134 os <<
"* PAPI Counter Report (over all processes) " << std::endl;
135 os <<
"************************************************************" << std::endl;
137 for (std::map<std::string,InternalCounter2>::const_iterator timer =
m_counters.begin();
142 const std::vector<long long int>& accum = timer->second.accumulated_counters;
143 std::vector<long long int> global_min(accum.size(),0);
144 std::vector<long long int> global_max(accum.size(),0);
145 std::vector<long long int> global_sum(accum.size(),0);
146 std::vector<long long int> global_avg(accum.size(),0);
147 long long int average_time = 0;
154 for (std::vector<long long int>::iterator i = global_avg.begin();
155 i != global_avg.end(); ++i)
156 (*i) = *i / Teuchos::as<long long int>(comm.
getSize());
159 average_time /= Teuchos::as<long long int>(comm.
getSize());
161 os << timer->first<<
": Average Process Time (seconds) = "
162 << timer->second.accumulated_time / 1.0e6 << std::endl;
163 os << timer->first<<
": Number of Calls = " << timer->second.num_calls << std::endl;
166 for (std::vector<long_long>::const_iterator event=timer->second.accumulated_counters.begin();
167 event != timer->second.accumulated_counters.end(); ++event,++i) {
168 char event_name[PAPI_MAX_STR_LEN];
170 std::string string_event_name(event_name);
171 os << timer->first <<
": " << string_event_name <<
" = "
172 <<
"min:" << global_min[i]
173 <<
", max:" << global_max[i]
174 <<
", total:" << global_sum[i]
175 <<
", avg:" << global_avg[i]
181 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)
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
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)