Commit 5071ea57 authored by Uldis Locans's avatar Uldis Locans

add option to link DKS with static cuda libraries

parent efe5f0db
......@@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED (VERSION 3.2)
PROJECT (DKS)
SET (DKS_VERSION_MAJOR 1)
SET (DKS_VERSION_MINOR 1)
SET (DKS_VERSION_PATCH 1)
SET (DKS_VERSION_PATCH 2)
set (DKS_VERSION ${DKS_VERSION_MAJOR}.${DKS_VERSION_MINOR}.${DKS_VERSION_PATCH})
SET (PACKAGE \"dks\")
SET (PACKAGE_BUGREPORT \"locans.uldis@psi.ch\")
......@@ -28,8 +28,9 @@ MESSAGE (STATUS "OpenCL kernel files: ${OPENCL_KERNELS}")
set (BOOSTROOT $ENV{BOOST_DIR})
SET (Boost_USE_STATIC_LIBS OFF)
SET (Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE(Boost 1.55.0 REQUIRED COMPONENTS filesystem system)
FIND_PACKAGE(Boost 1.55 REQUIRED COMPONENTS filesystem system)
IF (Boost_FOUND)
MESSAGE (STATUS "Boost version: ${Boost_VERSION}")
MESSAGE (STATUS "Found boost include dir: ${Boost_INCLUDE_DIRS}")
MESSAGE (STATUS "Found boost library dir: ${Boost_LIBRARY_DIRS}")
MESSAGE (STATUS "Found boost libraries: ${Boost_LIBRARIES}")
......@@ -79,7 +80,7 @@ OPTION (USE_UQTK "Use UQTK" OFF)
IF (${CMAKE_C_COMPILER_ID} STREQUAL "Intel" OR USE_INTEL)
#for intel compiler turn on openmp and opencl
OPTION (USE_OPENCL "Use OpenCL" ON)
OPTION (USE_OPENCL "Use OpenCL" OFF)
OPTION (USE_CUDA "Use CUDA" OFF)
OPTION (USE_MIC "Use intel MIC" ON)
......@@ -113,15 +114,21 @@ ENDIF (${CMAKE_C_COMPILER_ID} STREQUAL "Intel" OR USE_INTEL)
IF ( (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") AND NOT USE_INTEL)
OPTION (USE_OPENCL "Use OpenCL" ON)
OPTION (USE_OPENCL "Use OpenCL" OFF)
OPTION (USE_CUDA "Use CUDA" OFF)
OPTION (USE_MIC "Use intel MIC" OFF)
OPTION (STATIC_CUDA "Link static cuda libraries" OFF)
IF (ENABLE_MUSR)
SET (USE_OPENCL ON)
ENDIF (ENABLE_MUSR)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG -O3 -Wall -fopenmp -std=c++11 -D__wsu")
FIND_PACKAGE(CUDA)
IF (CUDA_FOUND)
SET (USE_CUDA ON)
OPTION(CUDA_USE_STATIC_CUDA_RUNTIME "Use static cuda libraries" OFF)
INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})
LINK_DIRECTORIES(${CUDA_TOOLKIT_ROOT_DIR}/lib64)
LINK_DIRECTORIES(${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs)
......@@ -131,20 +138,27 @@ IF ( (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "
MESSAGE (STATUS "cuda version: ${CUDA_VERSION}")
SET(CUDA_PROPAGATE_HOST_FLAGS OFF)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lcudart -lcufft -lcublas -lnvToolsExt -DDKS_CUDA")
SET (CUDA_NVCC_FLAGS "-arch=sm_35 -DDEBUG -lcufft -lcublas -lcudart -fmad=false")
SET (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -DDEBUG -std=c++11 -D__wsu")
SET (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} ${OPENCL_KERNELS}")
SET (CUDA_NVCC_FLAGS "-arch=sm_35;-DDEBUG;-std=c++11;-D__wsu;-fmad=false")
SET (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};${OPENCL_KERNELS}")
IF (NOT STATIC_CUDA)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDKS_CUDA")
SET (DKS_CUDA_LIBS "-lcudadevrt -lcudart -lcufft -lcublas")
ELSE (NOT STATIC_CUDA)
SET (CUDA_SEPARABLE_COMPILATION ON)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDKS_CUDA -fPIC")
SET (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-rdc=true;-lcufft_static;-lcublas_static;-lcurand_static")
SET (DKS_CUDA_LIBS "-lcudadevrt -lcudart_static -lcufft_static -lcublas_static -lculibos")
ENDIF (NOT STATIC_CUDA)
#if cuda version >= 7.0 add runtime commpilation flags
IF (NOT CUDA_VERSION VERSION_LESS "7.0")
IF (NOT CUDA_VERSION VERSION_LESS "7.0" AND ENABLE_MUSR)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lnvrtc -lcuda")
ENDIF (NOT CUDA_VERSION VERSION_LESS "7.0")
ENDIF (NOT CUDA_VERSION VERSION_LESS "7.0" AND ENABLE_MUSR)
MESSAGE (STATUS "nvcc flags: ${CUDA_NVCC_FLAGS}")
SET(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
#set(CUDA_SEPARABLE_COMPILATION ON)
SET(BUILD_SHARED_LIBS OFF)
ENDIF (CUDA_FOUND)
......@@ -171,9 +185,9 @@ IF ( (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "
ENDIF(APPLE AND NOT CUDA_FOUND)
#if cuda found set cuda opencl flags
IF (CUDA_FOUND)
IF (CUDA_FOUND AND USE_OPENCL)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lOpenCL -lpthread -DDKS_OPENCL")
ENDIF (CUDA_FOUND)
ENDIF (CUDA_FOUND AND USE_OPENCL)
#if cuda not found but amd opencl found set opencl flags
IF (NOT CUDA_FOUND AND OpenCL_FOUND)
......
......@@ -112,26 +112,18 @@ IF (USE_CUDA)
CUDA_ADD_LIBRARY(dks ${DKS_SRCS})
CUDA_ADD_LIBRARY(dksshared SHARED ${DKS_SRCS})
IF (USE_UQTK)
TARGET_LINK_LIBRARIES(dks cudadevrt lreg UQTk quad uqtktools cvode-2.6.0 dsfmt lbfgs uqtklapack uqtkslatec uqtkblas gfortran)
TARGET_LINK_LIBRARIES(dksshared cudadevrt lreg UQTk quad uqtktools cvode-2.6.0 dsfmt lbfgs uqtklapack uqtkslatec uqtkblas gfortran)
ELSE (USE_UQTK)
TARGET_LINK_LIBRARIES(dks cudadevrt)
TARGET_LINK_LIBRARIES(dksshared cudadevrt)
ENDIF (USE_UQTK)
TARGET_LINK_LIBRARIES(dks ${DKS_CUDA_LIBS})
TARGET_LINK_LIBRARIES(dksshared ${DKS_CUDA_LIBS})
#TARGET_LINK_LIBRARIES(dks)
#TARGET_LINK_LIBRARIES(dksshared)
ELSE (USE_CUDA)
MESSAGE (STATUS "DKS srcs: ${DKS_SRCS}")
ADD_LIBRARY(dks ${DKS_SRCS})
ADD_LIBRARY(dksshared SHARED ${DKS_SRCS})
IF (USE_UQTK)
TARGET_LINK_LIBRARIES(dks lreg UQTk quad uqtktools cvode-2.6.0 dsfmt lbfgs uqtklapack uqtkslatec uqtkblas gfortran)
TARGET_LINK_LIBRARIES(dksshared lreg UQTk quad uqtktools cvode-2.6.0 dsfmt lbfgs uqtklapack uqtkslatec uqtkblas gfortran)
ELSE (USE_UQTK)
TARGET_LINK_LIBRARIES(dks)
TARGET_LINK_LIBRARIES(dksshared)
ENDIF(USE_UQTK)
TARGET_LINK_LIBRARIES(dks)
TARGET_LINK_LIBRARIES(dksshared)
ENDIF (USE_CUDA)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment