81 int(NUM_SUMMARY_OPS) );
90 for (
int i=0;
i<NUM_OPS;
i++) {
91 flopCounts[
i] +=
static_cast<double>(partialFlopCounts[
i]);
92 partialFlopCounts[
i] = 0;
94 for (
int i=0;
i<NUM_SUMMARY_OPS;
i++) {
95 summaryFlopCounts[
i] +=
static_cast<double>(partialSummaryFlopCounts[
i]);
96 partialSummaryFlopCounts[
i] = 0;
99 for (
int i=0;
i<NUM_OPS;
i++)
100 totalFlopCount += flopCounts[
i];
107 if (partialFlopCounts[ft] > flopGranularity) {
108 flopCounts[ft] +=
static_cast<double>(partialFlopCounts[ft]);
109 partialFlopCounts[ft] =0;
111 if (partialSummaryFlopCounts[sft] > flopGranularity) {
112 summaryFlopCounts[sft] +=
113 static_cast<double>(partialSummaryFlopCounts[sft]);
114 partialSummaryFlopCounts[sft] = 0;
116 ++partialFlopCounts[ft];
117 ++partialSummaryFlopCounts[sft];
125 return SUMMARY_ASSIGN;
132 return SUMMARY_PLUS_MINUS;
134 case MULTIPLY_ASSIGN:
135 return SUMMARY_MULTIPLY;
138 return SUMMARY_DIVIDE;
158 return SUMMARY_NONLINEAR;
160 case GREATER_THAN_EQUAL:
162 case LESS_THAN_EQUAL:
164 return SUMMARY_COMPARISON;
171 return SUMMARY_ASSIGN;
181 assert( n >= 1 && names && abbr && counts );
184 const char spacero[] =
"----------";
185 const char spacerc[] =
"--------------------";
188 out <<
"\nLegend\n------\n";
189 for(
int j = 0; j < n; ++j )
190 out <<
" " << abbr[j] <<
" = " << names[j] << std::endl;
194 out << std::left <<
" " << std::setw(wo) <<
"op\\count";
195 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << abbr[j];
197 out << std::right <<
" " << std::setw(wo) << spacero;
198 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << spacerc;
202 double theseFlops = 0;
203 for(
int j = 0; j < n; ++j ) theseFlops += counts[j].flopCounts[
i];
206 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << counts[j].
flopCounts[
i];
210 out << std::right <<
" " << std::setw(wo) << spacero;
211 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << spacerc;
214 std::vector<double> totalFlops(n);
216 double theseFlops = 0;
217 for(
int j = 0; j < n; ++j ) {
220 totalFlops[j] += flops;
224 for(
int j = 0; j < n; ++j )
229 out << std::right <<
" " << std::setw(wo) << spacero;
230 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << spacerc;
233 out <<
" " << std::setw(wo) <<
"all flops";
234 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.
static SACADO_INLINE_FUNCTION void zero(T *dest, int sz)
Zero out array dest of length sz.
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.
double flopCounts[NUM_OPS]
Individual flop counts.
static const char * summaryFlopCountsNames[NUM_SUMMARY_OPS]
Names for summary operation categories.