Split tests to cpu and cuda

This commit is contained in:
2024-09-07 21:24:34 +02:00
parent f8220f0ec1
commit 591507ed21
16 changed files with 29 additions and 10 deletions

View File

@@ -17,8 +17,12 @@ endif()
if(USE_CUDA) if(USE_CUDA)
enable_language(CUDA) enable_language(CUDA)
add_definitions(-DUSE_CUDA) add_definitions(-DUSE_CUDA)
message(STATUS "Building library with CUDA support")
else()
message(STATUS "Building library without CUDA support")
endif() endif()
file(GLOB_RECURSE CPU_SOURCES file(GLOB_RECURSE CPU_SOURCES
src/layers/*.cpp src/layers/*.cpp
src/model/*.cpp src/model/*.cpp

View File

@@ -2,8 +2,6 @@
#include <algorithm> #include <algorithm>
#include "cuda_helper.cuh"
using namespace CUDANet; using namespace CUDANet;
void Module::addLayer(const std::string& name, Layers::SequentialLayer* layer) { void Module::addLayer(const std::string& name, Layers::SequentialLayer* layer) {

View File

@@ -1,17 +1,34 @@
find_package(GTest REQUIRED) find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS}) include_directories(${GTEST_INCLUDE_DIRS})
file(GLOB_RECURSE TEST_SOURCES file(GLOB COMMON_TEST_SOURCES
*.cu common/*.hpp
kernels/*.cu
layers/*.cu
model/*.cpp model/*.cpp
) )
add_executable(test_main if(USE_CUDA)
EXCLUDE_FROM_ALL file(GLOB TEST_SOURCES
${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) target_link_libraries(test_main ${GTEST_BOTH_LIBRARIES} CUDANet)