|
Sacado Package Browser (Single Doxygen Collection)
Version of the Day
|
Go to the documentation of this file.
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
const T & val() const
Return the current value.
SCALAR_FLOP_COUNTER_BINARY_OP_ASSIGN(=, FlopCounts::ASSIGN)
RemoveConst< T >::type value_type
Typename of values.
#define SCALAR_FLOP_COUNTER_UNARY_OP(OP, OP_NAME)
#define SCALAR_FLOP_COUNTER_BINARY_COMPARISON_OP(OP, OP_NAME)
#define SCALAR_FLOP_COUNTER_BINARY_OP(OP, OP_NAME)
void val(const T &a)
Set the current value.
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.
#define SCALAR_FLOP_COUNTER_BINARY_FUNC(OP, OP_NAME)
ESummaryFlopType getSummaryType(EFlopType ft)
Get summary op enum from op enum.
FlopCounts()
Default constructor.
atan2(expr1.val(), expr2.val())
void increment(EFlopType ft)
Increment an individual flop counter.
Class storing flop counts and summary flop counts.
ScalarFlopCounter()
Construct to uninitialized.
Turn ScalarFlopCounter into a meta-function class usable with mpl::apply.
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.
#define SACADO_ENABLE_VALUE_CTOR_DECL
static void finalizeCounters()
Finalize total flop count after block of computations.
unsigned int partialFlopCounts[NUM_OPS]
Partial sum of individual flop counts.
static const char * summaryFlopCountsNames[NUM_SUMMARY_OPS]
Names for summary operation categories.
Base class for Sacado types to control overload resolution.
#define SCALAR_FLOP_COUNTER_UNARY_FUNC(OP, OP_NAME)
EFlopType
Enum for operations.
SimpleFad< ValueT > min(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
ScalarFlopCounter< U > type
static void resetCounters()
Reset static flop counters before starting a block of computations.
ESummaryFlopType
Enum of summary operation categories.
static FlopCounts flopCounts_
ScalarFlopCounter(const S &v, SACADO_ENABLE_VALUE_CTOR_DECL)
Construct to scalar value.
pow(expr1.val(), expr2.val())
Templated flop counter class.
static void incrCounter(const FlopCounts::EFlopType &ft)
Increment an individual flop counter.
static FlopCounts getCounters()
Get the flop counts after a block of computations.
static const char * flopCountsNames[NUM_OPS]
Names of individual flops.
unsigned int partialSummaryFlopCounts[NUM_SUMMARY_OPS]
Partial sum of summary category flop counts.
static std::ostream & printCounters(std::ostream &out)
Print the current static flop counts to out.
void reset()
Reset flop counters before starting a block of computations. */.
SimpleFad< ValueT > max(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
ScalarType< value_type >::type scalar_type
Typename of scalar's (which may be different from T)
double totalFlopCount
Total flop count.
double summaryFlopCounts[NUM_SUMMARY_OPS]
Summary category flop counts.