diff --git a/CMakeLists.txt b/CMakeLists.txt index e73c1e4..028d451 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,12 @@ endif() if(USE_CUDA) enable_language(CUDA) add_definitions(-DUSE_CUDA) + message(STATUS "Building library with CUDA support") +else() + message(STATUS "Building library without CUDA support") endif() + file(GLOB_RECURSE CPU_SOURCES src/layers/*.cpp src/model/*.cpp diff --git a/src/model/module.cpp b/src/model/module.cpp index 92c6b06..1fb5434 100644 --- a/src/model/module.cpp +++ b/src/model/module.cpp @@ -2,8 +2,6 @@ #include -#include "cuda_helper.cuh" - using namespace CUDANet; void Module::addLayer(const std::string& name, Layers::SequentialLayer* layer) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 325db35..4e10651 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,17 +1,34 @@ find_package(GTest REQUIRED) include_directories(${GTEST_INCLUDE_DIRS}) -file(GLOB_RECURSE TEST_SOURCES - *.cu - kernels/*.cu - layers/*.cu +file(GLOB COMMON_TEST_SOURCES + common/*.hpp model/*.cpp ) -add_executable(test_main - EXCLUDE_FROM_ALL - ${TEST_SOURCES} -) +if(USE_CUDA) + file(GLOB TEST_SOURCES + cuda/*.cu + cuda/kernels/*.cu + cuda/layers/*.cu + cuda/utils/*.cu + ) + add_executable(test_main + EXCLUDE_FROM_ALL + ${COMMON_TEST_SOURCES} + ${TEST_SOURCES} + ) + set_target_properties(test_main PROPERTIES CUDA_SEPARABLE_COMPILATION ON) +else() + file(GLOB TEST_SOURCES + cpu/*.cpp + ) + add_executable(test_main + EXCLUDE_FROM_ALL + ${COMMON_TEST_SOURCES} + ${TEST_SOURCES} + ) +endif() target_link_libraries(test_main ${GTEST_BOTH_LIBRARIES} CUDANet) diff --git a/test/kernels/test_activation_functions.cu b/test/cuda/kernels/test_activation_functions.cu similarity index 100% rename from test/kernels/test_activation_functions.cu rename to test/cuda/kernels/test_activation_functions.cu diff --git a/test/kernels/test_matmul.cu b/test/cuda/kernels/test_matmul.cu similarity index 100% rename from test/kernels/test_matmul.cu rename to test/cuda/kernels/test_matmul.cu diff --git a/test/layers/test_activation.cu b/test/cuda/layers/test_activation.cu similarity index 100% rename from test/layers/test_activation.cu rename to test/cuda/layers/test_activation.cu diff --git a/test/layers/test_avg_pooling.cu b/test/cuda/layers/test_avg_pooling.cu similarity index 100% rename from test/layers/test_avg_pooling.cu rename to test/cuda/layers/test_avg_pooling.cu diff --git a/test/layers/test_batch_norm.cu b/test/cuda/layers/test_batch_norm.cu similarity index 100% rename from test/layers/test_batch_norm.cu rename to test/cuda/layers/test_batch_norm.cu diff --git a/test/layers/test_concat.cu b/test/cuda/layers/test_concat.cu similarity index 100% rename from test/layers/test_concat.cu rename to test/cuda/layers/test_concat.cu diff --git a/test/layers/test_conv2d.cu b/test/cuda/layers/test_conv2d.cu similarity index 100% rename from test/layers/test_conv2d.cu rename to test/cuda/layers/test_conv2d.cu diff --git a/test/layers/test_dense.cu b/test/cuda/layers/test_dense.cu similarity index 100% rename from test/layers/test_dense.cu rename to test/cuda/layers/test_dense.cu diff --git a/test/layers/test_input.cu b/test/cuda/layers/test_input.cu similarity index 100% rename from test/layers/test_input.cu rename to test/cuda/layers/test_input.cu diff --git a/test/layers/test_max_pooling.cu b/test/cuda/layers/test_max_pooling.cu similarity index 100% rename from test/layers/test_max_pooling.cu rename to test/cuda/layers/test_max_pooling.cu diff --git a/test/layers/test_output.cu b/test/cuda/layers/test_output.cu similarity index 100% rename from test/layers/test_output.cu rename to test/cuda/layers/test_output.cu diff --git a/test/utils/test_vector.cu b/test/cuda/utils/test_vector.cu similarity index 100% rename from test/utils/test_vector.cu rename to test/cuda/utils/test_vector.cu diff --git a/test/model/test_model.cu b/test/model/test_model.cpp similarity index 100% rename from test/model/test_model.cu rename to test/model/test_model.cpp