forked from intel/compute-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platforms.cmake
305 lines (264 loc) · 11.2 KB
/
platforms.cmake
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#
# Copyright (C) 2018-2024 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(MAX_CORE 64)
set(ALL_CORE_TYPES "")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake${BRANCH_DIR_SUFFIX}fill_core_types.cmake)
set(ALL_CORE_TYPES_REVERSED ${ALL_CORE_TYPES})
list(REVERSE ALL_CORE_TYPES_REVERSED)
macro(FIND_IDX_FOR_CORE_TYPE CORE_TYPE CORE_IDX)
list(FIND ALL_CORE_TYPES "${CORE_TYPE}" CORE_IDX)
if(${CORE_IDX} EQUAL -1)
message(FATAL_ERROR "No ${CORE_TYPE} allowed, exiting")
endif()
endmacro()
macro(INIT_LIST LIST_TYPE ELEMENT_TYPE)
foreach(IT RANGE 0 ${MAX_CORE} 1)
list(APPEND ALL_${ELEMENT_TYPE}_${LIST_TYPE} " ")
endforeach()
endmacro()
macro(GET_LIST_FOR_CORE_TYPE LIST_TYPE ELEMENT_TYPE CORE_IDX OUT_LIST)
list(GET ALL_${ELEMENT_TYPE}_${LIST_TYPE} ${CORE_IDX} CORE_X_${LIST_TYPE})
string(REPLACE "," ";" ${OUT_LIST} ${CORE_X_${LIST_TYPE}})
endmacro()
macro(ADD_ITEM_FOR_CORE_TYPE LIST_TYPE ELEMENT_TYPE CORE_TYPE ITEM)
FIND_IDX_FOR_CORE_TYPE(${CORE_TYPE} CORE_IDX)
list(GET ALL_${ELEMENT_TYPE}_${LIST_TYPE} ${CORE_IDX} CORE_X_LIST)
string(REPLACE " " "" CORE_X_LIST ${CORE_X_LIST})
if("${CORE_X_LIST}" STREQUAL "")
set(CORE_X_LIST "${ITEM}")
else()
set(CORE_X_LIST "${CORE_X_LIST},${ITEM}")
endif()
list(REMOVE_AT ALL_${ELEMENT_TYPE}_${LIST_TYPE} ${CORE_IDX})
list(INSERT ALL_${ELEMENT_TYPE}_${LIST_TYPE} ${CORE_IDX} ${CORE_X_LIST})
endmacro()
macro(CORE_CONTAINS_ANY_PLATFORM TYPE CORE_TYPE OUT_FLAG)
FIND_IDX_FOR_CORE_TYPE(${CORE_TYPE} CORE_IDX)
GET_LIST_FOR_CORE_TYPE("PLATFORMS" ${TYPE} ${CORE_IDX} CORE_X_PLATFORMS)
set(${OUT_FLAG} FALSE)
foreach(PLATFORM_IT ${CORE_X_PLATFORMS})
if(NOT ("${PLATFORM_IT}" STREQUAL " "))
set(${OUT_FLAG} TRUE)
endif()
endforeach()
endmacro()
macro(CORE_CONTAINS_PLATFORM TYPE CORE_TYPE PLATFORM_TYPE OUT_FLAG)
FIND_IDX_FOR_CORE_TYPE("${CORE_TYPE}" CORE_IDX)
GET_LIST_FOR_CORE_TYPE("PLATFORMS" "${TYPE}" ${CORE_IDX} CORE_X_PLATFORMS)
set(${OUT_FLAG} FALSE)
foreach(PLATFORM_IT ${CORE_X_PLATFORMS})
if("${PLATFORM_IT}" STREQUAL "${PLATFORM_TYPE}")
set(${OUT_FLAG} TRUE)
endif()
endforeach()
endmacro()
macro(INIT_PRODUCTS_LIST TYPE)
list(APPEND ALL_${TYPE}_PRODUCT_FAMILY " ")
list(APPEND ALL_${TYPE}_PRODUCT_TO_PRODUCT_FAMILY " ")
endmacro()
macro(ADD_PRODUCT TYPE PRODUCT ITEM)
list(APPEND ALL_${TYPE}_PRODUCT_FAMILY ${ITEM})
list(APPEND ALL_${TYPE}_PRODUCT_TO_PRODUCT_FAMILY ${PRODUCT})
endmacro()
macro(GET_AVAILABLE_PRODUCTS TYPE PRODUCT_FAMILY_LIST DEFAULT_PRODUCT_FAMILY)
list(REMOVE_ITEM ALL_${TYPE}_PRODUCT_FAMILY " ")
list(REMOVE_ITEM ALL_${TYPE}_PRODUCT_TO_PRODUCT_FAMILY " ")
set(${PRODUCT_FAMILY_LIST} ${ALL_${TYPE}_PRODUCT_FAMILY})
set(${DEFAULT_PRODUCT_FAMILY})
if(NOT "${DEFAULT_${TYPE}_PLATFORM}" STREQUAL "")
list(FIND ALL_${TYPE}_PRODUCT_TO_PRODUCT_FAMILY ${DEFAULT_${TYPE}_PLATFORM} INDEX)
if(${INDEX} EQUAL -1)
message(FATAL_ERROR "${DEFAULT_${TYPE}_PLATFORM} not found in product families.")
endif()
list(GET ALL_${TYPE}_PRODUCT_FAMILY ${INDEX} DEFAULT)
set(${DEFAULT_PRODUCT_FAMILY} ${DEFAULT})
endif()
endmacro()
macro(GET_AVAILABLE_PLATFORMS TYPE FLAG_NAME OUT_STR)
set(${TYPE}_PLATFORM_LIST)
set(${TYPE}_CORE_FLAGS_DEFINITONS)
if(NOT DEFAULT_${TYPE}_PLATFORM AND DEFINED PREFERRED_PLATFORM AND ${FLAG_NAME}_${PREFERRED_PLATFORM})
set(DEFAULT_${TYPE}_PLATFORM ${PREFERRED_PLATFORM})
endif()
foreach(CORE_TYPE ${ALL_CORE_TYPES_REVERSED})
set(COREX_HAS_PLATFORMS FALSE)
CORE_CONTAINS_ANY_PLATFORM("${TYPE}" ${CORE_TYPE} COREX_HAS_PLATFORMS)
if(${COREX_HAS_PLATFORMS})
FIND_IDX_FOR_CORE_TYPE(${CORE_TYPE} CORE_IDX)
list(APPEND ${TYPE}_CORE_FLAGS_DEFINITONS ${FLAG_NAME}_${CORE_TYPE})
GET_LIST_FOR_CORE_TYPE("PLATFORMS" ${TYPE} ${CORE_IDX} ${TYPE}_COREX_PLATFORMS)
list(APPEND ${TYPE}_PLATFORM_LIST ${${TYPE}_COREX_PLATFORMS})
if(NOT DEFAULT_${TYPE}_PLATFORM)
list(GET ${TYPE}_PLATFORM_LIST 0 DEFAULT_${TYPE}_PLATFORM ${PLATFORM_IT})
endif()
if(NOT DEFAULT_${TYPE}_${CORE_TYPE}_PLATFORM)
list(GET ${TYPE}_COREX_PLATFORMS 0 DEFAULT_${TYPE}_${CORE_TYPE}_PLATFORM)
endif()
endif()
endforeach()
foreach(PLATFORM_IT ${${TYPE}_PLATFORM_LIST})
set(${OUT_STR} "${${OUT_STR}} ${PLATFORM_IT}")
list(APPEND ${TYPE}_CORE_FLAGS_DEFINITONS ${FLAG_NAME}_${PLATFORM_IT})
endforeach()
endmacro()
macro(GET_PLATFORMS_FOR_CORE_TYPE TYPE CORE_TYPE OUT_LIST)
FIND_IDX_FOR_CORE_TYPE(${CORE_TYPE} CORE_IDX)
GET_LIST_FOR_CORE_TYPE("PLATFORMS" ${TYPE} ${CORE_IDX} ${OUT_LIST})
endmacro()
# default flag for CoreX devices support
set(SUPPORT_GEN_DEFAULT TRUE CACHE BOOL "default value for SUPPORT_COREx")
# default flag for platform support
set(SUPPORT_PLATFORM_DEFAULT TRUE CACHE BOOL "default value for support platform")
# Define the hardware configurations we support and test
macro(SET_FLAGS_FOR CORE_TYPE)
foreach(SKU_NAME ${ARGN})
if(SUPPORT_${SKU_NAME})
if(NOT SUPPORT_${CORE_TYPE})
message(STATUS "Auto-Enabling ${CORE_TYPE} support for ${SKU_NAME}")
set(SUPPORT_${CORE_TYPE} TRUE CACHE BOOL "Support ${CORE_TYPE} devices" FORCE)
endif()
endif()
if(TESTS_${SKU_NAME})
if(NOT TESTS_${CORE_TYPE})
message(STATUS "Auto-Enabling ${CORE_TYPE} tests for ${SKU_NAME}")
set(TESTS_${CORE_TYPE} TRUE CACHE BOOL "Build ULTs for ${CORE_TYPE} devices" FORCE)
endif()
endif()
string(TOLOWER ${CORE_TYPE} MAP_${SKU_NAME}_CORE_lower)
string(TOLOWER ${SKU_NAME} MAP_${SKU_NAME}_lower)
set(MAP_${SKU_NAME}_CORE_lower "${CORE_PREFIX}${MAP_${SKU_NAME}_CORE_lower}${CORE_SUFFIX}" CACHE STRING "Core name for SKU" FORCE)
set(MAP_${SKU_NAME}_lower ${MAP_${SKU_NAME}_lower} CACHE STRING "SKU in lower case" FORCE)
endforeach()
set(SUPPORT_${CORE_TYPE} ${SUPPORT_GEN_DEFAULT} CACHE BOOL "Support ${CORE_TYPE} devices")
set(TESTS_${CORE_TYPE} ${SUPPORT_${CORE_TYPE}} CACHE BOOL "Build ULTs for ${CORE_TYPE} devices")
if(NOT SUPPORT_${CORE_TYPE} OR NEO_SKIP_UNIT_TESTS)
set(TESTS_${CORE_TYPE} FALSE)
endif()
if(SUPPORT_${CORE_TYPE})
list(APPEND ALL_SUPPORTED_CORE_FAMILIES ${CORE_TYPE})
list(REMOVE_DUPLICATES ALL_SUPPORTED_CORE_FAMILIES)
foreach(${CORE_TYPE}_PLATFORM ${ARGN})
set(SUPPORT_${${CORE_TYPE}_PLATFORM} ${SUPPORT_PLATFORM_DEFAULT} CACHE BOOL "Support ${${CORE_TYPE}_PLATFORM}")
if(TESTS_${CORE_TYPE})
set(TESTS_${${CORE_TYPE}_PLATFORM} ${SUPPORT_${${CORE_TYPE}_PLATFORM}} CACHE BOOL "Build ULTs for ${${CORE_TYPE}_PLATFORM}")
endif()
if(NOT SUPPORT_${${CORE_TYPE}_PLATFORM} OR NOT TESTS_${CORE_TYPE} OR NEO_SKIP_UNIT_TESTS)
set(TESTS_${${CORE_TYPE}_PLATFORM} FALSE)
endif()
endforeach()
endif()
if(TESTS_${CORE_TYPE})
list(APPEND ALL_TESTED_CORE_FAMILIES ${CORE_TYPE})
list(REMOVE_DUPLICATES ALL_TESTED_CORE_FAMILIES)
endif()
endmacro()
macro(DISABLE_FLAGS_FOR CORE_TYPE)
set(SUPPORT_${CORE_TYPE} FALSE CACHE BOOL "Support ${CORE_TYPE} devices" FORCE)
set(TESTS_${CORE_TYPE} FALSE CACHE BOOL "Build ULTs for ${CORE_TYPE} devices" FORCE)
foreach(SKU_NAME ${ARGN})
set(SUPPORT_${SKU_NAME} FALSE CACHE BOOL "Support ${SKU_NAME}" FORCE)
set(TESTS_${SKU_NAME} FALSE CACHE BOOL "Build ULTs for ${SKU_NAME}" FORCE)
endforeach()
endmacro()
macro(DISABLE_32BIT_FLAGS_FOR CORE_TYPE)
DISABLE_FLAGS_FOR(${CORE_TYPE} ${ARGN})
endmacro()
macro(DISABLE_WDDM_LINUX_FOR CORE_TYPE)
if(SUPPORT_${CORE_TYPE})
foreach(SKU_NAME ${ARGN})
if(SUPPORT_${SKU_NAME})
list(APPEND PLATFORMS_TO_HAVE_WDDM_DISABLED ${SKU_NAME})
list(REMOVE_DUPLICATES PLATFORMS_TO_HAVE_WDDM_DISABLED)
endif()
endforeach()
endif()
endmacro()
macro(ADD_PLATFORM_FOR_CORE_TYPE LIST_TYPE CORE_TYPE PLATFORM_NAME)
ADD_ITEM_FOR_CORE_TYPE("PLATFORMS" ${LIST_TYPE} ${CORE_TYPE} ${PLATFORM_NAME})
set(${CORE_TYPE}_HAS_${PLATFORM_NAME} TRUE)
if(NOT DEFAULT_${LIST_TYPE}_${CORE_TYPE}_${PLATFORM_NAME}_PLATFORM)
string(TOLOWER ${PLATFORM_NAME} DEFAULT_${LIST_TYPE}_${CORE_TYPE}_${PLATFORM_NAME}_PLATFORM)
endif()
endmacro()
macro(ENABLE_ADDITIONAL_SKU SKU_NAME)
set(SUPPORT_${SKU_NAME} TRUE CACHE BOOL "Support ${SKU_NAME}" FORCE)
endmacro()
macro(TEST_ADDITIONAL_SKU SKU_NAME)
set(TESTS_${SKU_NAME} TRUE CACHE BOOL "Build ULTs for ${SKU_NAME}" FORCE)
endmacro()
macro(ADD_AOT_DEFINITION CONFIG_NAME)
list(APPEND AOT_DEFINITIONS "SUPPORT_AOT_${CONFIG_NAME}")
endmacro()
macro(SET_FLAGS_FOR_LEGACY CORE_TYPE)
if(NEO_LEGACY_PLATFORMS_SUPPORT)
SET_FLAGS_FOR(${CORE_TYPE} ${ARGN})
else()
DISABLE_FLAGS_FOR(${CORE_TYPE} ${ARGN})
endif()
endmacro()
macro(SET_FLAGS_FOR_CURRENT CORE_TYPE)
if(NEO_CURRENT_PLATFORMS_SUPPORT)
SET_FLAGS_FOR(${CORE_TYPE} ${ARGN})
else()
DISABLE_FLAGS_FOR(${CORE_TYPE} ${ARGN})
endif()
endmacro()
# Init lists
INIT_LIST("FAMILY_NAME" "TESTED")
INIT_LIST("PLATFORMS" "SUPPORTED")
INIT_LIST("PLATFORMS" "SUPPORTED_IMAGES")
INIT_LIST("PLATFORMS" "SUPPORTED_AUX_TRANSLATION")
INIT_LIST("PLATFORMS" "TESTED")
INIT_LIST("PLATFORMS" "SUPPORTED_HEAPLESS")
INIT_LIST("PLATFORMS" "SUPPORTED_STATELESS")
INIT_PRODUCTS_LIST("TESTED")
INIT_PRODUCTS_LIST("SUPPORTED")
set(AOT_DEFINITIONS)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake${BRANCH_DIR_SUFFIX}setup_platform_flags.cmake)
# Get platform lists, flag definition and set default platforms
GET_AVAILABLE_PLATFORMS("SUPPORTED" "SUPPORT" ALL_AVAILABLE_SUPPORTED_PLATFORMS)
GET_AVAILABLE_PLATFORMS("TESTED" "TESTS" ALL_AVAILABLE_TESTED_PLATFORMS)
GET_AVAILABLE_PRODUCTS("TESTED" ALL_PRODUCT_FAMILY_LIST DEFAULT_TESTED_PRODUCT_FAMILY)
GET_AVAILABLE_PRODUCTS("SUPPORTED" ALL_PRODUCT_FAMILY_LIST DEFAULT_SUPPORTED_PRODUCT_FAMILY)
# Output platforms
message(STATUS "All supported platforms: ${ALL_AVAILABLE_SUPPORTED_PLATFORMS}")
message(STATUS "All tested platforms: ${ALL_AVAILABLE_TESTED_PLATFORMS}")
message(STATUS "Default supported platform: ${DEFAULT_SUPPORTED_PLATFORM}")
message(STATUS "Default tested platform: ${DEFAULT_TESTED_PLATFORM}")
# Output families
message(STATUS "All supported core families: ${ALL_SUPPORTED_CORE_FAMILIES}")
message(STATUS "All tested core families: ${ALL_TESTED_CORE_FAMILIES}")
list(FIND SUPPORTED_PLATFORM_LIST ${DEFAULT_SUPPORTED_PLATFORM} VALID_DEFAULT_SUPPORTED_PLATFORM)
if(VALID_DEFAULT_SUPPORTED_PLATFORM LESS 0)
message(FATAL_ERROR "Not a valid supported platform: ${DEFAULT_SUPPORTED_PLATFORM}")
endif()
if(DEFAULT_TESTED_PLATFORM)
list(FIND TESTED_PLATFORM_LIST ${DEFAULT_TESTED_PLATFORM} VALID_DEFAULT_TESTED_PLATFORM)
if(VALID_DEFAULT_TESTED_PLATFORM LESS 0)
message(FATAL_ERROR "Not a valid tested platform: ${DEFAULT_TESTED_PLATFORM}")
endif()
else()
set(NEO_SKIP_UNIT_TESTS TRUE)
endif()
if(NOT DEFAULT_TESTED_FAMILY_NAME)
if(DEFINED PREFERRED_FAMILY_NAME)
list(FIND ALL_TESTED_FAMILY_NAME ${PREFERRED_FAMILY_NAME} CORE_IDX)
if(${CORE_IDX} GREATER -1)
set(DEFAULT_TESTED_FAMILY_NAME ${PREFERRED_FAMILY_NAME})
endif()
endif()
if(NOT DEFINED DEFAULT_TESTED_FAMILY_NAME)
foreach(CORE_TYPE ${ALL_CORE_TYPES_REVERSED})
FIND_IDX_FOR_CORE_TYPE(${CORE_TYPE} CORE_IDX)
list(GET ALL_TESTED_FAMILY_NAME ${CORE_IDX} CORE_FAMILY_NAME)
if(NOT CORE_FAMILY_NAME STREQUAL " ")
set(DEFAULT_TESTED_FAMILY_NAME ${CORE_FAMILY_NAME})
break()
endif()
endforeach()
endif()
endif()
message(STATUS "Default tested family name: ${DEFAULT_TESTED_FAMILY_NAME}")