SINGA-177 Add fully cmake supporting for the compilation of singa_v1 Add #include "singa_config.h" into files that use compile macros.
Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/72923b1c Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/72923b1c Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/72923b1c Branch: refs/heads/master Commit: 72923b1cbd6ba61da5abe7e3708a7515ad658607 Parents: 611554f Author: Wei Wang <[email protected]> Authored: Mon May 23 23:33:04 2016 +0800 Committer: Wei Wang <[email protected]> Committed: Mon May 23 23:33:04 2016 +0800 ---------------------------------------------------------------------- include/singa/core/common.h | 1 + include/singa/core/device.h | 2 +- include/singa/utils/cuda_utils.h | 7 ++++++- src/CMakeLists.txt | 18 +++++++++--------- src/core/device/cuda_gpu.cc | 1 + src/core/tensor/tensor_math_cuda.h | 1 + src/model/layer/cudnn_dropout.cc | 2 +- src/model/layer/cudnn_dropout.h | 7 ++++--- src/model/layer/cudnn_utils.h | 1 + test/singa/test_cudnn_dropout.cc | 2 +- 10 files changed, 26 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72923b1c/include/singa/core/common.h ---------------------------------------------------------------------- diff --git a/include/singa/core/common.h b/include/singa/core/common.h index 61c1c41..9d005c4 100644 --- a/include/singa/core/common.h +++ b/include/singa/core/common.h @@ -20,6 +20,7 @@ #define SINGA_CORE_COMMON_H_ #include <random> #include <chrono> +#include "./singa_config.h" #include "singa/utils/logging.h" #ifdef USE_CUDA http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72923b1c/include/singa/core/device.h ---------------------------------------------------------------------- diff --git a/include/singa/core/device.h b/include/singa/core/device.h index a67b564..23c2431 100644 --- a/include/singa/core/device.h +++ b/include/singa/core/device.h @@ -23,7 +23,7 @@ #include <vector> #include <string> #include <functional> - +#include "singa_config.h" #include "singa/core/common.h" #include "singa/core/memory.h" #include "singa/core/scheduler.h" http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72923b1c/include/singa/utils/cuda_utils.h ---------------------------------------------------------------------- diff --git a/include/singa/utils/cuda_utils.h b/include/singa/utils/cuda_utils.h index b2bb5c5..076d0d1 100644 --- a/include/singa/utils/cuda_utils.h +++ b/include/singa/utils/cuda_utils.h @@ -1,5 +1,9 @@ // from caffe include/caffe/util/device_alternative.hpp +#ifndef SINGA_UTILS_CUDA_UTILS_H_ +#define SINGA_UTILS_CUDA_UTILS_H_ +#include "singa_config.h" +#ifdef USE_CUDA #include <cublas_v2.h> #include <cuda.h> #include <cuda_runtime.h> @@ -91,4 +95,5 @@ const char* curandGetErrorString(curandStatus_t error) { } return "Unknown curand status"; } - +#endif +#endif // SINGA_UTILS_CUDA_UTILS_H_ http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72923b1c/src/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 39383bd..92e7fe5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,14 +3,14 @@ FILE(GLOB proto_files proto/*.proto) singa_protobuf_generate_cpp_py(${proto_gen_folder} proto_srcs proto_hdrs proto_python ${proto_files}) # include python files either to force generation ADD_LIBRARY(proto STATIC ${proto_hdrs} ${proto_srcs} ${proto_python}) -LIST(APPEND singa_linker_libs proto) +LIST(APPEND SINGA_LINKER_LIBS proto) #FILE(GLOB_RECURSE utils_source ${CMAKE_CURRENT_SOURCE_DIR}/utils/ "*.cc") AUX_SOURCE_DIRECTORY(utils utils_source) #message(STATUS "UTILS ${utils_source}") ADD_LIBRARY(singa_utils SHARED ${utils_source}) -TARGET_LINK_LIBRARIES(singa_utils ${singa_linker_libs}) -LIST(APPEND singa_linker_libs singa_utils) +TARGET_LINK_LIBRARIES(singa_utils ${SINGA_LINKER_LIBS}) +LIST(APPEND SINGA_LINKER_LIBS singa_utils) #FILE(GLOB_RECURSE core_source ${CMAKE_CURRENT_SOURCE_DIR}/core/ "*.cc") @@ -20,17 +20,17 @@ AUX_SOURCE_DIRECTORY(core/scheduler core_source) AUX_SOURCE_DIRECTORY(core/tensor core_source) #message(STATUS "CORE ${core_source}") ADD_LIBRARY(singa_core SHARED ${core_source}) -TARGET_LINK_LIBRARIES(singa_core ${singa_linker_libs}) -LIST(APPEND singa_linker_libs singa_core) -#MESSAGE(STATUS "link libs " ${singa_linker_libs}) +TARGET_LINK_LIBRARIES(singa_core ${SINGA_LINKER_LIBS}) +LIST(APPEND SINGA_LINKER_LIBS singa_core) +#MESSAGE(STATUS "link libs " ${SINGA_LINKER_LIBS}) #FILE(GLOB_RECURSE model_source ${CMAKE_CURRENT_SOURCE_DIR}/model/ "*.cc") AUX_SOURCE_DIRECTORY(model model_source) AUX_SOURCE_DIRECTORY(model/layer model_source) #MESSAGE(STATUS "MODEL ${model_source}") ADD_LIBRARY(singa_model SHARED ${model_source}) -TARGET_LINK_LIBRARIES(singa_model ${singa_linker_libs}) -LIST(APPEND singa_linker_libs singa_model) +TARGET_LINK_LIBRARIES(singa_model ${SINGA_LINKER_LIBS}) +LIST(APPEND SINGA_LINKER_LIBS singa_model) #ADD_LIBRARY(singa_layer SHARED ${LAYER_SOURCE}) #ADD_LIBRARY(singa_model SHARED ${MODEL_SOURCE}) @@ -40,4 +40,4 @@ LIST(APPEND singa_linker_libs singa_model) #TARGET_LINK_LIBRARIES(singa_layer singa_core singa_utils) #TARGET_LINK_LIBRARIES(singa_model singa_layer singa_core singa_utils) -#ADD_LIBRARY(singa SHARED ${singa_linker_libs}) +#ADD_LIBRARY(singa SHARED ${SINGA_LINKER_LIBS}) http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72923b1c/src/core/device/cuda_gpu.cc ---------------------------------------------------------------------- diff --git a/src/core/device/cuda_gpu.cc b/src/core/device/cuda_gpu.cc index 8eafc4c..59a5f45 100644 --- a/src/core/device/cuda_gpu.cc +++ b/src/core/device/cuda_gpu.cc @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "singa_config.h" #ifdef USE_CUDA #include <cublas_v2.h> #include <cuda.h> http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72923b1c/src/core/tensor/tensor_math_cuda.h ---------------------------------------------------------------------- diff --git a/src/core/tensor/tensor_math_cuda.h b/src/core/tensor/tensor_math_cuda.h index 991e8bb..40f9210 100644 --- a/src/core/tensor/tensor_math_cuda.h +++ b/src/core/tensor/tensor_math_cuda.h @@ -19,6 +19,7 @@ #ifndef SINGA_CORE_TENSOR_TENSOR_MATH_CUDA_H_ #define SINGA_CORE_TENSOR_TENSOR_MATH_CUDA_H_ #include "./tensor_math.h" +#include "singa_config.h" #include "singa/core/common.h" http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72923b1c/src/model/layer/cudnn_dropout.cc ---------------------------------------------------------------------- diff --git a/src/model/layer/cudnn_dropout.cc b/src/model/layer/cudnn_dropout.cc index 65cd8e5..64a581b 100644 --- a/src/model/layer/cudnn_dropout.cc +++ b/src/model/layer/cudnn_dropout.cc @@ -15,11 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "./cudnn_dropout.h" #ifdef USE_CUDNN // cudnn dropout is added in cudnn 5 #if CUDNN_VERSION_MAJOR >= 5 -#include "./cudnn_dropout.h" #include <cudnn.h> #include <chrono> http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72923b1c/src/model/layer/cudnn_dropout.h ---------------------------------------------------------------------- diff --git a/src/model/layer/cudnn_dropout.h b/src/model/layer/cudnn_dropout.h index a7d00e0..d3b3de6 100644 --- a/src/model/layer/cudnn_dropout.h +++ b/src/model/layer/cudnn_dropout.h @@ -18,16 +18,17 @@ #ifndef SRC_MODEL_LAYER_CUDNN_DROPOUT_H_ #define SRC_MODEL_LAYER_CUDNN_DROPOUT_H_ +#include "singa_config.h" #ifdef USE_CUDNN // cudnn dropout is added in cudnn 5 - #if CUDNN_VERSION_MAJOR >= 5 +#if CUDNN_VERSION_MAJOR >= 5 +#include "./dropout.h" + #include <cudnn.h> #include <utility> #include <string> #include <vector> -#include "./dropout.h" -#include "singa/core/common.h" #include "singa/model/layer.h" #include "singa/proto/core.pb.h" http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72923b1c/src/model/layer/cudnn_utils.h ---------------------------------------------------------------------- diff --git a/src/model/layer/cudnn_utils.h b/src/model/layer/cudnn_utils.h index 298ee5c..039a1ac 100644 --- a/src/model/layer/cudnn_utils.h +++ b/src/model/layer/cudnn_utils.h @@ -18,6 +18,7 @@ #ifndef SRC_MODEL_LAYER_CUDNN_UTILS_H_ #define SRC_MODEL_LAYER_CUDNN_UTILS_H_ +#include "singa_config.h" #ifdef USE_CUDNN #include <cudnn.h> http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72923b1c/test/singa/test_cudnn_dropout.cc ---------------------------------------------------------------------- diff --git a/test/singa/test_cudnn_dropout.cc b/test/singa/test_cudnn_dropout.cc index 5fdc554..393d555 100644 --- a/test/singa/test_cudnn_dropout.cc +++ b/test/singa/test_cudnn_dropout.cc @@ -18,11 +18,11 @@ * under the License. * *************************************************************/ +#include "../src/model/layer/cudnn_dropout.h" #ifdef USE_CUDNN // cudnn dropout is added in cudnn 5 //#if CUDNN_MAJOR_VERSION >= 5 -#include "../src/model/layer/cudnn_dropout.h" #include "gtest/gtest.h" bool inline GetBitValue(const char* x, int pos) {
