Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_learning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
aidge
aidge_learning
Commits
5ea85fe7
Commit
5ea85fe7
authored
5 months ago
by
Houssem ROUIS
Browse files
Options
Downloads
Patches
Plain Diff
Fix cuda linking
parent
cd0c1ed3
No related branches found
No related tags found
No related merge requests found
Pipeline
#59578
canceled
5 months ago
Stage: static_analysis
Stage: build
Stage: test
Stage: coverage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+2
-6
2 additions, 6 deletions
CMakeLists.txt
unit_tests/CMakeLists.txt
+38
-26
38 additions, 26 deletions
unit_tests/CMakeLists.txt
with
40 additions
and
32 deletions
CMakeLists.txt
+
2
−
6
View file @
5ea85fe7
...
@@ -8,12 +8,6 @@ project(aidge_learning
...
@@ -8,12 +8,6 @@ project(aidge_learning
DESCRIPTION
"Functions and alogrithms to train models in the AIDGE framework"
DESCRIPTION
"Functions and alogrithms to train models in the AIDGE framework"
LANGUAGES CXX
)
LANGUAGES CXX
)
# Enable CUDA if backend_cuda is found
find_package
(
aidge_backend_cuda
)
if
(
aidge_backend_cuda_FOUND
)
enable_language
(
CUDA
)
endif
()
message
(
STATUS
"Project name:
${
CMAKE_PROJECT_NAME
}
"
)
message
(
STATUS
"Project name:
${
CMAKE_PROJECT_NAME
}
"
)
message
(
STATUS
"Project version:
${
version
}
"
)
message
(
STATUS
"Project version:
${
version
}
"
)
...
@@ -26,6 +20,7 @@ option(PYBIND "python binding" OFF)
...
@@ -26,6 +20,7 @@ option(PYBIND "python binding" OFF)
option
(
WERROR
"Warning as error"
OFF
)
option
(
WERROR
"Warning as error"
OFF
)
option
(
TEST
"Enable tests"
ON
)
option
(
TEST
"Enable tests"
ON
)
option
(
COVERAGE
"Enable coverage"
OFF
)
option
(
COVERAGE
"Enable coverage"
OFF
)
option
(
ENABLE_ASAN
"Enable ASan (AddressSanitizer) for runtime analysis of memory use (over/underflow, memory leak, ...)"
OFF
)
##############################################
##############################################
# Import utils CMakeLists
# Import utils CMakeLists
...
@@ -37,6 +32,7 @@ endif()
...
@@ -37,6 +32,7 @@ endif()
##############################################
##############################################
# FIND Dependencies
# FIND Dependencies
if
(
NOT $ENV{AIDGE_INSTALL} STREQUAL
""
)
if
(
NOT $ENV{AIDGE_INSTALL} STREQUAL
""
)
set
(
CMAKE_INSTALL_PREFIX $ENV{AIDGE_INSTALL}
)
set
(
CMAKE_INSTALL_PREFIX $ENV{AIDGE_INSTALL}
)
list
(
APPEND CMAKE_PREFIX_PATH $ENV{AIDGE_INSTALL}
)
list
(
APPEND CMAKE_PREFIX_PATH $ENV{AIDGE_INSTALL}
)
...
...
This diff is collapsed.
Click to expand it.
unit_tests/CMakeLists.txt
+
38
−
26
View file @
5ea85fe7
I
nclude
(
FetchContent
)
i
nclude
(
FetchContent
)
# Fetch and make available Catch2 for unit testing
FetchContent_Declare
(
FetchContent_Declare
(
Catch2
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.0.1
# or a later release
GIT_TAG v3.0.1
# or a later release
)
)
FetchContent_MakeAvailable
(
Catch2
)
FetchContent_MakeAvailable
(
Catch2
)
# Gather all source files for the test executable
file
(
GLOB_RECURSE src_files
"*.cpp"
)
file
(
GLOB_RECURSE src_files
"*.cpp"
)
set
(
tests_exe tests
${
module_name
}
)
set
(
tests_exe tests
${
module_name
}
)
add_executable
(
tests_exe
${
src_files
}
)
set_target_properties
(
tests_exe PROPERTIES CUDA_SEPARABLE_COMPILATION ON
)
# Find required and optional dependencies
find_package
(
aidge_backend_cpu REQUIRED
)
find_package
(
aidge_backend_cpu REQUIRED
)
find_package
(
aidge_backend_cuda
)
find_package
(
aidge_backend_cuda
)
if
(
NOT DEFINED CMAKE_CUDA_STANDARD
)
# Find CUDA Toolkit if CUDA backend is available
set
(
CMAKE_CUDA_STANDARD 14
)
if
(
aidge_backend_cuda_FOUND
)
set
(
CMAKE_CUDA_STANDARD_REQUIRED ON
)
# Specify CUDA Toolkit without COMPONENTS to avoid missing imported targets
enable_language
(
CUDA
)
find_package
(
CUDA REQUIRED
)
find_package
(
CUDAToolkit REQUIRED
)
if
(
NOT DEFINED CMAKE_CUDA_STANDARD
)
set
(
CMAKE_CUDA_STANDARD 14
)
set
(
CMAKE_CUDA_STANDARD_REQUIRED ON
)
endif
()
endif
()
endif
()
target_link_libraries
(
tests_exe
# Define the test executable
add_executable
(
${
tests_exe
}
${
src_files
}
)
# Include CUDA headers
include_directories
(
${
CUDA_INCLUDE_DIRS
}
)
# Link against the required aidge_backend_cpu library
target_link_libraries
(
${
tests_exe
}
PUBLIC
${
module_name
}
_aidge_backend_cpu
PUBLIC
${
module_name
}
_aidge_backend_cpu
PRIVATE Catch2::Catch2WithMain
PRIVATE Catch2::Catch2WithMain
)
)
# Conditional CUDA linkage and definitions
if
(
aidge_backend_cuda_FOUND
)
if
(
aidge_backend_cuda_FOUND
)
# Enable CUDA language support and separable compilation for the target
enable_language
(
CUDA
)
enable_language
(
CUDA
)
find_package
(
CUDAToolkit REQUIRED
)
set_target_properties
(
${
tests_exe
}
PROPERTIES CUDA_SEPARABLE_COMPILATION ON
)
target_link_libraries
(
_aidge_backend_cuda
target_include_directories
(
${
tests_exe
}
PRIVATE
${
CUDAToolkit_INCLUDE_DIRS
}
)
INTERFACE
# Link manually specified CUDA libraries if the targets are not available
cudart
# Ensure CUDA dependencies are included
target_link_libraries
(
${
tests_exe
}
cublas
# Include other CUDA components if needed
PUBLIC
cudnn
_aidge_backend_cuda
)
CUDA::cudart
CUDA::cublas
target_include_directories
(
_aidge_backend_cuda INTERFACE
${
CUDAToolkit_INCLUDE_DIRS
}
)
cudnn
target_link_libraries
(
tests_exe
PUBLIC
${
module_name
}
_aidge_backend_cuda
)
)
# Define a preprocessor macro
if aidge_backend_cuda is linked
# Define a preprocessor macro
to indicate CUDA support
target_compile_definitions
(
tests_exe PUBLIC USE_AIDGE_BACKEND_CUDA
)
target_compile_definitions
(
${
tests_exe
}
PUBLIC USE_AIDGE_BACKEND_CUDA
)
endif
()
endif
()
# Add Catch2 test discovery
list
(
APPEND CMAKE_MODULE_PATH
${
catch2_SOURCE_DIR
}
/extras
)
list
(
APPEND CMAKE_MODULE_PATH
${
catch2_SOURCE_DIR
}
/extras
)
include
(
CTest
)
include
(
CTest
)
include
(
Catch
)
include
(
Catch
)
catch_discover_tests
(
tests_exe
)
catch_discover_tests
(
${
tests_exe
}
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment