30#ifndef SACADO_SCALAR_FLOP_COUNTER_HPP
31#define SACADO_SCALAR_FLOP_COUNTER_HPP
180#define SCALAR_FLOP_COUNTER_BINARY_OP_ASSIGN( OP, OP_NAME ) \
181 ScalarFlopCounter<T> operator OP ( const ScalarFlopCounter<T>& s ) \
183 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
204 template <
typename U>
227 const char* names[n] = {
"Current" };
228 const char* abbr[n] = {
"count" };
242 template <
typename S>
291#define SCALAR_FLOP_COUNTER_BINARY_OP( OP, OP_NAME ) \
293 ScalarFlopCounter<T> operator OP ( \
294 const Base< ScalarFlopCounter<T> >& aa, \
295 const Base< ScalarFlopCounter<T> >& bb ) \
297 const ScalarFlopCounter<T>& a = aa.derived(); \
298 const ScalarFlopCounter<T>& b = bb.derived(); \
299 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
300 return ScalarFlopCounter<T>(a.val() OP b.val()); \
303 ScalarFlopCounter<T> operator OP ( \
304 const typename ScalarFlopCounter<T>::value_type& a, \
305 const Base< ScalarFlopCounter<T> >& bb ) \
307 const ScalarFlopCounter<T>& b = bb.derived(); \
308 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
309 return ScalarFlopCounter<T>(a OP b.val()); \
312 ScalarFlopCounter<T> operator OP ( \
314 const Base< ScalarFlopCounter<T> >& bb ) \
316 const ScalarFlopCounter<T>& b = bb.derived(); \
317 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
318 return ScalarFlopCounter<T>(a OP b.val()); \
321 ScalarFlopCounter<T> operator OP ( \
322 const Base< ScalarFlopCounter<T> >& aa, \
323 const typename ScalarFlopCounter<T>::value_type& b ) \
325 const ScalarFlopCounter<T>& a = aa.derived(); \
326 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
327 return ScalarFlopCounter<T>(a.val() OP b); \
330 ScalarFlopCounter<T> operator OP ( \
331 const Base< ScalarFlopCounter<T> >& aa, \
334 const ScalarFlopCounter<T>& a = aa.derived(); \
335 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
336 return ScalarFlopCounter<T>(a.val() OP b); \
339#define SCALAR_FLOP_COUNTER_UNARY_OP( OP, OP_NAME ) \
341 ScalarFlopCounter<T> operator OP ( \
342 const Base< ScalarFlopCounter<T> >& aa ) \
344 const ScalarFlopCounter<T>& a = aa.derived(); \
345 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
346 return ScalarFlopCounter<T>( OP a.val() ); \
349#define SCALAR_FLOP_COUNTER_UNARY_FUNC( OP, OP_NAME ) \
351 ScalarFlopCounter<T> OP( \
352 const Base< ScalarFlopCounter<T> >& aa ) \
354 const ScalarFlopCounter<T>& a = aa.derived(); \
355 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
356 return ScalarFlopCounter<T>( std::OP( a.val() ) ); \
359#define SCALAR_FLOP_COUNTER_BINARY_FUNC( OP, OP_NAME ) \
361 ScalarFlopCounter<T> OP ( \
362 const Base< ScalarFlopCounter<T> >& aa, \
363 const Base< ScalarFlopCounter<T> >& bb ) \
365 const ScalarFlopCounter<T>& a = aa.derived(); \
366 const ScalarFlopCounter<T>& b = bb.derived(); \
367 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
368 return ScalarFlopCounter<T>( std::OP( a.val(), b.val() ) ); \
371 ScalarFlopCounter<T> OP ( \
372 const typename ScalarFlopCounter<T>::value_type& a, \
373 const Base< ScalarFlopCounter<T> >& bb ) \
375 const ScalarFlopCounter<T>& b = bb.derived(); \
376 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
377 return ScalarFlopCounter<T>( std::OP( a, b.val() ) ); \
380 ScalarFlopCounter<T> OP ( \
382 const Base< ScalarFlopCounter<T> >& bb ) \
384 const ScalarFlopCounter<T>& b = bb.derived(); \
385 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
386 return ScalarFlopCounter<T>( std::OP( a, b.val() ) ); \
389 ScalarFlopCounter<T> OP ( \
390 const Base< ScalarFlopCounter<T> >& aa, \
391 const typename ScalarFlopCounter<T>::value_type& b ) \
393 const ScalarFlopCounter<T>& a = aa.derived(); \
394 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
395 return ScalarFlopCounter<T>( std::OP( a.val(), b ) ); \
398 ScalarFlopCounter<T> OP ( \
399 const Base< ScalarFlopCounter<T> >& aa, \
402 const ScalarFlopCounter<T>& a = aa.derived(); \
403 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
404 return ScalarFlopCounter<T>( std::OP(a.val(), b ) ); \
407#define SCALAR_FLOP_COUNTER_BINARY_COMPARISON_OP( OP, OP_NAME ) \
410 const Base< ScalarFlopCounter<T> >& aa, \
411 const Base< ScalarFlopCounter<T> >& bb ) \
413 const ScalarFlopCounter<T>& a = aa.derived(); \
414 const ScalarFlopCounter<T>& b = bb.derived(); \
415 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
416 return (a.val() OP b.val()); \
420 const typename ScalarFlopCounter<T>::value_type& a, \
421 const Base< ScalarFlopCounter<T> >& bb ) \
423 const ScalarFlopCounter<T>& b = bb.derived(); \
424 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
425 return (a OP b.val()); \
429 const Base< ScalarFlopCounter<T> >& aa, \
430 const typename ScalarFlopCounter<T>::value_type& b ) \
432 const ScalarFlopCounter<T>& a = aa.derived(); \
433 ScalarFlopCounter<T>::incrCounter(OP_NAME); \
434 return (a.val() OP b); \
atan2(expr1.val(), expr2.val())
#define SACADO_ENABLE_VALUE_CTOR_DECL
#define SCALAR_FLOP_COUNTER_BINARY_OP(OP, OP_NAME)
#define SCALAR_FLOP_COUNTER_UNARY_FUNC(OP, OP_NAME)
#define SCALAR_FLOP_COUNTER_UNARY_OP(OP, OP_NAME)
#define SCALAR_FLOP_COUNTER_BINARY_FUNC(OP, OP_NAME)
#define SCALAR_FLOP_COUNTER_BINARY_OP_ASSIGN(OP, OP_NAME)
#define SCALAR_FLOP_COUNTER_BINARY_COMPARISON_OP(OP, OP_NAME)
adouble max(const adouble &a, const adouble &b)
adouble min(const adouble &a, const adouble &b)
Class storing flop counts and summary flop counts.
static unsigned int flopGranularity
The number of flops to accumulate as an integer before converting to a double.
double flopCounts[NUM_OPS]
Individual flop counts.
void reset()
Reset flop counters before starting a block of computations. */.
void increment(EFlopType ft)
Increment an individual flop counter.
FlopCounts()
Default constructor.
double summaryFlopCounts[NUM_SUMMARY_OPS]
Summary category flop counts.
static const char * summaryFlopCountsNames[NUM_SUMMARY_OPS]
Names for summary operation categories.
unsigned int partialFlopCounts[NUM_OPS]
Partial sum of individual flop counts.
ESummaryFlopType getSummaryType(EFlopType ft)
Get summary op enum from op enum.
unsigned int partialSummaryFlopCounts[NUM_SUMMARY_OPS]
Partial sum of summary category flop counts.
static const char * flopCountsNames[NUM_OPS]
Names of individual flops.
double totalFlopCount
Total flop count.
ESummaryFlopType
Enum of summary operation categories.
EFlopType
Enum for operations.
ScalarType< value_type >::type scalar_type
Typename of scalar's (which may be different from T).
SCALAR_FLOP_COUNTER_BINARY_OP_ASSIGN(-=, FlopCounts::MINUS_ASSIGN)
RemoveConst< T >::type value_type
Typename of values.
static std::ostream & printCounters(std::ostream &out)
Print the current static flop counts to out.
SCALAR_FLOP_COUNTER_BINARY_OP_ASSIGN(/=, FlopCounts::DIVIDE_ASSIGN)
static FlopCounts flopCounts_
static void incrCounter(const FlopCounts::EFlopType &ft)
Increment an individual flop counter.
static FlopCounts getCounters()
Get the flop counts after a block of computations.
void val(const T &a)
Set the current value.
SCALAR_FLOP_COUNTER_BINARY_OP_ASSIGN(=, FlopCounts::ASSIGN)
SCALAR_FLOP_COUNTER_BINARY_OP_ASSIGN(+=, FlopCounts::PLUS_ASSIGN)
static void resetCounters()
Reset static flop counters before starting a block of computations.
const T & val() const
Return the current value.
ScalarFlopCounter()
Construct to uninitialized.
static void finalizeCounters()
Finalize total flop count after block of computations.
ScalarFlopCounter(const S &v, SACADO_ENABLE_VALUE_CTOR_DECL)
Construct to scalar value.
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.
Base class for Sacado types to control overload resolution.
Turn ScalarFlopCounter into a meta-function class usable with mpl::apply.
ScalarFlopCounter< U > type