-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
193 lines (175 loc) · 6.06 KB
/
CMakeLists.txt
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
include_guard()
cmake_minimum_required(VERSION 3.14)
project(CudaLight)
include(${CMAKE_SOURCE_DIR}/cmake/All.cmake)
if (CONFIG_FOUND_CUDA_GPU)
set(LANGUAGES_USE_CUDA ON CACHE BOOL "" FORCE)
endif()
set(LINEAR_ALGEBRA_PROVIDER "MKL" CACHE STRING "Linear algebra provider")
set_property(CACHE LINEAR_ALGEBRA_PROVIDER PROPERTY STRINGS MKL OpenBlas Blas)
# Npy++ submodule
add_subdirectory(NpyCpp ${CMAKE_BINARY_DIR}/CudaLight/NpyCpp EXCLUDE_FROM_ALL)
# CudaLightKernels submodule
add_subdirectory(CudaLightKernels ${CMAKE_BINARY_DIR}/CudaLight/CudaLightKernels EXCLUDE_FROM_ALL)
# Cuda Wrappers
set(CUDA_KERNEL_INCLUDE "")
set(CUDA_KERNEL_DEPENDENCY "")
set(CUDA_KERNEL_TEST_SOURCE "")
mark_as_advanced(CUDA_KERNEL_INCLUDE)
mark_as_advanced(CUDA_KERNEL_DEPENDENCIES)
mark_as_advanced(CUDA_KERNEL_TEST_SOURCE)
if (CONFIG_FOUND_CUDA_GPU)
set(CUDA_KERNEL_INCLUDE CudaLightKernels)
set(CUDA_KERNEL_DEPENDENCY CudaLightKernels)
set(CUDA_KERNEL_TEST_SOURCE UnitTests/CuBlasTests.cpp
UnitTests/CubTests.cpp
UnitTests/CuSparseTests.cpp
UnitTests/DeviceManagerTests.cpp
UnitTests/MatrixTests.cpp
UnitTests/SerializationTests.cpp
UnitTests/SparseMatrixTests.cpp
UnitTests/SparseVectorTests.cpp
UnitTests/TensorTests.cpp
UnitTests/VectorTests.cpp)
endif()
# Mkl Wrappers
set(MKL_WRAPPERS_DEFINE "")
set(MKL_WRAPPERS_DEPENDENCIES "")
set(MKL_TEST_SOURCE "")
mark_as_advanced(MKL_WRAPPERS_DEFINE)
mark_as_advanced(MKL_WRAPPERS_DEPENDENCIES "")
mark_as_advanced(MKL_TEST_SOURCE "")
# OpenBLAS Wrappers
set(OBLAS_WRAPPERS_DEFINE "")
set(OBLAS_WRAPPERS_DEPENDENCIES "")
set(OBLAS_TEST_SOURCE "")
mark_as_advanced(OBLAS_WRAPPERS_DEFINE)
mark_as_advanced(OBLAS_WRAPPERS_DEPENDENCIES "")
mark_as_advanced(OBLAS_TEST_SOURCE "")
# Generic BLAS Wrappers
set(GBLAS_WRAPPERS_DEFINE "")
set(GBLAS_WRAPPERS_DEPENDENCIES "")
set(GBLAS_TEST_SOURCE "")
mark_as_advanced(GBLAS_WRAPPERS_DEFINE)
mark_as_advanced(GBLAS_WRAPPERS_DEPENDENCIES "")
mark_as_advanced(GBLAS_TEST_SOURCE "")
if (LINEAR_ALGEBRA_PROVIDER STREQUAL "MKL" AND MKL_FOUND)
message(STATUS "Using MKL provider")
set(MKL_WRAPPERS_DEFINE USE_MKL)
set(MKL_WRAPPERS_DEPENDENCIES MklRoutines)
set(MKL_TEST_SOURCE UnitTests/MklVectorTests.cpp
UnitTests/MklMatrixTests.cpp
UnitTests/MklTensorTests.cpp
UnitTests/MklBlasTests.cpp
UnitTests/MklSparseVectorTests.cpp
UnitTests/MklSparseMatrixTests.cpp
UnitTests/MklSparseTests.cpp
UnitTests/MklExtraRoutinesTests.cpp)
create_library(
NAME
MklRoutines
SOURCES
HostRoutines/MklAllWrappers.cpp
PUBLIC_INCLUDE_DIRECTORIES
. HostRoutines ${CUDA_KERNEL_INCLUDE}
PUBLIC_SYSTEM_INCLUDE_DIRECTORIES
${MKL_INCLUDE_DIR} CudaLightKernels
PUBLIC_COMPILE_DEFINITIONS
${MKL_WRAPPERS_DEFINE}
DEPENDENCIES
${MKL_LIBRARIES}
)
elseif (LINEAR_ALGEBRA_PROVIDER STREQUAL "OpenBlas" AND OpenBLAS_FOUND)
message(STATUS "Using OpenBlas provider")
set(OBLAS_WRAPPERS_DEFINE USE_OPEN_BLAS)
set(OBLAS_WRAPPERS_DEPENDENCIES OpenBlasRoutines)
set(OBLAS_TEST_SOURCE UnitTests/OpenBlasVectorTests.cpp
UnitTests/OpenBlasMatrixTests.cpp
UnitTests/OpenBlasTensorTests.cpp
UnitTests/OpenBlasTests.cpp
UnitTests/OpenBlasExtraRoutinesTests.cpp)
create_library(
NAME
OpenBlasRoutines
SOURCES
HostRoutines/OpenBlasAllWrappers.cpp
PUBLIC_INCLUDE_DIRECTORIES
. HostRoutines ${CUDA_KERNEL_INCLUDE}
PUBLIC_SYSTEM_INCLUDE_DIRECTORIES
${OpenBLAS_INCLUDE_DIR} CudaLightKernels
PUBLIC_COMPILE_DEFINITIONS
${OBLAS_WRAPPERS_DEFINE}
DEPENDENCIES
${OpenBLAS_LIB} ${LAPACK_LIBRARIES}
)
elseif (LINEAR_ALGEBRA_PROVIDER STREQUAL "Blas" AND BLAS_FOUND AND LAPACK_FOUND)
message(STATUS "Using generic Blas provider")
set(GBLAS_WRAPPERS_DEFINE USE_BLAS)
set(GBLAS_WRAPPERS_DEPENDENCIES GenericBlasRoutines)
set(GBLAS_TEST_SOURCE UnitTests/GenericBlasVectorTests.cpp
UnitTests/GenericBlasMatrixTests.cpp
UnitTests/GenericBlasTensorTests.cpp
UnitTests/GenericBlasTests.cpp
UnitTests/GenericBlasExtraRoutinesTests.cpp)
create_library(
NAME
GenericBlasRoutines
SOURCES
HostRoutines/GenericBlasAllWrappers.cpp
PUBLIC_INCLUDE_DIRECTORIES
. HostRoutines ${CUDA_KERNEL_INCLUDE}
PUBLIC_COMPILE_DEFINITIONS
${GBLAS_WRAPPERS_DEFINE} CudaLightKernels
DEPENDENCIES
${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}
)
endif()
create_library(
NAME
HostRoutines
SOURCES
HostRoutines/BufferInitializer.cpp
HostRoutines/MemoryManager.cpp
HostRoutines/BlasWrappers.cpp
HostRoutines/SparseWrappers.cpp
HostRoutines/Extra.cpp
HostRoutines/ForgeHelpers.cpp
PUBLIC_INCLUDE_DIRECTORIES
. HostRoutines CudaLightKernels ${CUDA_KERNEL_INCLUDE}
DEPENDENCIES
${MKL_WRAPPERS_DEPENDENCIES} ${OBLAS_WRAPPERS_DEPENDENCIES} ${GBLAS_WRAPPERS_DEPENDENCIES}
)
create_library(
NAME
CudaLight
SOURCES
CudaLight/DeviceManager.cpp
CudaLight/DeviceManagerHelper.cpp
CudaLight/Exception.cpp
PUBLIC_INCLUDE_DIRECTORIES
CudaLight
DEPENDENCIES
Npy++ ${CUDA_KERNEL_DEPENDENCY} HostRoutines
)
create_test(
NAME
CLTests
SOURCES
UnitTests/main.cpp
${CUDA_KERNEL_TEST_SOURCE}
${MKL_TEST_SOURCE}
${OBLAS_TEST_SOURCE}
${GBLAS_TEST_SOURCE}
UnitTests/HostVectorTests.cpp
UnitTests/HostMatrixTests.cpp
UnitTests/HostTensorTests.cpp
UnitTests/HostBlasTests.cpp
UnitTests/HostExtraRoutinesTests.cpp
UnitTests/HostSerializationTests.cpp
PUBLIC_INCLUDE_DIRECTORIES
${GTEST_INCLUDE_DIR}
DEPENDENCIES
CudaLight
SYSTEM_DEPENDENCIES
gtest pthread
)