Skip to content

Commit b5df973

Browse files
committed
keep the same cudart behaviour as the previous one
1 parent 5cdc9cd commit b5df973

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

benchmark/spmv/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ add_executable(spmv spmv.cpp)
22
target_link_libraries(spmv ginkgo gflags rapidjson)
33
if (GINKGO_BUILD_CUDA)
44
target_compile_definitions(spmv PRIVATE HAS_CUDA=1)
5-
if("${CUDA_RUNTIME_LIBS}" MATCHES "Threads::Threads")
6-
# need to import Threads
7-
set(THREADS_PREFER_PTHREAD_FLAG ON)
8-
find_package(Threads REQUIRED)
9-
endif()
105
target_link_libraries(spmv ginkgo ${CUDA_RUNTIME_LIBS}
116
${CUBLAS} ${CUSPARSE})
127
target_include_directories(spmv SYSTEM PRIVATE ${CUDA_INCLUDE_DIRS})

cuda/CMakeLists.txt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,23 @@ set(CMAKE_CUDA_COMPILER_VERSION ${CMAKE_CUDA_COMPILER_VERSION} PARENT_SCOPE)
3434
set(CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS} PARENT_SCOPE)
3535

3636

37-
# nvcc uses static cudartlibrary by default
37+
# MSVC nvcc uses static cudartlibrary by default, and other platforms use shared cudartlibrary.
3838
# add `-cudart shared` or `-cudart=shared` according system into CMAKE_CUDA_FLAGS/GINKGO_CUDA_COMPILER_FLAGS
39-
# to force nvcc to use dynamic cudart library.
39+
# to force nvcc to use dynamic cudart library in MSVC.
4040
find_library(CUDA_RUNTIME_LIBS_DYNAMIC cudart
4141
HINT ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
4242
find_library(CUDA_RUNTIME_LIBS_STATIC cudart_static
4343
HINT ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
44-
45-
if("${CMAKE_CUDA_FLAGS}" MATCHES "-cudart(=| )shared" OR "${GINKGO_CUDA_COMPILER_FLAGS}" MATCHES "-cudart(=| )shared")
46-
set(CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_DYNAMIC}" CACHE STRING "Path to a library" FORCE)
47-
else()
48-
set(CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_STATIC}" CACHE STRING "Path to a library" FORCE)
49-
if(NOT MSVC)
50-
set(THREADS_PREFER_PTHREAD_FLAG ON)
51-
find_package(Threads REQUIRED)
52-
# link cudart_static need rt, pthread, and dl
53-
set(CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_STATIC};rt;Threads::Threads;-Wl,--no-as-needed;dl" CACHE STRING "Path to a library" FORCE)
44+
if(MSVC)
45+
if("${CMAKE_CUDA_FLAGS}" MATCHES "-cudart(=| )shared" OR "${GINKGO_CUDA_COMPILER_FLAGS}" MATCHES "-cudart(=| )shared")
46+
set(CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_DYNAMIC}" CACHE STRING "Path to a library" FORCE)
47+
else()
48+
set(CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_STATIC}" CACHE STRING "Path to a library" FORCE)
5449
endif()
50+
else()
51+
set(CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_DYNAMIC}" CACHE STRING "Path to a library" FORCE)
5552
endif()
53+
5654
find_library(CUBLAS cublas
5755
HINT ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
5856
find_library(CUSPARSE cusparse

0 commit comments

Comments
 (0)