101 int(NUM_SUMMARY_OPS) );
104 totalFlopCount = 0.0;
110 for (
int i=0;
i<NUM_OPS;
i++) {
111 flopCounts[
i] +=
static_cast<double>(partialFlopCounts[
i]);
112 partialFlopCounts[
i] = 0;
114 for (
int i=0;
i<NUM_SUMMARY_OPS;
i++) {
115 summaryFlopCounts[
i] +=
static_cast<double>(partialSummaryFlopCounts[
i]);
116 partialSummaryFlopCounts[
i] = 0;
119 for (
int i=0;
i<NUM_OPS;
i++)
120 totalFlopCount += flopCounts[
i];
127 if (partialFlopCounts[ft] > flopGranularity) {
128 flopCounts[ft] +=
static_cast<double>(partialFlopCounts[ft]);
129 partialFlopCounts[ft] =0;
131 if (partialSummaryFlopCounts[sft] > flopGranularity) {
132 summaryFlopCounts[sft] +=
133 static_cast<double>(partialSummaryFlopCounts[sft]);
134 partialSummaryFlopCounts[sft] = 0;
136 ++partialFlopCounts[ft];
137 ++partialSummaryFlopCounts[sft];
145 return SUMMARY_ASSIGN;
152 return SUMMARY_PLUS_MINUS;
154 case MULTIPLY_ASSIGN:
155 return SUMMARY_MULTIPLY;
158 return SUMMARY_DIVIDE;
178 return SUMMARY_NONLINEAR;
180 case GREATER_THAN_EQUAL:
182 case LESS_THAN_EQUAL:
184 return SUMMARY_COMPARISON;
191 return SUMMARY_ASSIGN;
201 assert( n >= 1 && names && abbr && counts );
204 const char spacero[] =
"----------";
205 const char spacerc[] =
"--------------------";
208 out <<
"\nLegend\n------\n";
209 for(
int j = 0; j < n; ++j )
210 out <<
" " << abbr[j] <<
" = " << names[j] << std::endl;
214 out << std::left <<
" " << std::setw(wo) <<
"op\\count";
215 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << abbr[j];
217 out << std::right <<
" " << std::setw(wo) << spacero;
218 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << spacerc;
222 double theseFlops = 0;
223 for(
int j = 0; j < n; ++j ) theseFlops += counts[j].flopCounts[
i];
226 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << counts[j].
flopCounts[
i];
230 out << std::right <<
" " << std::setw(wo) << spacero;
231 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << spacerc;
234 std::vector<double> totalFlops(n);
236 double theseFlops = 0;
237 for(
int j = 0; j < n; ++j ) {
240 totalFlops[j] += flops;
244 for(
int j = 0; j < n; ++j )
249 out << std::right <<
" " << std::setw(wo) << spacero;
250 for(
int j = 0; j < n; ++j ) out <<
" " << std::setw(wc) << spacerc;
253 out <<
" " << std::setw(wo) <<
"all flops";
254 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.