dune-common  2.7.0
Classes | Public Member Functions | List of all members
Dune::Simd::UnitTest Class Reference

#include <dune/common/simd/test.hh>

Public Member Functions

template<class V , class Rebinds , template< class > class RebindPrune = IsLoop, template< class > class RebindAccept = Std::to_true_type>
void check ()
 run unit tests for simd vector type V More...
 
template<class V , class Rebinds , template< class > class Prune = IsLoop>
 DUNE_DEPRECATED_MSG ("Call check() instead, and explicitly instantiate " "checkType() and friends instead") void checkVector()
 run unit tests for simd vector type V More...
 
bool good () const
 whether all tests succeeded More...
 
Test instantiation points

These functions should not be called directly, but serve as explicit instantiation points to keep memory usage bounded during compilation. There should be an explicit instantiation declaration (extern template ...) in the the overall header of your unit test for each type that is tested (possibly implicitly tested due to recursive checks). Similarly, there should be an explicit instantiation definition (template ...) in a separate translation unit. Ideally, there should be one translation unit per explicit instantiation definition, otherwise each of them will contribute to the overall memory used during compilation.

If explicitly instantiating the top-level instantiation point checkType() is not sufficient, there are further instantiation points for improved granularity. The hierarchy of instantiation points is:

Each instantiation point in the hierarchy implicitly instantiates its descendants, unless there are explicit instantiation declarations for them. However, for future-proofing it can make sense to explicitly instantiate nodes in the hierarchy even if all their children are already explicitly instantiated. This will limit the impact of instantiation points added in the future.

template<class V >
void checkType ()
 
template<class V >
void checkNonOps ()
 
template<class V >
void checkUnaryOps ()
 
template<class V >
void checkBinaryOps ()
 
template<class V >
void checkBinaryOpsVectorVector ()
 
template<class V >
void checkBinaryOpsScalarVector ()
 
template<class V >
void checkBinaryOpsVectorScalar ()
 
template<class V >
void checkBinaryOpsProxyVector ()
 
template<class V >
void checkBinaryOpsVectorProxy ()
 

Member Function Documentation

◆ check()

template<class V , class Rebinds , template< class > class RebindPrune = IsLoop, template< class > class RebindAccept = Std::to_true_type>
void Dune::Simd::UnitTest::check ( )
inline

run unit tests for simd vector type V

This function will also ensure that check<W>() is run, for any type W = Rebind<R, V> where R is in Rebinds, and RebindPrune<W>::value == false. No test will be run twice for a given type.

If the result of Rebind is not pruned by RebindPrune, it will be passed to RebindAccept. If that rejects the type, a static assertion will trigger.

Template Parameters
RebindsA list of types, usually in the form of a TypeList.
RebindPruneA type predicate determining whether to run check() for types obtained from Rebinds.
RebindAcceptA type predicate determining whether a type is acceptable as the result of a Rebind.

◆ checkBinaryOps()

template<class V >
void Dune::Simd::UnitTest::checkBinaryOps

◆ checkBinaryOpsProxyVector()

template<class V >
void Dune::Simd::UnitTest::checkBinaryOpsProxyVector

◆ checkBinaryOpsScalarVector()

template<class V >
void Dune::Simd::UnitTest::checkBinaryOpsScalarVector

◆ checkBinaryOpsVectorProxy()

template<class V >
void Dune::Simd::UnitTest::checkBinaryOpsVectorProxy

◆ checkBinaryOpsVectorScalar()

template<class V >
void Dune::Simd::UnitTest::checkBinaryOpsVectorScalar

◆ checkBinaryOpsVectorVector()

template<class V >
void Dune::Simd::UnitTest::checkBinaryOpsVectorVector

◆ checkNonOps()

template<class V >
void Dune::Simd::UnitTest::checkNonOps

◆ checkType()

template<class V >
void Dune::Simd::UnitTest::checkType

◆ checkUnaryOps()

template<class V >
void Dune::Simd::UnitTest::checkUnaryOps

◆ DUNE_DEPRECATED_MSG()

template<class V , class Rebinds , template< class > class Prune = IsLoop>
Dune::Simd::UnitTest::DUNE_DEPRECATED_MSG ( "Call check()  instead,
and explicitly instantiate " "checkType() and friends instead"   
)

run unit tests for simd vector type V

This function will also ensure that checkVector<Rebind<R, V>>() (for any R in Rebinds) is run. No test will be run twice for a given type.

Template Parameters
RebindsA list of types, usually in the form of a TypeList.
PruneA type predicate determining whether to run checkVector() for types obtained from Rebinds.
Deprecated:
Rather than calling this function, call check() with the same template arguments. Rather than explicitly instantiating this function as described below, explicitly instantiate checkType() and friends.
Note
As an implementor of a unit test, you are encouraged to explicitly instantiate this function in separate compilation units for the types you are testing. Look at standardtest.cc for how to do this.

Background: The compiler can use a lot of memory when compiling a unit test for many Simd vector types. E.g. for standardtest.cc, which tests all the fundamental arithmetic types plus std::complex, g++ 4.9.2 (-g -O0 -Wall on x86_64 GNU/Linux) used ~6GByte.

One mitigation is to explicitly instantiate checkVector() for the types that are tested. Still after doing that, standardtest.cc needed ~1.5GByte during compilation, which is more than the compilation units that actually instantiated checkVector() (which clocked in at maximum at around 800MB, depending on how many instantiations they contained).

The second mitigation is to define checkVector() outside of the class. I have no idea why this helps, but it makes compilation use less than ~100MByte. (Yes, functions defined inside the class are implicitly inline, but the function is a template so it has inline semantics even when defined outside of the class. And I tried attribute((noinline)), which had no effect on memory consumption.)

◆ good()

bool Dune::Simd::UnitTest::good ( ) const
inline

whether all tests succeeded


The documentation for this class was generated from the following files: