Skip to content

Commit 0b8bba8

Browse files
authored
[SYCL][CUDA][HIP] Define backend macros based on compiler (#15012)
Currently the backend macros are only defined when the runtime adapters for the given backend are built. It's more accurate to use whether or not the compiler can target these backends, regardless of whether the runtime elements are present. It should be possible to compile an application for a backend without having to install the matching runtime.
1 parent 960b1ca commit 0b8bba8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sycl/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,9 @@ option(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB "Enable build of the SYCL major rel
169169
# Needed for feature_test.hpp
170170
if ("cuda" IN_LIST SYCL_ENABLE_PLUGINS)
171171
set(SYCL_BUILD_BACKEND_CUDA ON)
172-
set(SYCL_EXT_ONEAPI_BACKEND_CUDA ON)
173172
endif()
174173
if ("hip" IN_LIST SYCL_ENABLE_PLUGINS)
175174
set(SYCL_BUILD_BACKEND_HIP ON)
176-
set(SYCL_EXT_ONEAPI_BACKEND_HIP ON)
177175
endif()
178176
if ("opencl" IN_LIST SYCL_ENABLE_PLUGINS)
179177
set(SYCL_BUILD_BACKEND_OPENCL ON)
@@ -185,6 +183,11 @@ if ("native_cpu" IN_LIST SYCL_ENABLE_PLUGINS)
185183
set(SYCL_BUILD_BACKEND_NATIVE_CPU ON)
186184
endif()
187185

186+
# Set backend macros based on whether we can compile kernels for the target
187+
# rather than if we're building the runtime adapter.
188+
set(SYCL_EXT_ONEAPI_BACKEND_CUDA ${LLVM_HAS_NVPTX_TARGET})
189+
set(SYCL_EXT_ONEAPI_BACKEND_HIP ${LLVM_HAS_AMDGPU_TARGET})
190+
188191
# Configure SYCL version macro
189192
set(sycl_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
190193
set(sycl_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/source)

0 commit comments

Comments
 (0)