From 71af4bc7df3211335c2673a0723073d6efba9960 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Mon, 13 Apr 2026 14:09:02 +0900 Subject: [PATCH 1/2] remove old/deprecated options and enable cublas always --- .../plugins/SofaCUDA/Core/CMakeLists.txt | 20 ++----------------- .../Core/src/SofaCUDA/core/config.h.in | 5 +++-- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/applications/plugins/SofaCUDA/Core/CMakeLists.txt b/applications/plugins/SofaCUDA/Core/CMakeLists.txt index 05e8d3c428c..3a850011d51 100644 --- a/applications/plugins/SofaCUDA/Core/CMakeLists.txt +++ b/applications/plugins/SofaCUDA/Core/CMakeLists.txt @@ -67,20 +67,7 @@ sofa_find_package(Sofa.Component.Mass REQUIRED) # because of CudaMassType -> nee option(SOFACUDA_CORE_VERBOSE_PTXAS "???" OFF) -option(SOFACUDA_CUBLAS "Activate cublas support in CUDA (requires SOFACUDA_DOUBLE)." OFF) -if(SOFACUDA_CUBLAS) - set(SOFA_GPU_CUBLAS 1) # #cmakedefine - list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) - find_package(CUDASparse REQUIRED) -endif() - -# Note: THRUST is included in CUDA SDK 4.0+, it is recommended to use it if available -option(SOFACUDA_THRUST "Activate THRUST (for RadixSort)." ON) -if(SOFACUDA_THRUST) - set(SOFA_GPU_THRUST 1) # #cmakedefine -endif() - -option(SOFACUDA_DOUBLE "Activate double-precision support in CUDA (requires GT200+ GPU and -arch sm_13 flag." OFF) +option(SOFACUDA_DOUBLE "Activate double-precision support in CUDA." OFF) if(SOFACUDA_DOUBLE) set(SOFA_GPU_CUDA_DOUBLE 1) # #cmakedefine endif() @@ -126,10 +113,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.Mass) target_link_libraries(${PROJECT_NAME} PUBLIC CUDA::cudart) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17 cuda_std_17) - -if(SOFACUDA_CUBLAS) - target_link_libraries(${PROJECT_NAME} ${CUDA_cusparse_LIBRARY} CUDA::cublas) -endif() +target_link_libraries(${PROJECT_NAME} PUBLIC ${CUDA_cusparse_LIBRARY} CUDA::cublas) # see (I guess) https://github.com/sofa-framework/sofa/blob/314b95cbfba411bf8431486ea75b7c67c0bbcc76/Sofa/framework/Config/cmake/SofaMacrosInstall.cmake#L695 target_include_directories(${PROJECT_NAME} PUBLIC "$/include/${PROJECT_NAME}/${PROJECT_NAME}") diff --git a/applications/plugins/SofaCUDA/Core/src/SofaCUDA/core/config.h.in b/applications/plugins/SofaCUDA/Core/src/SofaCUDA/core/config.h.in index b9a7c3e611f..6cdd6ae5cc6 100644 --- a/applications/plugins/SofaCUDA/Core/src/SofaCUDA/core/config.h.in +++ b/applications/plugins/SofaCUDA/Core/src/SofaCUDA/core/config.h.in @@ -24,13 +24,14 @@ #include #include -#cmakedefine SOFA_GPU_THRUST #cmakedefine SOFA_GPU_CUDA_DOUBLE #cmakedefine SOFA_GPU_CUDA_PRECISE #cmakedefine SOFA_GPU_CUDA_DOUBLE_PRECISE -#cmakedefine SOFA_GPU_CUBLAS #cmakedefine01 SOFACUDA_CORE_HAVE_SOFA_GL +#define SOFA_GPU_THRUST +#define SOFA_GPU_CUBLAS + #ifdef SOFA_BUILD_SOFACUDA_CORE # define SOFACUDA_CORE_API SOFA_EXPORT_DYNAMIC_LIBRARY #else From 1ac433480dafc7825006b3736663dabf21570139 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Mon, 13 Apr 2026 14:10:57 +0900 Subject: [PATCH 2/2] same with double --- applications/plugins/SofaCUDA/Core/CMakeLists.txt | 6 ------ .../plugins/SofaCUDA/Core/src/SofaCUDA/core/config.h.in | 7 ++++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/applications/plugins/SofaCUDA/Core/CMakeLists.txt b/applications/plugins/SofaCUDA/Core/CMakeLists.txt index 3a850011d51..0b0060dbde4 100644 --- a/applications/plugins/SofaCUDA/Core/CMakeLists.txt +++ b/applications/plugins/SofaCUDA/Core/CMakeLists.txt @@ -67,12 +67,6 @@ sofa_find_package(Sofa.Component.Mass REQUIRED) # because of CudaMassType -> nee option(SOFACUDA_CORE_VERBOSE_PTXAS "???" OFF) -option(SOFACUDA_DOUBLE "Activate double-precision support in CUDA." OFF) -if(SOFACUDA_DOUBLE) - set(SOFA_GPU_CUDA_DOUBLE 1) # #cmakedefine -endif() - - # Note: with SOFA_GPU_CUDA_PRECISE and SOFA_GPU_CUDA_DOUBLE you get IEEE # 754-compliant floating point operations for addition and multiplication only. option(SOFACUDA_PRECISE "Use IEEE 754-compliant floating point operations." OFF) diff --git a/applications/plugins/SofaCUDA/Core/src/SofaCUDA/core/config.h.in b/applications/plugins/SofaCUDA/Core/src/SofaCUDA/core/config.h.in index 6cdd6ae5cc6..5ca68e13f34 100644 --- a/applications/plugins/SofaCUDA/Core/src/SofaCUDA/core/config.h.in +++ b/applications/plugins/SofaCUDA/Core/src/SofaCUDA/core/config.h.in @@ -24,13 +24,14 @@ #include #include -#cmakedefine SOFA_GPU_CUDA_DOUBLE +#define SOFA_GPU_CUDA_DOUBLE +#define SOFA_GPU_THRUST +#define SOFA_GPU_CUBLAS #cmakedefine SOFA_GPU_CUDA_PRECISE #cmakedefine SOFA_GPU_CUDA_DOUBLE_PRECISE + #cmakedefine01 SOFACUDA_CORE_HAVE_SOFA_GL -#define SOFA_GPU_THRUST -#define SOFA_GPU_CUBLAS #ifdef SOFA_BUILD_SOFACUDA_CORE # define SOFACUDA_CORE_API SOFA_EXPORT_DYNAMIC_LIBRARY