blob: 7c15661899211459ca0adf461978a78e26d82c73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
diff --git a/cuda/CMakeLists.txt b/cuda/CMakeLists.txt
index 1cdc582de..70dd1afcd 100644
--- a/cuda/CMakeLists.txt
+++ b/cuda/CMakeLists.txt
@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
add_library(ginkgo_cuda $<TARGET_OBJECTS:ginkgo_cuda_device> "")
+add_library(ginkgo_cuda_2 $<TARGET_OBJECTS:ginkgo_cuda_device> "")
+add_library(ginkgo_cuda_3 $<TARGET_OBJECTS:ginkgo_cuda_device> "")
+add_library(ginkgo_cuda_4 $<TARGET_OBJECTS:ginkgo_cuda_device> "")
+add_library(ginkgo_cuda_5 $<TARGET_OBJECTS:ginkgo_cuda_device> "")
include(${PROJECT_SOURCE_DIR}/cmake/template_instantiation.cmake)
add_instantiation_files(${PROJECT_SOURCE_DIR}/common/cuda_hip matrix/csr_kernels.instantiate.cpp CSR_INSTANTIATE)
add_instantiation_files(${PROJECT_SOURCE_DIR}/common/cuda_hip matrix/fbcsr_kernels.instantiate.cpp FBCSR_INSTANTIATE)
@@ -9,6 +13,24 @@ add_instantiation_files(${PROJECT_SOURCE_DIR}/common/cuda_hip solver/batch_cg_la
add_instantiation_files(. solver/batch_cg_launch.instantiate.cu BATCH_CG_INSTANTIATE2)
# we don't split up the dense kernels into distinct compilations
list(APPEND GKO_UNIFIED_COMMON_SOURCES ${PROJECT_SOURCE_DIR}/common/unified/matrix/dense_kernels.instantiate.cpp)
+target_sources(ginkgo_cuda_2
+ PRIVATE
+ ${GKO_UNIFIED_COMMON_SOURCES}
+)
+target_sources(ginkgo_cuda_3
+ PRIVATE
+ ${GKO_CUDA_HIP_COMMON_SOURCES}
+)
+target_sources(ginkgo_cuda_4
+ PRIVATE
+ ${BATCH_BICGSTAB_INSTANTIATE1}
+ ${BATCH_BICGSTAB_INSTANTIATE2}
+)
+target_sources(ginkgo_cuda_5
+ PRIVATE
+ ${BATCH_CG_INSTANTIATE1}
+ ${BATCH_CG_INSTANTIATE2}
+)
target_sources(ginkgo_cuda
PRIVATE
base/device.cpp
@@ -25,15 +47,9 @@ target_sources(ginkgo_cuda
matrix/fft_kernels.cu
preconditioner/batch_jacobi_kernels.cu
solver/batch_bicgstab_kernels.cu
- ${BATCH_BICGSTAB_INSTANTIATE1}
- ${BATCH_BICGSTAB_INSTANTIATE2}
solver/batch_cg_kernels.cu
- ${BATCH_CG_INSTANTIATE1}
- ${BATCH_CG_INSTANTIATE2}
solver/lower_trs_kernels.cu
solver/upper_trs_kernels.cu
- ${GKO_UNIFIED_COMMON_SOURCES}
- ${GKO_CUDA_HIP_COMMON_SOURCES}
)
if(GINKGO_JACOBI_FULL_OPTIMIZATIONS)
set(GKO_CUDA_JACOBI_BLOCK_SIZES)
@@ -53,46 +69,55 @@ target_sources(ginkgo_cuda PRIVATE ${GKO_CUDA_JACOBI_SOURCES})
string(REPLACE ";" "," GKO_JACOBI_BLOCK_SIZES_CODE "${GKO_CUDA_JACOBI_BLOCK_SIZES}")
configure_file(${Ginkgo_SOURCE_DIR}/common/cuda_hip/preconditioner/jacobi_common.hpp.in common/cuda_hip/preconditioner/jacobi_common.hpp)
-if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
+function(confgure_cuda_target target_name)
+ if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
# remove false positive CUDA warnings when calling one<T>() and zero<T>()
# and allows the usage of std::array for nvidia GPUs
- target_compile_options(ginkgo_cuda
+ target_compile_options(${target_name}
PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr>)
if(MSVC)
- target_compile_options(ginkgo_cuda
+ target_compile_options(${target_name}
PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
else()
- target_compile_options(ginkgo_cuda
+ target_compile_options(${target_name}
PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:--expt-extended-lambda>)
endif()
-endif()
+ endif()
-ginkgo_compile_features(ginkgo_cuda)
-target_compile_definitions(ginkgo_cuda PRIVATE GKO_COMPILING_CUDA GKO_DEVICE_NAMESPACE=cuda)
-if(GINKGO_CUDA_CUSTOM_THRUST_NAMESPACE)
- target_compile_definitions(ginkgo_cuda PRIVATE THRUST_CUB_WRAPPED_NAMESPACE=gko)
-endif()
+ ginkgo_compile_features(${target_name})
+ target_compile_definitions(${target_name} PRIVATE GKO_COMPILING_CUDA GKO_DEVICE_NAMESPACE=cuda)
+ if(GINKGO_CUDA_CUSTOM_THRUST_NAMESPACE)
+ target_compile_definitions(${target_name} PRIVATE THRUST_CUB_WRAPPED_NAMESPACE=gko)
+ endif()
-# include path for generated headers like jacobi_common.hpp
-target_include_directories(ginkgo_cuda
+ # include path for generated headers like jacobi_common.hpp
+ target_include_directories(${target_name}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
-target_link_libraries(ginkgo_cuda PRIVATE CUDA::cudart CUDA::cublas CUDA::cusparse CUDA::curand CUDA::cufft nvtx::nvtx)
-# NVTX3 is header-only and requires dlopen/dlclose in static builds
-target_link_libraries(ginkgo_cuda PUBLIC ginkgo_device ${CMAKE_DL_LIBS})
+ target_link_libraries(${target_name} PRIVATE CUDA::cudart CUDA::cublas CUDA::cusparse CUDA::curand CUDA::cufft nvtx::nvtx)
+ # NVTX3 is header-only and requires dlopen/dlclose in static builds
+ target_link_libraries(${target_name} PUBLIC ginkgo_device ${CMAKE_DL_LIBS})
-ginkgo_default_includes(ginkgo_cuda)
-ginkgo_install_library(ginkgo_cuda)
+ ginkgo_default_includes(${target_name})
+ ginkgo_install_library(${target_name})
-if(GINKGO_CHECK_CIRCULAR_DEPS)
+ if(GINKGO_CHECK_CIRCULAR_DEPS)
set(check_header_def "GKO_COMPILING_CUDA;GKO_DEVICE_NAMESPACE=cuda")
if(GINKGO_CUDA_CUSTOM_THRUST_NAMESPACE)
set(check_header_def "${check_header_def};THRUST_CUB_WRAPPED_NAMESPACE=gko")
endif()
- ginkgo_check_headers(ginkgo_cuda "${check_header_def}")
-endif()
+ ginkgo_check_headers(${target_name} "${check_header_def}")
+ endif()
+endfunction()
+
+confgure_cuda_target(ginkgo_cuda)
+confgure_cuda_target(ginkgo_cuda_2)
+confgure_cuda_target(ginkgo_cuda_3)
+confgure_cuda_target(ginkgo_cuda_4)
+confgure_cuda_target(ginkgo_cuda_5)
+target_link_libraries(ginkgo_cuda PUBLIC ginkgo_cuda_2 ginkgo_cuda_3 ginkgo_cuda_4 ginkgo_cuda_5)
if(GINKGO_BUILD_TESTS)
add_subdirectory(test)
|