From c61e8da94a08714194d690f7f9090bdb15b0481d Mon Sep 17 00:00:00 2001 From: fis Date: Thu, 26 Jul 2018 05:09:18 +0800 Subject: [PATCH] Add config for USE_CUDA. --- CMakeLists.txt | 7 +++++++ src/common/CMakeLists.txt | 1 + src/common/{utils.h => utils.h.in} | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/common/CMakeLists.txt rename src/common/{utils.h => utils.h.in} (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c696cad27..4830b44d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,13 @@ ADD_LIBRARY(cpuh2o4gpu STATIC ${CPU_SOURCES} $) TARGET_LINK_LIBRARIES(cpuh2o4gpu ${BLAS_LIBRARIES}) #============= BUILD CPU LIBRARY +if (USE_CUDA) + set(HG_USE_CUDA 1) +else() + set(HG_USE_CUDA 0) +endif(USE_CUDA) +add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/src/common) + if(USE_CUDA) FIND_PACKAGE(CUDA 8.0 REQUIRED) FIND_PACKAGE(NVML REQUIRED) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt new file mode 100644 index 000000000..887751962 --- /dev/null +++ b/src/common/CMakeLists.txt @@ -0,0 +1 @@ +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/utils.h.in ${CMAKE_CURRENT_SOURCE_DIR}/utils.h) diff --git a/src/common/utils.h b/src/common/utils.h.in similarity index 97% rename from src/common/utils.h rename to src/common/utils.h.in index a2fb9ef7b..179b5f2ec 100644 --- a/src/common/utils.h +++ b/src/common/utils.h.in @@ -10,7 +10,7 @@ #include "cblas/cblas.h" -#define USE_CUDA() 1 +#define USE_CUDA() @HG_USE_CUDA@ template void self_dot(std::vector array_in, int n, int dim,