forked from ROCm/rocm-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
251 lines (211 loc) · 6.9 KB
/
CMakeLists.txt
File metadata and controls
251 lines (211 loc) · 6.9 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# Copyright Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.25.2)
project(rocm-libraries LANGUAGES C CXX ASM)
include(CheckLanguage)
check_language(Fortran)
if(CMAKE_Fortran_COMPILER)
enable_language(Fortran)
set(ROCM_LIBS_HAVE_FORTRAN TRUE)
else()
set(ROCM_LIBS_HAVE_FORTRAN FALSE)
message(STATUS "Fortran compiler not found - Fortran support disabled")
endif()
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW) # FetchContent timestamp handling
endif()
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW) # option() honors normal variables
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include(CMakeDependentOption)
include(GNUInstallDirs)
include(add_subdirectory_with_message)
include(fetch_rocm_cmake)
# --- Options and cache variables ---
option(ROCM_LIBS_SUPERBUILD "Enable superbuild mode" ON)
set(ROCM_LIBS_ENABLE_COMPONENTS "all"
CACHE STRING "Semicolon-separated list of components to build (default: 'all')"
)
set(DEFAULT_COMPONENTS
# shared
mxdatagenerator
rocroller
origami
# projects
hipblas-common
hipblaslt
rocprim
rocrand
)
set(AVAILABLE_COMPONENTS
${DEFAULT_COMPONENTS}
# dnn
hipdnn
miopen-provider
hipblaslt-provider
)
set(UNSUPPORTED_COMPONENTS
# shared
tensile
# projects
composablekernel
hipblas
hipcub
hipfft
hiprand
hipsolver
hipsparse
hipsparselt
miopen
rocblas
rocfft
rocsolver
rocsparse
rocthrust
)
# NOTE: This is a temp option to reduce warnings generated by rocm-cmake. However, these warnings
# are reasonable and should be addressed.
option(ROCM_WARN_TOOLCHAIN_VAR "Warn if the toolchain version is not supported" OFF)
option(CMAKE_MESSAGE_CONTEXT_SHOW "Show the context of the message" ON)
# --- Validate options ---
if(NOT ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "ROCM_LIBS_ENABLE_COMPONENTS is empty, use 'all' to enable all components")
endif()
if("all" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
set(ROCM_LIBS_ENABLE_COMPONENTS ${DEFAULT_COMPONENTS})
endif()
message(STATUS "Enabling components:")
foreach(component ${ROCM_LIBS_ENABLE_COMPONENTS})
if(component IN_LIST AVAILABLE_COMPONENTS)
message(STATUS " ${component} (supported)")
elseif(component IN_LIST UNSUPPORTED_COMPONENTS)
message(STATUS " ${component} (unsupported)")
else()
message(FATAL_ERROR "Unknown component: ${component}.")
endif()
endforeach()
# --- Add subdirectories ---
if("mxdatagenerator" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT mxdatagenerator
PREFIX_PATH shared
EXPECT_TARGET roc::mxDataGenerator
)
endif()
if("hipblas-common" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT hipblas-common
PREFIX_PATH projects
EXPECT_TARGET roc::hipblas-common
)
endif()
if("rocroller" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
# pip packages:
# pip install pytest-cmake
set(ROCROLLER_ENABLE_FETCH ON)
add_subdirectory_with_message(
COMPONENT rocroller
PREFIX_PATH shared
EXPECT_TARGET roc::rocroller
)
endif()
if("origami" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT origami
PREFIX_PATH shared
EXPECT_TARGET roc::origami
)
endif()
if("hipblaslt" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
set(HIPBLASLT_ENABLE_BLIS OFF)
add_subdirectory_with_message(
COMPONENT hipblaslt
PREFIX_PATH projects
EXPECT_TARGET roc::hipblaslt
)
endif()
if("rocprim" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT rocprim
PREFIX_PATH projects
EXPECT_TARGET rocprim
)
endif()
if("rocrand" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT rocrand
PREFIX_PATH projects
EXPECT_TARGET rocrand
)
endif()
# --- DNN components (opt-in, not part of default 'all' build) ---
if("hipdnn" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT hipdnn
PREFIX_PATH projects
EXPECT_TARGET hipdnn_backend
)
endif()
if("miopen-provider" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT miopen-provider
PREFIX_PATH dnn-providers
EXPECT_TARGET miopen_plugin
)
endif()
if("hipblaslt-provider" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT hipblaslt-provider
PREFIX_PATH dnn-providers
EXPECT_TARGET hipblaslt_plugin
)
endif()
# --- Projects not yet configured for superbuild ---
if("tensile" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "tensile is not yet supported in the superbuild")
endif()
if("rocsparse" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "rocsparse is not yet supported in the superbuild")
endif()
if("rocfft" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "rocfft is not yet supported in the superbuild")
endif()
if("hipfft" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipfft is not yet supported in the superbuild")
endif()
if("hipsparse" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipsparse is not yet supported in the superbuild")
endif()
if("composablekernel" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "composablekernel is not yet supported in the superbuild")
endif()
if("miopen" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "miopen is not yet supported in the superbuild")
endif()
if("hipcub" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipcub is not yet supported in the superbuild")
# NOTE: Currently, hipcub tries to expose the rocm::rocprim target if it isn't already found.
# This action should be removed so that rocprim is made an explicit dependency where required.
endif()
if("hiprand" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hiprand is not yet supported in the superbuild")
endif()
if("hipblas" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipblas is not yet supported in the superbuild")
endif()
if("hipsolver" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipsolver is not yet supported in the superbuild")
endif()
if("hipsparselt" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipsparselt is not yet supported in the superbuild")
endif()
if("rocblas" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "rocblas is not yet supported in the superbuild")
endif()
if("rocsolver" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "rocsolver is not yet supported in the superbuild")
endif()
if("rocthrust" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "rocthrust is not yet supported in the superbuild")
endif()