Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design and Define New UnitTest infrastructure #28

Closed
crtrott opened this issue Apr 28, 2017 · 1 comment
Closed

Design and Define New UnitTest infrastructure #28

crtrott opened this issue Apr 28, 2017 · 1 comment

Comments

@crtrott
Copy link
Member

crtrott commented Apr 28, 2017

A systematic new unit test framework shall be defined laying out how to add new unit tests.

@crtrott crtrott self-assigned this Apr 28, 2017
@crtrott
Copy link
Member Author

crtrott commented Apr 28, 2017

The new structure for unit tests was (mostly) implemented for the dot product. The basic structure to allow for maximum maintainability is as follows:

In the unit_test directory contains a number of directories:

openmp
cuda
serial
threads
blas
sparse
graph

Other than that only one file Test_Main.cpp is included. That file will not generally be changed.
Inside of the blast,sparse and graph subdirectories header files with the actual tests will be defined using a naming scheme of:

Test_CATEGORY_FUNCTION.hpp

where CATEGORY is for example: Blas1, Blas2, Sparse, Graph and FUNCTION is for example Dot, AXPBY, Update, GEMV etc.. An example is

Test_Blas1_Dot.hpp

The execution space directories contain one header file Test_EXECSPACE.hpp which generally is not touched, and the actual cpp files to instantiate the tests:

Test_EXECSPACE_CATEGORY_FUNCTION.cpp

for example

Test_OpenMP_Blas1_Dot.cpp

These cpp files will only have to include lines for example:

#include<Test_OpenMP.hpp>
#include<Test_Blas1_Dot.hpp>

In the actual Test header file the tests are defined through there internal implementation and the gtest macros. The Test_EXECSPACE.hpp files define two things to be used inside the test file:

#define TestCategory openmp
#define TestExecSpace Kokkos::OpenMP

This allows generic declarations inside of the actual test header files. For example:

#if defined(KOKKOSKERNELS_INST_FLOAT) || !defined(KOKKOSKERNELS_ETI_ONLY)
TEST_F( TestCategory, dot_float ) {
    test_dot<float,TestExecSpace> ();
}
#endif

#if defined(KOKKOSKERNELS_INST_DOUBLE) || !defined(KOKKOSKERNELS_ETI_ONLY)
TEST_F( TestCategory, dot_double ) {
    test_dot<double,TestExecSpace> ();
}
#endif

#if defined(KOKKOSKERNELS_INST_INT) || !defined(KOKKOSKERNELS_ETI_ONLY)
TEST_F( TestCategory, dot_int ) {
    test_dot<int,TestExecSpace> ();
}
#endif

Note the explicit scalar type instantiation as well as the inclusion of the scalar type into the test name (dot_int). The ETI guards make sure that the tests are only instantiated if either any instantiation is allowed (KOKKOSKERNELS_ETI_ONLY not defined) or the appropriate type is included in the ETI list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant