62 #ifdef HAVE_SACADO_CXX11
103 int(NUM_SUMMARY_OPS) );
106 totalFlopCount = 0.0;
112 for (
int i=0; i<NUM_OPS; i++) {
113 flopCounts[i] +=
static_cast<double>(partialFlopCounts[i]);
114 partialFlopCounts[i] = 0;
116 for (
int i=0; i<NUM_SUMMARY_OPS; i++) {
117 summaryFlopCounts[i] +=
static_cast<double>(partialSummaryFlopCounts[i]);
118 partialSummaryFlopCounts[i] = 0;
121 for (
int i=0; i<NUM_OPS; i++)
122 totalFlopCount += flopCounts[i];
129 if (partialFlopCounts[ft] > flopGranularity) {
130 flopCounts[ft] +=
static_cast<double>(partialFlopCounts[ft]);
131 partialFlopCounts[ft] =0;
133 if (partialSummaryFlopCounts[sft] > flopGranularity) {
134 summaryFlopCounts[sft] +=
135 static_cast<double>(partialSummaryFlopCounts[sft]);
136 partialSummaryFlopCounts[sft] = 0;
138 ++partialFlopCounts[ft];
139 ++partialSummaryFlopCounts[sft];
147 return SUMMARY_ASSIGN;
154 return SUMMARY_PLUS_MINUS;
156 case MULTIPLY_ASSIGN:
157 return SUMMARY_MULTIPLY;
160 return SUMMARY_DIVIDE;
165 #ifdef HAVE_SACADO_CXX11
182 return SUMMARY_NONLINEAR;
184 case GREATER_THAN_EQUAL:
186 case LESS_THAN_EQUAL:
188 return SUMMARY_COMPARISON;
195 return SUMMARY_ASSIGN;
205 assert( n >= 1 && names && abbr && counts );
208 const char spacero[] =
"----------";
209 const char spacerc[] =
"--------------------";
212 out <<
"\nLegend\n------\n";
213 for(
int j = 0; j < n; ++j )
214 out <<
" " << abbr[j] <<
" = " << names[j] << std::endl;
218 out << std::left <<
" " << std::setw(wo) <<
"op\\count";
219 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << abbr[j];
221 out << std::right <<
" " << std::setw(wo) << spacero;
222 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << spacerc;
226 double theseFlops = 0;
227 for(
int j = 0; j < n; ++j ) theseFlops += counts[j].flopCounts[i];
230 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << counts[j].
flopCounts[i];
234 out << std::right <<
" " << std::setw(wo) << spacero;
235 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << spacerc;
238 std::vector<double> totalFlops(n);
240 double theseFlops = 0;
241 for(
int j = 0; j < n; ++j ) {
244 totalFlops[j] += flops;
248 for(
int j = 0; j < n; ++j )
253 out << std::right <<
" " << std::setw(wo) << spacero;
254 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << spacerc;
257 out <<
" " << std::setw(wo) <<
"all flops";
258 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << totalFlops[j];
void reset()
Reset flop counters before starting a block of computations. */.
ESummaryFlopType getSummaryType(EFlopType ft)
Get summary op enum from op enum.
EFlopType
Enum for operations.
void increment(EFlopType ft)
Increment an individual flop counter.
std::ostream & printCountersTable(const int n, const char *names[], const char *abbr[], const FlopCounts counts[], std::ostream &out)
Print a list of flop counts into a single table.
static unsigned int flopGranularity
The number of flops to accumulate as an integer before converting to a double.
ESummaryFlopType
Enum of summary operation categories.
double summaryFlopCounts[NUM_SUMMARY_OPS]
Summary category flop counts.
FlopCounts()
Default constructor.
static const char * flopCountsNames[NUM_OPS]
Names of individual flops.
Class storing flop counts and summary flop counts.
static KOKKOS_INLINE_FUNCTION void zero(T *dest, int sz)
Zero out array dest of length sz.
double flopCounts[NUM_OPS]
Individual flop counts.
static const char * summaryFlopCountsNames[NUM_SUMMARY_OPS]
Names for summary operation categories.