Skip to content

Commit 2002dc0

Browse files
[SYCL] Fix test configurations when L0 and OpenCL are disabled (#8247)
This commit changes the configuration of in-tree SYCL LIT tests to include features for when the L0 and OpenCL plugins are enabled. This allows the interop backend tests to be split into backend-dependent tests to be run only when their backends are enabled. Additionally, this commit changes the fsycl-host-only LIT configuration replacement to ignore unset include paths, avoiding empty "-isystem" options when related backends are disabled. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 00ae1e7 commit 2002dc0

8 files changed

+127
-88
lines changed

sycl/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ endif()
162162
if ("esimd_emulator" IN_LIST SYCL_ENABLE_PLUGINS)
163163
set(SYCL_BUILD_PI_ESIMD_EMULATOR ON)
164164
endif()
165+
if ("opencl" IN_LIST SYCL_ENABLE_PLUGINS)
166+
set(SYCL_BUILD_PI_OPENCL ON)
167+
endif()
168+
if ("level_zero" IN_LIST SYCL_ENABLE_PLUGINS)
169+
set(SYCL_BUILD_PI_LEVEL_ZERO ON)
170+
endif()
165171

166172
# Configure SYCL version macro
167173
set(sycl_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// REQUIRES: cuda_be
2+
// RUN: %clangxx -fsycl -fsyntax-only %s
3+
// RUN: %clangxx -fsycl -fsyntax-only -DUSE_CUDA_EXPERIMENTAL %s
4+
5+
#ifdef USE_CUDA_EXPERIMENTAL
6+
#define SYCL_EXT_ONEAPI_BACKEND_CUDA 1
7+
#define SYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL 1
8+
#include <sycl/ext/oneapi/experimental/backend/cuda.hpp>
9+
#endif
10+
11+
#include <sycl/sycl.hpp>
12+
13+
constexpr auto Backend = sycl::backend::ext_oneapi_cuda;
14+
15+
int main() {
16+
static_assert(
17+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::device>,
18+
sycl::detail::interop<Backend, sycl::device>::type>);
19+
#ifndef USE_CUDA_EXPERIMENTAL
20+
// CUDA experimental return type is different to input type
21+
static_assert(
22+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::context>,
23+
sycl::detail::interop<Backend, sycl::context>::type>);
24+
#endif
25+
static_assert(
26+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::queue>,
27+
sycl::detail::interop<Backend, sycl::queue>::type>);
28+
29+
return 0;
30+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// REQUIRES: hip_be
2+
// RUN: %clangxx -fsycl -fsyntax-only %s
3+
4+
#include <sycl/sycl.hpp>
5+
6+
constexpr auto Backend = sycl::backend::ext_oneapi_hip;
7+
8+
int main() {
9+
static_assert(
10+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::device>,
11+
sycl::detail::interop<Backend, sycl::device>::type>);
12+
static_assert(
13+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::queue>,
14+
sycl::detail::interop<Backend, sycl::queue>::type>);
15+
16+
return 0;
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// REQUIRES: level_zero_be
2+
// RUN: %clangxx %fsycl-host-only -fsyntax-only %s
3+
4+
#include <sycl/sycl.hpp>
5+
#include <ze_api.h>
6+
7+
constexpr auto Backend = sycl::backend::ext_oneapi_level_zero;
8+
9+
int main() {
10+
static_assert(
11+
std::is_same_v<sycl::backend_traits<Backend>::input_type<sycl::platform>,
12+
sycl::detail::interop<Backend, sycl::platform>::type>);
13+
static_assert(
14+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::platform>,
15+
sycl::detail::interop<Backend, sycl::platform>::type>);
16+
static_assert(
17+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::device>,
18+
sycl::detail::interop<Backend, sycl::device>::type>);
19+
static_assert(
20+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::queue>,
21+
sycl::detail::interop<Backend, sycl::queue>::type>);
22+
23+
return 0;
24+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// REQUIRES: opencl_be
2+
// RUN: %clangxx -fsycl -fsyntax-only %s
3+
4+
#include <CL/cl.h>
5+
#include <sycl/sycl.hpp>
6+
7+
constexpr auto Backend = sycl::backend::opencl;
8+
9+
int main() {
10+
static_assert(
11+
std::is_same_v<sycl::backend_traits<Backend>::input_type<sycl::device>,
12+
sycl::detail::interop<Backend, sycl::device>::type>);
13+
static_assert(
14+
std::is_same_v<sycl::backend_traits<Backend>::input_type<sycl::context>,
15+
sycl::detail::interop<Backend, sycl::context>::type>);
16+
static_assert(
17+
std::is_same_v<sycl::backend_traits<Backend>::input_type<sycl::queue>,
18+
sycl::detail::interop<Backend, sycl::queue>::type>);
19+
static_assert(
20+
std::is_same_v<sycl::backend_traits<Backend>::input_type<sycl::event>,
21+
sycl::detail::interop<Backend, sycl::event>::type>);
22+
static_assert(
23+
std::is_same_v<sycl::backend_traits<Backend>::input_type<sycl::platform>,
24+
sycl::detail::interop<Backend, sycl::platform>::type>);
25+
static_assert(
26+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::platform>,
27+
sycl::detail::interop<Backend, sycl::platform>::type>);
28+
static_assert(
29+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::device>,
30+
sycl::detail::interop<Backend, sycl::device>::type>);
31+
static_assert(
32+
std::is_same_v<sycl::backend_traits<Backend>::return_type<sycl::queue>,
33+
sycl::detail::interop<Backend, sycl::queue>::type>);
34+
35+
return 0;
36+
}

sycl/test/basic_tests/interop-backend-traits.cpp

Lines changed: 0 additions & 87 deletions
This file was deleted.

sycl/test/lit.cfg.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@
9696
llvm_symbolizer = os.path.join(config.llvm_build_bin_dir, 'llvm-symbolizer')
9797
llvm_config.with_environment('LLVM_SYMBOLIZER_PATH', llvm_symbolizer)
9898

99-
config.substitutions.append( ('%fsycl-host-only', '-std=c++17 -Xclang -fsycl-is-host -isystem %s -isystem %s -isystem %s -isystem %s' % (config.sycl_include, config.level_zero_include_dir, config.opencl_include_dir, config.sycl_include + '/sycl/') ) )
99+
sycl_host_only_options = '-std=c++17 -Xclang -fsycl-is-host'
100+
for include_dir in [config.sycl_include, config.level_zero_include_dir, config.opencl_include_dir, config.sycl_include + '/sycl/']:
101+
if include_dir:
102+
sycl_host_only_options += ' -isystem %s' % include_dir
103+
config.substitutions.append( ('%fsycl-host-only', sycl_host_only_options) )
104+
100105
config.substitutions.append( ('%sycl_lib', ' -lsycl6' if platform.system() == "Windows" else '-lsycl') )
101106

102107
llvm_config.add_tool_substitutions(['llvm-spirv'], [config.sycl_tools_dir])
@@ -116,6 +121,12 @@
116121
if config.esimd_emulator_be == "ON":
117122
config.available_features.add('esimd_emulator_be')
118123

124+
if config.opencl_be == "ON":
125+
config.available_features.add('opencl_be')
126+
127+
if config.level_zero_be == "ON":
128+
config.available_features.add('level_zero_be')
129+
119130
if triple == 'nvptx64-nvidia-cuda':
120131
llvm_config.with_system_environment('CUDA_PATH')
121132
config.available_features.add('cuda')

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ config.extra_environment = lit_config.params.get("extra_environment", "@LIT_EXTR
2828
config.cuda_be = '@SYCL_BUILD_PI_CUDA@'
2929
config.esimd_emulator_be = '@SYCL_BUILD_PI_ESIMD_EMULATOR@'
3030
config.hip_be = '@SYCL_BUILD_PI_HIP@'
31+
config.opencl_be = '@SYCL_BUILD_PI_OPENCL@'
32+
config.level_zero_be = '@SYCL_BUILD_PI_LEVEL_ZERO@'
3133

3234
import lit.llvm
3335
lit.llvm.initialize(lit_config, config)

0 commit comments

Comments
 (0)