From 41ff5a82d04baab1dc0407f456d85ef1eb4ef9be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Fri, 3 Nov 2023 17:27:41 +0100 Subject: [PATCH 1/3] Example: Also link static libraries to executables --- Example/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Example/CMakeLists.txt b/Example/CMakeLists.txt index ee18ce018..f3c20e95a 100644 --- a/Example/CMakeLists.txt +++ b/Example/CMakeLists.txt @@ -463,3 +463,9 @@ target_link_libraries ( my_demo PUBLIC my ) add_executable ( my_cxx_demo "Demo/my_demo.c" ) target_link_libraries ( my_cxx_demo PUBLIC my_cxx ) + +add_executable ( my_demo_static "Demo/my_demo.c" ) +target_link_libraries ( my_demo_static PUBLIC my_static ) + +add_executable ( my_cxx_demo_static "Demo/my_demo.c" ) +target_link_libraries ( my_cxx_demo_static PUBLIC my_cxx_static ) From d9c07b973c3a04a4df74c1da8bc12e974fd010b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Fri, 3 Nov 2023 17:44:13 +0100 Subject: [PATCH 2/3] CI: Try to execute all executables from example --- .github/workflows/build-arch-emu.yaml | 7 +++++ .github/workflows/build.yaml | 42 +++++++++++++++++++++++++- .github/workflows/root-cmakelists.yaml | 23 +++++++++++++- 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-arch-emu.yaml b/.github/workflows/build-arch-emu.yaml index 917b30b68..cea8619fb 100644 --- a/.github/workflows/build-arch-emu.yaml +++ b/.github/workflows/build-arch-emu.yaml @@ -174,6 +174,13 @@ jobs: cmake --build . echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Executing example\n" + printf "\033[1;35m C binary with shared libraries\033[0m\n" LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo + printf "\033[1;35m C++ binary with shared libraries\033[0m\n" + LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo + printf "\033[1;35m C binary with statically linked libraries\033[0m\n" + ./my_demo_static + printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n" + ./my_cxx_demo_static echo "::endgroup::" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1cc800168..7286f39a6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -191,7 +191,14 @@ jobs: cmake --build . echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Executing example\n" + printf "\033[1;35m C binary with shared libraries\033[0m\n" LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo + printf "\033[1;35m C++ binary with shared libraries\033[0m\n" + LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo + printf "\033[1;35m C binary with statically linked libraries\033[0m\n" + ./my_demo_static + printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n" + ./my_cxx_demo_static echo "::endgroup::" @@ -310,7 +317,14 @@ jobs: cmake --build . echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Executing example\n" + printf "\033[1;35m C binary with shared libraries\033[0m\n" ./my_demo + printf "\033[1;35m C++ binary with shared libraries\033[0m\n" + ./my_cxx_demo + printf "\033[1;35m C binary with statically linked libraries\033[0m\n" + ./my_demo_static + printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n" + ./my_cxx_demo_static echo "::endgroup::" @@ -468,8 +482,20 @@ jobs: cmake --build . echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Executing example\n" + printf "\033[1;35m C binary with shared libraries\033[0m\n" PATH="${GITHUB_WORKSPACE}/bin:${PATH}" \ ./my_demo + printf "\033[1;35m C++ binary with shared libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin:${PATH}" \ + ./my_cxx_demo + # We don't build a static version of GraphBLAS in CI. + # So we need to prepare the environment also for the following tests. + printf "\033[1;35m C binary with statically linked libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin:${PATH}" \ + ./my_demo_static + printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin:${PATH}" \ + ./my_cxx_demo_static echo "::endgroup::" @@ -664,5 +690,19 @@ jobs: cmake --build . --config Release echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Executing example\n" - PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" ./Release/my_demo + printf "\033[1;35m C binary with shared libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" \ + ./Release/my_demo + printf "\033[1;35m C++ binary with shared libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" \ + ./Release/my_cxx_demo + # We don't build a static version of GraphBLAS in CI. + # So we need to prepare the environment also for the following tests. + # Additionally, gmp, mpfr and BLAS are always shared libraries. + printf "\033[1;35m C binary with statically linked libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" \ + ./Release/my_demo_static + printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" \ + ./Release/my_cxx_demo_static echo "::endgroup::" diff --git a/.github/workflows/root-cmakelists.yaml b/.github/workflows/root-cmakelists.yaml index e47552bf5..c2da9c0dd 100644 --- a/.github/workflows/root-cmakelists.yaml +++ b/.github/workflows/root-cmakelists.yaml @@ -170,7 +170,14 @@ jobs: cmake --build . echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Executing example\n" + printf "\033[1;35m C binary with shared libraries\033[0m\n" LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo + printf "\033[1;35m C++ binary with shared libraries\033[0m\n" + LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo + printf "\033[1;35m C binary with statically linked libraries\033[0m\n" + ./my_demo_static + printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n" + ./my_cxx_demo_static echo "::endgroup::" @@ -349,5 +356,19 @@ jobs: cmake --build . --config Release echo "::endgroup::" printf "::group::\033[0;32m==>\033[0m Executing example\n" - PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" ./Release/my_demo + printf "\033[1;35m C binary with shared libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" \ + ./Release/my_demo + printf "\033[1;35m C++ binary with shared libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" \ + ./Release/my_cxx_demo + # We don't build a static version of GraphBLAS in CI. + # So we need to prepare the environment also for the following tests. + # Additionally, gmp, mpfr and BLAS are always shared libraries. + printf "\033[1;35m C binary with statically linked libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" \ + ./Release/my_demo_static + printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n" + PATH="${GITHUB_WORKSPACE}/bin;${GITHUB_WORKSPACE}/dependencies/bin;${PATH}" \ + ./Release/my_cxx_demo_static echo "::endgroup::" From 15db9d9f74e631cf4e1ab7ee77f781ef00fecf62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sat, 4 Nov 2023 14:27:03 +0100 Subject: [PATCH 3/3] GPUQREngine, GPURuntime: Fix issues when linking to static library. --- SPQR/GPUQREngine/CMakeLists.txt | 22 ++++++++++++++-------- SPQR/GPURuntime/CMakeLists.txt | 16 ++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/SPQR/GPUQREngine/CMakeLists.txt b/SPQR/GPUQREngine/CMakeLists.txt index ab44efe08..7d7ebac14 100644 --- a/SPQR/GPUQREngine/CMakeLists.txt +++ b/SPQR/GPUQREngine/CMakeLists.txt @@ -37,6 +37,8 @@ project ( gpuqrengine set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/../../SuiteSparse_config/cmake_modules ) +option ( ENABLE_CUDA "Enable CUDA acceleration" ON ) + include ( SuiteSparsePolicy ) #------------------------------------------------------------------------------- @@ -96,8 +98,11 @@ target_include_directories ( GPUQREngine PRIVATE "$" "$" ) -set_target_properties ( GPUQREngine PROPERTIES POSITION_INDEPENDENT_CODE ON ) -set_target_properties ( GPUQREngine PROPERTIES CUDA_SEPARABLE_COMPILATION ON ) +set_target_properties ( GPUQREngine PROPERTIES + POSITION_INDEPENDENT_CODE ON + CUDA_SEPARABLE_COMPILATION ON + CUDA_RESOLVE_DEVICE_SYMBOLS ON + CUDA_RUNTIME_LIBRARY Static ) target_link_libraries ( GPUQREngine PRIVATE CUDA::nvrtc CUDA::cudart_static CUDA::nvToolsExt CUDA::cublas ) target_compile_definitions ( GPUQREngine PRIVATE "SUITESPARSE_CUDA" ) @@ -128,13 +133,14 @@ if ( NOT NSTATIC ) target_include_directories ( GPUQREngine_static PRIVATE ${CUDAToolkit_INCLUDE_DIRS} ${GPUQRENGINE_INCLUDES} - "$" ) + $ + $ ) - target_include_directories ( GPUQREngine_static PRIVATE - "$" ) - - set_target_properties ( GPUQREngine_static PROPERTIES CUDA_SEPARABLE_COMPILATION ON ) - set_target_properties ( GPUQREngine_static PROPERTIES POSITION_INDEPENDENT_CODE ON ) + set_target_properties ( GPUQREngine_static PROPERTIES + POSITION_INDEPENDENT_CODE ON + CUDA_SEPARABLE_COMPILATION ON + CUDA_RESOLVE_DEVICE_SYMBOLS ON + CUDA_RUNTIME_LIBRARY Static ) target_link_libraries ( GPUQREngine_static PUBLIC CUDA::nvrtc CUDA::cudart_static CUDA::nvToolsExt CUDA::cublas ) target_compile_definitions ( GPUQREngine_static PRIVATE "SUITESPARSE_CUDA" ) diff --git a/SPQR/GPURuntime/CMakeLists.txt b/SPQR/GPURuntime/CMakeLists.txt index 3b9b7a979..babe4726a 100644 --- a/SPQR/GPURuntime/CMakeLists.txt +++ b/SPQR/GPURuntime/CMakeLists.txt @@ -51,10 +51,6 @@ configure_file ( "Config/SuiteSparse_GPURuntime.hpp.in" #------------------------------------------------------------------------------- -set ( CMAKE_CUDA_FLAGS "-cudart=static -lineinfo" ) -message ( STATUS "C++ flags for CUDA: ${CMAKE_CXX_FLAGS}" ) -message ( STATUS "nvcc flags for CUDA: ${CMAKE_CUDA_FLAGS}" ) - file ( GLOB SUITESPARSE_GPURUNTIME_SOURCES "Source/*.cpp" ) set ( SUITESPARSE_GPURUNTIME_INCLUDES Include ) @@ -81,8 +77,10 @@ target_include_directories ( GPURuntime PRIVATE ${SUITESPARSE_GPURUNTIME_INCLUDES} $ ) -set_target_properties ( GPURuntime PROPERTIES POSITION_INDEPENDENT_CODE ON ) -set_target_properties ( GPURuntime PROPERTIES CUDA_SEPARABLE_COMPILATION ON ) +set_target_properties ( GPURuntime PROPERTIES + POSITION_INDEPENDENT_CODE ON + CUDA_SEPARABLE_COMPILATION ON + CUDA_RUNTIME_LIBRARY Static ) target_link_libraries ( GPURuntime PRIVATE CUDA::nvrtc CUDA::cudart_static CUDA::nvToolsExt CUDA::cublas ) target_compile_definitions ( GPURuntime PRIVATE "SUITESPARSE_CUDA" ) @@ -115,8 +113,10 @@ if ( NOT NSTATIC ) ${SUITESPARSE_GPURUNTIME_INCLUDES} $ ) - set_target_properties ( GPURuntime_static PROPERTIES CUDA_SEPARABLE_COMPILATION ON ) - set_target_properties ( GPURuntime_static PROPERTIES POSITION_INDEPENDENT_CODE ON ) + set_target_properties ( GPURuntime_static PROPERTIES + POSITION_INDEPENDENT_CODE ON + CUDA_SEPARABLE_COMPILATION ON + CUDA_RUNTIME_LIBRARY Static ) target_link_libraries ( GPURuntime_static PUBLIC CUDA::nvrtc CUDA::cudart_static CUDA::nvToolsExt CUDA::cublas ) target_compile_definitions ( GPURuntime_static PRIVATE "SUITESPARSE_CUDA" )