Skip to content

Commit 5bf5442

Browse files
authored
[SYCL] Replace CUDA & HIP features.hpp headers with macros (#14667)
Split out from #14145 this patch replaces the generated `features.hpp` header for the CUDA and HIP plugins, which only defined single feature test macro, with `#cmakedefine01` definitions controlled by the build system.
1 parent bd97280 commit 5bf5442

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

sycl/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,21 @@ option(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB "Enable build of the SYCL major rel
157157

158158
# Needed for feature_test.hpp
159159
if ("cuda" IN_LIST SYCL_ENABLE_PLUGINS)
160-
set(SYCL_BUILD_PI_CUDA ON)
160+
set(SYCL_BUILD_BACKEND_CUDA ON)
161+
set(SYCL_EXT_ONEAPI_BACKEND_CUDA ON)
161162
endif()
162163
if ("hip" IN_LIST SYCL_ENABLE_PLUGINS)
163-
set(SYCL_BUILD_PI_HIP ON)
164+
set(SYCL_BUILD_BACKEND_HIP ON)
165+
set(SYCL_EXT_ONEAPI_BACKEND_HIP ON)
164166
endif()
165167
if ("opencl" IN_LIST SYCL_ENABLE_PLUGINS)
166-
set(SYCL_BUILD_PI_OPENCL ON)
168+
set(SYCL_BUILD_BACKEND_OPENCL ON)
167169
endif()
168170
if ("level_zero" IN_LIST SYCL_ENABLE_PLUGINS)
169-
set(SYCL_BUILD_PI_LEVEL_ZERO ON)
171+
set(SYCL_BUILD_BACKENDLEVEL_ZERO ON)
170172
endif()
171173
if ("native_cpu" IN_LIST SYCL_ENABLE_PLUGINS)
172-
set(SYCL_BUILD_NATIVE_CPU ON)
174+
set(SYCL_BUILD_BACKEND_NATIVE_CPU ON)
173175
endif()
174176

175177
# Configure SYCL version macro

sycl/source/feature_test.hpp.in

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,8 @@ inline namespace _V1 {
116116
#define __has_include(x) 0
117117
#endif
118118

119-
#if __has_include("detail/plugins/cuda/features.hpp")
120-
#include "detail/plugins/cuda/features.hpp"
121-
#endif
122-
123-
#if __has_include("detail/plugins/hip/features.hpp")
124-
#include "detail/plugins/hip/features.hpp"
125-
#endif
119+
#cmakedefine01 SYCL_EXT_ONEAPI_BACKEND_CUDA
120+
#cmakedefine01 SYCL_EXT_ONEAPI_BACKEND_HIP
126121

127122
} // namespace _V1
128123
} // namespace sycl

sycl/test/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ add_lit_testsuite(check-sycl-deploy "Running the SYCL regression tests"
5858
set_target_properties(check-sycl-deploy PROPERTIES FOLDER "SYCL tests")
5959

6060
set(TRIPLES "spir64-unknown-unknown")
61-
if (SYCL_BUILD_PI_CUDA OR (SYCL_BUILD_PI_HIP AND "${SYCL_BUILD_PI_HIP_PLATFORM}" STREQUAL "NVIDIA"))
61+
if (SYCL_BUILD_BACKEND_CUDA OR (SYCL_BUILD_BACKEND_HIP AND "${SYCL_BUILD_PI_HIP_PLATFORM}" STREQUAL "NVIDIA"))
6262
set(TRIPLES "${TRIPLES},nvptx64-nvidia-cuda")
6363
endif()
64-
if ((SYCL_BUILD_PI_HIP AND "${SYCL_BUILD_PI_HIP_PLATFORM}" STREQUAL "AMD"))
64+
if ((SYCL_BUILD_BACKEND_HIP AND "${SYCL_BUILD_PI_HIP_PLATFORM}" STREQUAL "AMD"))
6565
set(TRIPLES "${TRIPLES},amdgcn-amd-amdhsa")
6666
endif()
6767

@@ -94,7 +94,7 @@ add_lit_testsuite(check-sycl-dumps "Running ABI dump tests only"
9494
EXCLUDE_FROM_CHECK_ALL
9595
)
9696

97-
if(SYCL_BUILD_PI_CUDA)
97+
if(SYCL_BUILD_BACKEND_CUDA)
9898
add_lit_testsuite(check-sycl-ptx "Running device-agnostic SYCL regression tests for NVidia PTX"
9999
${CMAKE_CURRENT_BINARY_DIR}
100100
ARGS ${RT_TEST_ARGS}
@@ -108,7 +108,7 @@ if(SYCL_BUILD_PI_CUDA)
108108
add_dependencies(check-sycl-cuda check-sycl-ptx)
109109
endif()
110110

111-
if(SYCL_BUILD_PI_HIP)
111+
if(SYCL_BUILD_BACKEND_HIP)
112112
add_custom_target(check-sycl-hip)
113113
if("${SYCL_BUILD_PI_HIP_PLATFORM}" STREQUAL "NVIDIA")
114114
add_lit_testsuite(check-sycl-hip-ptx "Running device-agnostic SYCL regression tests for HIP NVidia PTX"

sycl/test/lit.site.cfg.py.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ config.llvm_enable_projects = "@LLVM_ENABLE_PROJECTS@"
2626
config.sycl_threads_lib = '@SYCL_THREADS_LIB@'
2727
config.sycl_use_libcxx = '@SYCL_USE_LIBCXX@'
2828
config.extra_environment = lit_config.params.get("extra_environment", "@LIT_EXTRA_ENVIRONMENT@")
29-
config.cuda = '@SYCL_BUILD_PI_CUDA@'
30-
config.hip = '@SYCL_BUILD_PI_HIP@'
31-
config.opencl = '@SYCL_BUILD_PI_OPENCL@'
32-
config.level_zero = '@SYCL_BUILD_PI_LEVEL_ZERO@'
33-
config.native_cpu = '@SYCL_BUILD_NATIVE_CPU@'
29+
config.cuda = '@SYCL_BUILD_BACKEND_CUDA@'
30+
config.hip = '@SYCL_BUILD_BACKEND_HIP@'
31+
config.opencl = '@SYCL_BUILD_BACKEND_OPENCL@'
32+
config.level_zero = '@SYCL_BUILD_BACKEND_LEVEL_ZERO@'
33+
config.native_cpu = '@SYCL_BUILD_BACKEND_NATIVE_CPU@'
3434
config.native_cpu_ock = '@NATIVECPU_USE_OCK@'
3535
config.sycl_preview_lib_enabled = '@SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB@'
3636

sycl/tools/sycl-trace/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ target_include_directories(sycl_pi_trace_collector PRIVATE
9797

9898
add_dependencies(sycl_pi_trace_collector pi-pretty-printers)
9999

100-
if(SYCL_BUILD_PI_CUDA)
100+
if(SYCL_BUILD_BACKEND_CUDA)
101101

102102
find_package(CUDA 10.1 REQUIRED)
103103

104104
target_compile_definitions(cuda_trace_collector
105105
PRIVATE
106-
$<$<BOOL:${SYCL_BUILD_PI_CUDA}>:USE_PI_CUDA>
106+
$<$<BOOL:${SYCL_BUILD_BACKEND_CUDA}>:USE_PI_CUDA>
107107
)
108108

109109
# The following two if's can be removed when FindCUDA -> FindCUDAToolkit.
@@ -157,7 +157,7 @@ if(SYCL_BUILD_PI_CUDA)
157157
target_link_libraries(cuda_trace_collector PRIVATE xptifw)
158158
target_compile_definitions(sycl_pi_trace_collector
159159
PRIVATE
160-
$<$<BOOL:${SYCL_BUILD_PI_CUDA}>:USE_PI_CUDA>
160+
$<$<BOOL:${SYCL_BUILD_BACKEND_CUDA}>:USE_PI_CUDA>
161161
)
162162
endif()
163163

0 commit comments

Comments
 (0)