diff --git a/CMakeLists.txt b/CMakeLists.txt index a528fc51..41b531ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,16 +8,10 @@ INCLUDE(SetupTPLs) INCLUDE(SetupMFMG) INCLUDE(SetupCache) -# By default build a static library because CUDA does not work with a shared -# library -OPTION(BUILD_SHARED_LIBS "Build a shared library" OFF) INITIALIZE_CACHE() IF(${MFMG_ENABLE_CUDA}) - IF (${BUILD_SHARED_LIBS}) - MESSAGE(SEND_ERROR "CUDA build does not support shared library") - ENDIF() # ENABLE_LANGUAGE cannot be in a function and it has to be called in the # highest directory so we cannot encapsulate it ENABLE_LANGUAGE(CUDA) @@ -74,7 +68,7 @@ TARGET_INCLUDE_DIRECTORIES(mfmg SYSTEM PUBLIC ${DEAL_II_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES(mfmg PUBLIC ${DEAL_II_LIBRARIES}) TARGET_LINK_LIBRARIES(mfmg PUBLIC ${MFMG_CUDA_LIBRARIES}) TARGET_INCLUDE_DIRECTORIES(mfmg PUBLIC ${AMGX_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES(mfmg PUBLIC ${AMGX_LIBRARY}) +TARGET_LINK_LIBRARIES(mfmg PUBLIC ${AMGX_LIBRARIES}) TARGET_COMPILE_DEFINITIONS(mfmg PRIVATE ${CLANG_TIDY_DEFINITIONS}) IF(${Backtrace_FOUND}) diff --git a/cmake/SetupCUDA.cmake b/cmake/SetupCUDA.cmake index 1db1862d..b2139822 100644 --- a/cmake/SetupCUDA.cmake +++ b/cmake/SetupCUDA.cmake @@ -2,12 +2,16 @@ # the list of CUDA libraries that we are using FUNCTION(SET_CUDA_LIBRARIES) ADD_DEFINITIONS(-DMFMG_WITH_CUDA) + FIND_LIBRARY(CUSPARSE cusparse HINT ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) + FIND_LIBRARY(CUSOLVER cusolver HINT ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) SET(MFMG_CUDA_LIBRARIES - "cusparse" - "cusolver" + ${CUSPARSE} + ${CUSOLVER} PARENT_SCOPE ) - # cuSolver needs OpenMP + +#### OPENMP ################################################################## +# cuSOLVER needs OpenMP FIND_PACKAGE(OpenMP) IF(OPENMP_FOUND) SET(CMAKE_CXX_FLAGS @@ -21,4 +25,19 @@ FUNCTION(SET_CUDA_LIBRARIES) ELSE() MESSAGE(SEND_ERROR "Could not find OpenMP required by cuSolver") ENDIF() + +#### AMGX #################################################################### + IF(${MFMG_ENABLE_CUDA}) + IF (${MFMG_ENABLE_AMGX}) + FIND_LIBRARY(AMGX_LIBRARY amgx amgxsh PATH "${AMGX_DIR}/lib") + FIND_LIBRARY(CUBLAS cublas HINT ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) + SET(AMGX_LIBRARIES + ${AMGX_LIBRARY} + ${CUBLAS} + PARENT_SCOPE + ) + SET(AMGX_INCLUDE_DIR "${AMGX_DIR}/include" PARENT_SCOPE) + ADD_DEFINITIONS(-DMFMG_WITH_AMGX) + ENDIF() + ENDIF() ENDFUNCTION() diff --git a/cmake/SetupTPLs.cmake b/cmake/SetupTPLs.cmake index 515586a9..7bfa7a82 100644 --- a/cmake/SetupTPLs.cmake +++ b/cmake/SetupTPLs.cmake @@ -32,16 +32,3 @@ ELSE() ADD_DEFINITIONS(-DDEBUG) ENDIF() ENDIF() - -#### AMGX #################################################################### -IF(${MFMG_ENABLE_CUDA}) - IF (${MFMG_ENABLE_AMGX}) - ADD_LIBRARY(amgx STATIC IMPORTED) - SET_TARGET_PROPERTIES(amgx PROPERTIES IMPORTED_LOCATION - "${AMGX_DIR}/lib/libamgx.a" - IMPORTED_LINK_INTERFACE_LIBRARIES "cublas") - ADD_DEFINITIONS(-DMFMG_WITH_AMGX) - SET(AMGX_INCLUDE_DIR "${AMGX_DIR}/include") - SET(AMGX_LIBRARY amgx) - ENDIF() -ENDIF()