mirror of
https://github.com/amd/blis.git
synced 2026-05-11 09:39:59 +00:00
Code coverage support in gtestsuite framework
- Tools used for code coverage are : Gcov and Lcov. - We need to use macros specified by gcov during compiliation of blis and gtestsuite. - Locv will generate coverage reports in html format. AMD-Internal: [CPUPL-2732] Change-Id: I17b30b4a322b8771f2d6a4ba28986cf0ccf3fba6
This commit is contained in:
@@ -58,6 +58,8 @@ set_property(CACHE BLIS_LINKING_TYPE PROPERTY STRINGS "static" "shared")
|
||||
|
||||
option(ENABLE_ASAN "Run tests using Address Sanatizer" OFF)
|
||||
|
||||
option(ENABLE_COVERAGE "Run tests for Code Coderage" OFF)
|
||||
|
||||
# Set variable if the platform is Linux based.
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(LINUX TRUE)
|
||||
@@ -146,6 +148,10 @@ if(LINUX)
|
||||
add_definitions(-DENABLE_ASAN)
|
||||
endif()
|
||||
|
||||
if(ENABLE_COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "-O0 --coverage")
|
||||
endif()
|
||||
|
||||
# Set GNU OpenMP library as the default option
|
||||
set(OpenMP_LIBRARY "GNU" CACHE STRING "Using GNU OpenMP library")
|
||||
# Set the possibe values of OpenMP runtimes
|
||||
|
||||
@@ -77,7 +77,18 @@ There are multiple configuration options to chose from when invoking CMake. Thos
|
||||
* To link shared BLIS, use `-DBLIS_LINKING_TYPE=shared`.
|
||||
## Address Sanitizer
|
||||
* To build using address sanitizer, configure using `-DENABLE_ASAN=ON`. [**OFF by default**]
|
||||
* An installation to BLIS which was build with ASAN flags needs to be provided.
|
||||
* An installation to BLIS which was build with ASAN flags[CFLAGS="-O0 -g -fsanitize=address"] needs to be provided.
|
||||
## Code Coverage[Only GCC Compiler]
|
||||
* BLIS : Configure BLIS Library with code coverage flags[CFLAGS="-O0 -fprofile-arcs -ftest-coverage"], compile and install.
|
||||
* Gtestsuite : To build for code coverage, configure cmake with `-DENABLE_COVERAGE=ON`. [**OFF by default**] and then compile and run the executable.
|
||||
* CodeCoverage : in gtestsuite folder, run the below mentioned steps or bash script - to generate html LCOV-code coverage report.
|
||||
Run the bash script : bash codecov.sh <blis_obj_path> <out_dir_name>
|
||||
or
|
||||
Steps to generate html LCOV-code coverage report.
|
||||
1. lcov --capture --directory <obj_path> --output-file <out_dir>.info
|
||||
2. lcov --remove <out_dir>.info -o <out_dir_fir>.info '/usr/*' '/*/_deps/*'
|
||||
3. genhtml <out_dir_fir>.info --output-directory <out_dir>
|
||||
4. In <out_dir>, open index.html file
|
||||
## BLIS Library Interface to be Tested
|
||||
* To build the testsuite using BLAS interface, configure using `-DTEST_INTERFACE=BLAS`. [**Default**]
|
||||
* To build the testsuite using CBLAS interface, configure using `-DTEST_INTERFACE=CBLAS`.
|
||||
@@ -215,7 +226,7 @@ Currently, we have the following behaviour in the different interfaces:
|
||||
* BLIS-typed prints and aborts.
|
||||
* BLAS prints and returns.
|
||||
* CBLAS prints and exits.
|
||||
For that reason, we currently test only for BLAS APIs, so ensure to add the #ifdef's as appropriate. Note that printing seems to be inconsistent.
|
||||
For that reason, we currently test only for BLAS APIs, so ensure to add the #ifdef's as appropriate. Note that printing seems to be inconsistent.
|
||||
|
||||
A test program would be looking like the following:
|
||||
```cpp
|
||||
@@ -227,7 +238,7 @@ A test program would be looking like the following:
|
||||
|
||||
/**
|
||||
* Testing invalid/incorrect input parameters.
|
||||
*
|
||||
*
|
||||
* storage : 'c', 'r', note BLAS is 'c' only.
|
||||
* transa, transb : 'n', 't', 'c'
|
||||
* m, n, k >= 0
|
||||
@@ -300,7 +311,7 @@ If we want to test for different lda combinations as well, especially for the ca
|
||||
If lda = 30, for the cases 3, 4, 7, 8 above, lda < max(1, m), so the requirement is not satisfied. Another issue is that lda depends on the storage type and on whether we test for non transpose, transpose or conjugate transpose matrices.
|
||||
|
||||
To overcome this issue and generate tests which fullfill the requirements for the correct value of the leading dimension of a matrix we use **lda increments** and do the lda computation as follows:
|
||||
* Depending on the parameters storage and trans, compute lda = max(1, k), where k is m or n, depending on the requirements.
|
||||
* Depending on the parameters storage and trans, compute lda = max(1, k), where k is m or n, depending on the requirements.
|
||||
* Add the lda_inc parameter: lda += lda_inc
|
||||
|
||||
To test an m-by-n matrix A (column-major), stored in an array a, use lda_inc = 0 as a parameter to the test generator. To test for the case where A is a submatrix of k-by-n matrix B, use lda_inc = k-m.
|
||||
|
||||
12
gtestsuite/codecov.sh
Executable file
12
gtestsuite/codecov.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Code Coverage for BLIS"
|
||||
echo "obj_dir_path : $1"
|
||||
echo "out_dir_name : $2"
|
||||
|
||||
#$1 : obj_dir_path
|
||||
#$2 : out_dir_name
|
||||
|
||||
lcov --capture --directory $1 --output-file $2.info
|
||||
lcov --remove $2.info -o $2_filtered.info '/usr/*' '/*/_deps/*'
|
||||
genhtml $2_filtered.info --output-directory $2
|
||||
@@ -82,6 +82,9 @@ foreach(dir ${DIRS})
|
||||
if(ENABLE_ASAN)
|
||||
target_link_libraries(${target_name}.${dir}.${subdir} -fsanitize=address)
|
||||
endif()
|
||||
if(ENABLE_COVERAGE)
|
||||
target_link_libraries(${target_name}.${dir}.${subdir} "--coverage")
|
||||
endif()
|
||||
if(TEST_INTERFACE STREQUAL "BLAS")
|
||||
target_compile_definitions(${target_name}.${dir}.${subdir} PUBLIC TEST_BLAS)
|
||||
elseif(TEST_INTERFACE STREQUAL "CBLAS")
|
||||
|
||||
Reference in New Issue
Block a user