Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge Add core and reference multiprecision tests
This adds multiprecision tests for the core and reference modules. In addition to this, all non matrix, solver and preconditioners in the OpenMP module also have multiprecision tests. ### Summary of changes + All core tests rewrote for multiple precisions + All reference tests rewrote for multiple precisions + Extra OpenMP tests rewrote for multiple precisions (non matrix, solver or preconditioner). + codecov is put back into Ginkgo, and our coverage significantly improved thanks to the templated tests + In `core/test/utils.hpp`, a bunch of declarations were provided for default values we want to tests, and other tools used when doing multiprecision tests. + In `core/test/utils/assertions.hpp`, `get_relative_error` and other commonly used functions from the assertions were extended for the complex value case (using `gko::remove_complex` most of the time). A new assertion was added for comparing values of complex type (`GKO_ASSERT_NEAR`, which extends the basic gtest one `ASSERT_NEAR`). + Papi required some fixes (counting the instances of Papi loggers globally instead of per template valuetype). + `Ilu` required some fixes (using `gko::remove_complex` and removing default valuetype use of `<>`). ### How to write templated tests `core/tests/utils.hpp` always needs to be included because it provides required definitions. In general, if only one kind of precision (e.g. `value_type`) is required, then normal templating can be used, otherwise, due to the use of the macro for declaring the templated values to try, a tuple which contains all the elements need to be defined, see the `reference/test/matrix/csr_kernels.cpp` for example. ```cpp template <typename ValueIndexType> class Csr : public ::testing::Test { protected: using value_type = typename std::tuple_element<0, decltype(ValueIndexType())>::type; using index_type = typename std::tuple_element<1, decltype(ValueIndexType())>::type; }; ``` Afterwards, the class needs to be instantiated for all precisions, which is done such as in the following way: ```cpp TYPED_TEST_CASE(Csr, gko::test::ValueIndexTypes); ``` Note that `ValueIndexTypes` is provided by `utils.hpp` and contains tuples of all valuetype and index type combinations. As a requirement, the tests now need to use the macro `TYPED_TEST` instead of `TEST_F`. This has multiple implications: + All member objects/functions have to be accessed with `this->`. + All member definitions such as `using` need to be accessed through `TestFixture::Mtx` for example. The approach I used is to add to every test the required `using` shortcut to make the tests look nicer. + A variable `TypeParam` is provided which is the template type of the test. + Due to complexes being able to be built with `{real, img}` notation, our initializations of the form `{{1.0, 2.0}, {3.0, 4.0}}` are ambiguous (the second `{`). I provided a shortcut `I<type>` for stating that this is actually an initializer list of type T, and not a complex construction. So the following example would be replaced with: ```cpp using T = typename TestFixture::value_type; auto mtx = gko::initialize({I<T>{1.0, 2.0}, I<T>{3.0, 4.0}}, this->exec); ``` Finally, I implemented a shortcut `r<value_type>::value` for providing depending on the type of the value a proper precision (`1e-7` for `float` and `std::complex<float>`, and `1e-14` for `double` variants). ### Closes: #32 ### Related PR: #448
- Loading branch information