30 #ifndef SACADO_SCALAR_FLOP_COUNTER_HPP 31 #define SACADO_SCALAR_FLOP_COUNTER_HPP 43 namespace FlopCounterPack {
49 #ifdef HAVE_SACADO_CXX11 78 #ifdef HAVE_SACADO_CXX11 186 #define SCALAR_FLOP_COUNTER_BINARY_OP_ASSIGN( OP, OP_NAME ) \ 187 ScalarFlopCounter<T> operator OP ( const ScalarFlopCounter<T>& s ) \ 189 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 210 template <
typename U>
233 const char* names[n] = {
"Current" };
234 const char* abbr[n] = {
"count" };
248 template <
typename S>
297 #define SCALAR_FLOP_COUNTER_BINARY_OP( OP, OP_NAME ) \ 299 ScalarFlopCounter<T> operator OP ( \ 300 const Base< ScalarFlopCounter<T> >& aa, \ 301 const Base< ScalarFlopCounter<T> >& bb ) \ 303 const ScalarFlopCounter<T>& a = aa.derived(); \ 304 const ScalarFlopCounter<T>& b = bb.derived(); \ 305 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 306 return ScalarFlopCounter<T>(a.val() OP b.val()); \ 309 ScalarFlopCounter<T> operator OP ( \ 310 const typename ScalarFlopCounter<T>::value_type& a, \ 311 const Base< ScalarFlopCounter<T> >& bb ) \ 313 const ScalarFlopCounter<T>& b = bb.derived(); \ 314 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 315 return ScalarFlopCounter<T>(a OP b.val()); \ 318 ScalarFlopCounter<T> operator OP ( \ 320 const Base< ScalarFlopCounter<T> >& bb ) \ 322 const ScalarFlopCounter<T>& b = bb.derived(); \ 323 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 324 return ScalarFlopCounter<T>(a OP b.val()); \ 327 ScalarFlopCounter<T> operator OP ( \ 328 const Base< ScalarFlopCounter<T> >& aa, \ 329 const typename ScalarFlopCounter<T>::value_type& b ) \ 331 const ScalarFlopCounter<T>& a = aa.derived(); \ 332 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 333 return ScalarFlopCounter<T>(a.val() OP b); \ 336 ScalarFlopCounter<T> operator OP ( \ 337 const Base< ScalarFlopCounter<T> >& aa, \ 340 const ScalarFlopCounter<T>& a = aa.derived(); \ 341 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 342 return ScalarFlopCounter<T>(a.val() OP b); \ 345 #define SCALAR_FLOP_COUNTER_UNARY_OP( OP, OP_NAME ) \ 347 ScalarFlopCounter<T> operator OP ( \ 348 const Base< ScalarFlopCounter<T> >& aa ) \ 350 const ScalarFlopCounter<T>& a = aa.derived(); \ 351 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 352 return ScalarFlopCounter<T>( OP a.val() ); \ 355 #define SCALAR_FLOP_COUNTER_UNARY_FUNC( OP, OP_NAME ) \ 357 ScalarFlopCounter<T> OP( \ 358 const Base< ScalarFlopCounter<T> >& aa ) \ 360 const ScalarFlopCounter<T>& a = aa.derived(); \ 361 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 362 return ScalarFlopCounter<T>( std::OP( a.val() ) ); \ 365 #define SCALAR_FLOP_COUNTER_BINARY_FUNC( OP, OP_NAME ) \ 367 ScalarFlopCounter<T> OP ( \ 368 const Base< ScalarFlopCounter<T> >& aa, \ 369 const Base< ScalarFlopCounter<T> >& bb ) \ 371 const ScalarFlopCounter<T>& a = aa.derived(); \ 372 const ScalarFlopCounter<T>& b = bb.derived(); \ 373 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 374 return ScalarFlopCounter<T>( std::OP( a.val(), b.val() ) ); \ 377 ScalarFlopCounter<T> OP ( \ 378 const typename ScalarFlopCounter<T>::value_type& a, \ 379 const Base< ScalarFlopCounter<T> >& bb ) \ 381 const ScalarFlopCounter<T>& b = bb.derived(); \ 382 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 383 return ScalarFlopCounter<T>( std::OP( a, b.val() ) ); \ 386 ScalarFlopCounter<T> OP ( \ 388 const Base< ScalarFlopCounter<T> >& bb ) \ 390 const ScalarFlopCounter<T>& b = bb.derived(); \ 391 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 392 return ScalarFlopCounter<T>( std::OP( a, b.val() ) ); \ 395 ScalarFlopCounter<T> OP ( \ 396 const Base< ScalarFlopCounter<T> >& aa, \ 397 const typename ScalarFlopCounter<T>::value_type& b ) \ 399 const ScalarFlopCounter<T>& a = aa.derived(); \ 400 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 401 return ScalarFlopCounter<T>( std::OP( a.val(), b ) ); \ 404 ScalarFlopCounter<T> OP ( \ 405 const Base< ScalarFlopCounter<T> >& aa, \ 408 const ScalarFlopCounter<T>& a = aa.derived(); \ 409 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 410 return ScalarFlopCounter<T>( std::OP(a.val(), b ) ); \ 413 #define SCALAR_FLOP_COUNTER_BINARY_COMPARISON_OP( OP, OP_NAME ) \ 416 const Base< ScalarFlopCounter<T> >& aa, \ 417 const Base< ScalarFlopCounter<T> >& bb ) \ 419 const ScalarFlopCounter<T>& a = aa.derived(); \ 420 const ScalarFlopCounter<T>& b = bb.derived(); \ 421 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 422 return (a.val() OP b.val()); \ 426 const typename ScalarFlopCounter<T>::value_type& a, \ 427 const Base< ScalarFlopCounter<T> >& bb ) \ 429 const ScalarFlopCounter<T>& b = bb.derived(); \ 430 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 431 return (a OP b.val()); \ 435 const Base< ScalarFlopCounter<T> >& aa, \ 436 const typename ScalarFlopCounter<T>::value_type& b ) \ 438 const ScalarFlopCounter<T>& a = aa.derived(); \ 439 ScalarFlopCounter<T>::incrCounter(OP_NAME); \ 440 return (a.val() OP b); \ 461 #ifdef HAVE_SACADO_CXX11 492 #endif // SACADO_SCALAR_FLOP_COUNTER_HPP
double totalFlopCount
Total flop count.
static FlopCounts flopCounts_
void reset()
Reset flop counters before starting a block of computations. */.
static FlopCounts getCounters()
Get the flop counts after a block of computations.
static void resetCounters()
Reset static flop counters before starting a block of computations.
ScalarFlopCounter< U > type
ESummaryFlopType getSummaryType(EFlopType ft)
Get summary op enum from op enum.
EFlopType
Enum for operations.
#define SACADO_ENABLE_VALUE_CTOR_DECL
void increment(EFlopType ft)
Increment an individual flop counter.
static void incrCounter(const FlopCounts::EFlopType &ft)
Increment an individual flop counter.
SimpleFad< ValueT > atan2(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
unsigned int partialFlopCounts[NUM_OPS]
Partial sum of individual flop counts.
SimpleFad< ValueT > sqrt(const SimpleFad< ValueT > &a)
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.
SimpleFad< ValueT > asin(const SimpleFad< ValueT > &a)
static unsigned int flopGranularity
The number of flops to accumulate as an integer before converting to a double.
ScalarType< value_type >::type scalar_type
Typename of scalar's (which may be different from T)
Base class for Sacado types to control overload resolution.
SimpleFad< ValueT > log(const SimpleFad< ValueT > &a)
unsigned int partialSummaryFlopCounts[NUM_SUMMARY_OPS]
Partial sum of summary category flop counts.
Turn ScalarFlopCounter into a meta-function class usable with mpl::apply.
ScalarFlopCounter(const S &v, SACADO_ENABLE_VALUE_CTOR_DECL)
Construct to scalar value.
SimpleFad< ValueT > exp(const SimpleFad< ValueT > &a)
ESummaryFlopType
Enum of summary operation categories.
SimpleFad< ValueT > atan(const SimpleFad< ValueT > &a)
static std::ostream & printCounters(std::ostream &out)
Print the current static flop counts to out.
SimpleFad< ValueT > log10(const SimpleFad< ValueT > &a)
SCALAR_FLOP_COUNTER_BINARY_OP_ASSIGN(=, FlopCounts::ASSIGN)
SimpleFad< ValueT > min(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
const T & val() const
Return the current value.
RemoveConst< T >::type value_type
Typename of values.
SimpleFad< ValueT > sin(const SimpleFad< ValueT > &a)
double summaryFlopCounts[NUM_SUMMARY_OPS]
Summary category flop counts.
FlopCounts()
Default constructor.
SimpleFad< ValueT > sinh(const SimpleFad< ValueT > &a)
static const char * flopCountsNames[NUM_OPS]
Names of individual flops.
Class storing flop counts and summary flop counts.
#define SCALAR_FLOP_COUNTER_BINARY_COMPARISON_OP(OP, OP_NAME)
Templated flop counter class.
double flopCounts[NUM_OPS]
Individual flop counts.
SimpleFad< ValueT > pow(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
static const char * summaryFlopCountsNames[NUM_SUMMARY_OPS]
Names for summary operation categories.
SimpleFad< ValueT > tan(const SimpleFad< ValueT > &a)
SimpleFad< ValueT > cos(const SimpleFad< ValueT > &a)
SimpleFad< ValueT > cosh(const SimpleFad< ValueT > &a)
SimpleFad< ValueT > max(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
#define SCALAR_FLOP_COUNTER_UNARY_FUNC(OP, OP_NAME)
#define SCALAR_FLOP_COUNTER_BINARY_OP(OP, OP_NAME)
static void finalizeCounters()
Finalize total flop count after block of computations.
ScalarFlopCounter()
Construct to uninitialized.
void val(const T &a)
Set the current value.
KOKKOS_INLINE_FUNCTION Expr< AbsOp< Expr< T > > > abs(const Expr< T > &expr)
KOKKOS_INLINE_FUNCTION Expr< FAbsOp< Expr< T > > > fabs(const Expr< T > &expr)
SimpleFad< ValueT > acos(const SimpleFad< ValueT > &a)
SimpleFad< ValueT > tanh(const SimpleFad< ValueT > &a)
#define SCALAR_FLOP_COUNTER_UNARY_OP(OP, OP_NAME)
#define SCALAR_FLOP_COUNTER_BINARY_FUNC(OP, OP_NAME)