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

Uses Valgrind for ExperimentalMemCheck in ctest #844

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,14 @@ jobs:
- name: Checkout LAPACK
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@16b940825621068d98711680b6c3ff92201f8fc0 # v3

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B build
cmake -B build -G Ninja
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-D CMAKE_INSTALL_PREFIX=${{github.workspace}}/lapack_install
-D CBLAS:BOOL=ON
Expand Down Expand Up @@ -181,4 +184,57 @@ jobs:
-D BUILD_SHARED_LIBS:BOOL=ON

- name: Install
run: cmake --build build --target install -j2
run: cmake --build build --target install -j2

memory-check:
runs-on: ubuntu-latest
env:
BUILD_TYPE: Debug

steps:

- name: Checkout LAPACK
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@16b940825621068d98711680b6c3ff92201f8fc0 # v3

- name: Install APT packages
run: |
sudo apt update
sudo apt install -y cmake valgrind gfortran

- name: Configure CMake
run: >
cmake -B build -G Ninja
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-D CBLAS:BOOL=ON
-D LAPACKE:BOOL=ON
-D BUILD_TESTING:BOOL=ON
-D LAPACKE_WITH_TMG:BOOL=ON
-D BUILD_SHARED_LIBS:BOOL=ON
-D LAPACK_TESTING_USE_PYTHON:BOOL=OFF

- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
run: |
ctest -C ${{env.BUILD_TYPE}} --schedule-random -j2 -T memcheck > memcheck.out
cat memcheck.out
if tail -n 1 memcheck.out | grep -q "Memory checking results:"; then
exit 0
else
for f in Testing/Temporary/MemoryChecker.*.log; do
if tail -n 1 $f | grep -q "ERROR SUMMARY: 0 errors"; then
tail -n 1 $f
continue
else
echo "Memory check failed in $f"
cat $f
exit 1
fi
done
exit 0
fi
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ if(_is_coverage_build)
find_package(codecov)
endif()

# Use valgrind if it is found
option( LAPACK_TESTING_USE_PYTHON "Use Python for testing. Disable it on memory checks." ON )
find_program( MEMORYCHECK_COMMAND valgrind )
if( MEMORYCHECK_COMMAND )
message( STATUS "Found valgrind: ${MEMORYCHECK_COMMAND}" )
set( MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --show-leak-kinds=all --track-origins=yes" )
endif()

# By default test Fortran compiler complex abs and complex division
option(TEST_FORTRAN_COMPILER "Test Fortran compiler complex abs and complex division" OFF)
if( TEST_FORTRAN_COMPILER )
Expand Down
3 changes: 2 additions & 1 deletion CTestCustom.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION

# Only run post test if suitable python interpreter was found
set(PYTHON_EXECUTABLE @PYTHON_EXECUTABLE@)
if(PYTHON_EXECUTABLE)
set(LAPACK_TESTING_USE_PYTHON @LAPACK_TESTING_USE_PYTHON@)
if(PYTHON_EXECUTABLE AND LAPACK_TESTING_USE_PYTHON)
set(CTEST_CUSTOM_POST_TEST "${PYTHON_EXECUTABLE} ./lapack_testing.py -s -d TESTING")
endif()

6 changes: 6 additions & 0 deletions LAPACKE/example/example_DGESV_colmajor.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ int main(int argc, char **argv) {
print_matrix_colmajor( "Details of LU factorization", n, n, A, lda );
/* Print pivot indices */
print_vector( "Pivot indices", n, ipiv );

/* Free matrices and vectors */
free(A);
free(b);
free(ipiv);

exit( 0 );
} /* End of LAPACKE_dgesv Example */

6 changes: 6 additions & 0 deletions LAPACKE/example/example_DGESV_rowmajor.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ int main(int argc, char **argv) {
print_matrix_rowmajor( "Details of LU factorization", n, n, A, lda );
/* Print pivot indices */
print_vector( "Pivot indices", n, ipiv );

/* Free matrices and vectors */
free(A);
free(b);
free(ipiv);

exit( 0 );
} /* End of LAPACKE_dgesv Example */

4 changes: 2 additions & 2 deletions TESTING/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ add_subdirectory(EIG)


# Only run this test if python 3 is found
if(PYTHON_EXECUTABLE)
if(PYTHON_EXECUTABLE AND LAPACK_TESTING_USE_PYTHON)
message(STATUS "Enabling LAPACK test summary (see TESTING/testing_results.txt)")
file(COPY ${LAPACK_SOURCE_DIR}/lapack_testing.py DESTINATION ${LAPACK_BINARY_DIR})
add_test(
Expand All @@ -38,7 +38,7 @@ function(add_lapack_test output input target)
-DINTDIR=${CMAKE_CFG_INTDIR}
-P "${LAPACK_SOURCE_DIR}/TESTING/runtest.cmake")

if(PYTHON_EXECUTABLE)
if(PYTHON_EXECUTABLE AND LAPACK_TESTING_USE_PYTHON)
set_property(
TEST LAPACK_Test_Summary
APPEND PROPERTY DEPENDS LAPACK-${testName}
Expand Down
Loading