Skip to content

Commit 74809e4

Browse files
authored
[SYCL] Revise SYCL Cmake config for LIT tests (#3034)
1. Aligned CMake target configuration SYCL LIT test location. 2. Added support for running on-device LIT tests for prebuilt SYCL compiler and runtime binaries following the [instructions](https://github.com/intel/llvm/blob/sycl/sycl/test/on-device/README.md). 3. Removed obsolete dependencies from the build 4. Added Level_Zero headers support to LIT infra to support online_compiler/online_compiler_L0.cpp test 5. add LEVEL_ZERO_INCLUDE_DIR to global scope to be used in tests;
1 parent 8208427 commit 74809e4

File tree

7 files changed

+118
-58
lines changed

7 files changed

+118
-58
lines changed

sycl/plugins/level_zero/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR)
5555
COMPONENT level-zero-loader
5656
)
5757

58-
set(LEVEL_ZERO_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/level_zero_loader_install/include/)
58+
set(LEVEL_ZERO_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/level_zero_loader_install/include/
59+
CACHE INTERNAL "Path containing Level_Zero header files.")
5960
else()
6061
file(GLOB LEVEL_ZERO_LIBRARY_SRC "${LEVEL_ZERO_LIBRARY}*")
6162
get_filename_component(LEVEL_ZERO_LIB_NAME ${LEVEL_ZERO_LIBRARY} NAME)

sycl/test/CMakeLists.txt

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ configure_lit_site_cfg(
2020
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
2121
)
2222

23-
configure_lit_site_cfg(
24-
${CMAKE_CURRENT_SOURCE_DIR}/on-device/lit.site.cfg.py.in
25-
${CMAKE_CURRENT_BINARY_DIR}/on-device/lit.site.cfg.py
26-
MAIN_CONFIG
27-
${CMAKE_CURRENT_SOURCE_DIR}/on-device/lit.cfg.py
28-
)
29-
3023
configure_lit_site_cfg(
3124
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
3225
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
@@ -58,58 +51,19 @@ add_lit_testsuite(check-sycl-deploy "Running the SYCL regression tests"
5851
)
5952
set_target_properties(check-sycl-deploy PROPERTIES FOLDER "SYCL tests")
6053

61-
add_lit_testsuites(SYCL ${CMAKE_CURRENT_SOURCE_DIR}
62-
DEPENDS ${SYCL_TEST_DEPS}
63-
EXCLUDE_FROM_CHECK_ALL
64-
)
65-
66-
add_lit_testsuites(SYCL-DEPLOY ${CMAKE_CURRENT_SOURCE_DIR}
67-
ARGS ${DEPLOY_RT_TEST_ARGS}
68-
PARAMS "SYCL_PLUGIN=opencl"
69-
DEPENDS ${SYCL_DEPLOY_TEST_DEPS}
70-
EXCLUDE_FROM_CHECK_ALL
71-
)
72-
73-
add_lit_testsuite(check-sycl-opencl "Running the SYCL regression tests for OpenCL"
74-
${CMAKE_CURRENT_BINARY_DIR}/on-device
75-
ARGS ${RT_TEST_ARGS}
76-
PARAMS "SYCL_PLUGIN=opencl"
77-
DEPENDS ${SYCL_TEST_DEPS}
78-
EXCLUDE_FROM_CHECK_ALL
79-
)
80-
set_target_properties(check-sycl-opencl PROPERTIES FOLDER "SYCL tests")
81-
82-
add_lit_testsuite(check-sycl-level-zero "Running the SYCL regression tests for Level Zero"
83-
${CMAKE_CURRENT_BINARY_DIR}/on-device
84-
ARGS ${RT_TEST_ARGS}
85-
PARAMS "SYCL_PLUGIN=level_zero"
86-
DEPENDS ${SYCL_TEST_DEPS}
87-
EXCLUDE_FROM_CHECK_ALL
88-
)
89-
9054
add_lit_testsuite(check-sycl-spirv "Running device-agnostic SYCL regression tests for SPIR-V"
9155
${CMAKE_CURRENT_BINARY_DIR}
9256
ARGS ${RT_TEST_ARGS}
9357
PARAMS "SYCL_TRIPLE=spir64-unknown-linux-sycldevice"
9458
DEPENDS ${SYCL_TEST_DEPS}
9559
EXCLUDE_FROM_CHECK_ALL
9660
)
97-
set_target_properties(check-sycl-level-zero PROPERTIES FOLDER "SYCL tests")
9861

9962
add_custom_target(check-sycl)
100-
add_dependencies(check-sycl check-sycl-opencl check-sycl-level-zero check-sycl-spirv)
63+
add_dependencies(check-sycl check-sycl-spirv)
10164
set_target_properties(check-sycl PROPERTIES FOLDER "SYCL tests")
10265

10366
if(SYCL_BUILD_PI_CUDA)
104-
add_lit_testsuite(check-sycl-cuda "Running the SYCL regression tests for CUDA"
105-
${CMAKE_CURRENT_BINARY_DIR}/on-device
106-
ARGS ${RT_TEST_ARGS}
107-
PARAMS "SYCL_PLUGIN=cuda"
108-
DEPENDS ${SYCL_TEST_DEPS}
109-
EXCLUDE_FROM_CHECK_ALL
110-
)
111-
set_target_properties(check-sycl-cuda PROPERTIES FOLDER "SYCL CUDA tests")
112-
11367
add_lit_testsuite(check-sycl-ptx "Running device-agnostic SYCL regression tests for NVidia PTX"
11468
${CMAKE_CURRENT_BINARY_DIR}
11569
ARGS ${RT_TEST_ARGS}
@@ -118,13 +72,9 @@ if(SYCL_BUILD_PI_CUDA)
11872
EXCLUDE_FROM_CHECK_ALL
11973
)
12074

75+
add_custom_target(check-sycl-cuda)
12176
add_dependencies(check-sycl-cuda check-sycl-ptx)
122-
12377
add_dependencies(check-sycl check-sycl-cuda)
12478

125-
add_lit_testsuites(SYCL-CUDA ${CMAKE_CURRENT_SOURCE_DIR}/on-device
126-
PARAMS "SYCL_PLUGIN=cuda"
127-
DEPENDS ${SYCL_TEST_DEPS}
128-
EXCLUDE_FROM_CHECK_ALL
129-
)
13079
endif()
80+
add_subdirectory(on-device)

sycl/test/on-device/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
configure_lit_site_cfg(
2+
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
3+
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
4+
MAIN_CONFIG
5+
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
6+
)
7+
8+
add_lit_testsuite(check-sycl-opencl "Running the SYCL regression tests for OpenCL"
9+
${CMAKE_CURRENT_BINARY_DIR}
10+
ARGS ${RT_TEST_ARGS}
11+
PARAMS "SYCL_PLUGIN=opencl"
12+
DEPENDS ${SYCL_TEST_DEPS}
13+
EXCLUDE_FROM_CHECK_ALL
14+
)
15+
set_target_properties(check-sycl-opencl PROPERTIES FOLDER "SYCL OpenCL device tests")
16+
17+
add_lit_testsuite(check-sycl-level-zero "Running the SYCL regression tests for Level Zero"
18+
${CMAKE_CURRENT_BINARY_DIR}
19+
ARGS ${RT_TEST_ARGS}
20+
PARAMS "SYCL_PLUGIN=level_zero"
21+
DEPENDS ${SYCL_TEST_DEPS}
22+
EXCLUDE_FROM_CHECK_ALL
23+
)
24+
set_target_properties(check-sycl-level-zero PROPERTIES FOLDER "SYCL Level_Zero device tests")
25+
26+
if( TARGET check-sycl)
27+
add_dependencies(check-sycl check-sycl-opencl check-sycl-level-zero)
28+
endif()
29+
30+
if(SYCL_BUILD_PI_CUDA)
31+
add_lit_testsuite(check-sycl-cuda-on-device "Running the SYCL regression tests for CUDA"
32+
${CMAKE_CURRENT_BINARY_DIR}
33+
ARGS ${RT_TEST_ARGS}
34+
PARAMS "SYCL_PLUGIN=cuda"
35+
DEPENDS ${SYCL_TEST_DEPS}
36+
EXCLUDE_FROM_CHECK_ALL
37+
)
38+
set_target_properties(check-sycl-cuda-on-device PROPERTIES FOLDER "SYCL CUDA device tests")
39+
if(TARGET check-sycl-cuda)
40+
add_dependencies(check-sycl-cuda check-sycl-cuda-on-device)
41+
endif()
42+
endif()

sycl/test/on-device/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,60 @@ It is developer responsibility to move the tests from this directory to
1111
[DPC++ E2E test suite](https://github.com/intel/llvm-test-suite/tree/intel/SYCL)
1212
or [KhronosGroup/SYCL-CTS](https://github.com/KhronosGroup/SYCL-CTS) once the
1313
feature is stabilized.
14+
15+
# Running tests on deployed DPC++ compiler and runtime
16+
The tests in this directory can be run on deployed DPC++ compiler and runtime.
17+
It is expected that get_device_count_by_type tool is prebuilt by the developer
18+
and tools with full path os provided as value for GET_DEVICE_TOOL LIT
19+
parameter.
20+
21+
```bash
22+
# clone llvm_project repo
23+
git clone https://github.com/intel/llvm sycl_lit
24+
cd sycl_lit
25+
export ROOT=`pwd`
26+
mkdir build
27+
cd build
28+
29+
# set extra environment
30+
export EXTCMPLRROOT=# path to deployed SYCL compiler and runtime
31+
export GET_DEVICE_TOOL=# Path to the get_device_count_by_type tool
32+
# The get_device_count_by_type tool should be built from sources [under](../../tools/get_device_count_by_type.cpp)
33+
export LEVEL_ZERO_INCLUDE_DIR=# Path to Level_Zero headers (optional)
34+
35+
# Configure project
36+
cmake -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_EXTERNAL_PROJECTS=sycl-test \
37+
-DLLVM_EXTERNAL_SYCL_TEST_SOURCE_DIR=$ROOT/sycl/test/on-device \
38+
-DSYCL_SOURCE_DIR=$ROOT/sycl -DOpenCL_LIBRARIES=$EXTCMPLRROOT/lib \
39+
$ROOT/llvm
40+
41+
# Build LIT tools
42+
make FileCheck
43+
44+
# Run tests for OpenCL BE
45+
python3 $ROOT/llvm/utils/lit/lit.py -v --param SYCL_PLUGIN=opencl \
46+
--param SYCL_TOOLS_DIR="$EXTCMPLRROOT/bin" \
47+
--param SYCL_INCLUDE="$EXTCMPLRROOT/include/sycl" \
48+
--param SYCL_LIBS_DIR="$EXTCMPLRROOT/lib" \
49+
--param GET_DEVICE_TOOL=$GET_DEVICE_TOOL \
50+
--param LEVEL_ZERO_INCLUDE_DIR=$L0_HEADER_PATH \
51+
tools/sycl-test/
52+
53+
# Run tests for Level_Zero BE
54+
python3 $ROOT/llvm/utils/lit/lit.py -v --param SYCL_PLUGIN=level_zero \
55+
--param SYCL_TOOLS_DIR="$EXTCMPLRROOT/bin" \
56+
--param SYCL_INCLUDE="$EXTCMPLRROOT/include/sycl" \
57+
--param SYCL_LIBS_DIR="$EXTCMPLRROOT/lib" \
58+
--param GET_DEVICE_TOOL=$GET_DEVICE_TOOL \
59+
--param LEVEL_ZERO_INCLUDE_DIR=$L0_HEADER_PATH \
60+
tools/sycl-test/
61+
62+
# Run tests for CUDA BE (if compiler build supports it)
63+
python3 $ROOT/llvm/utils/lit/lit.py -v --param SYCL_PLUGIN=cuda \
64+
--param SYCL_TOOLS_DIR="$EXTCMPLRROOT/bin" \
65+
--param SYCL_INCLUDE="$EXTCMPLRROOT/include/sycl" \
66+
--param SYCL_LIBS_DIR="$EXTCMPLRROOT/lib" \
67+
--param GET_DEVICE_TOOL=$GET_DEVICE_TOOL \
68+
--param LEVEL_ZERO_INCLUDE_DIR=$L0_HEADER_PATH \
69+
tools/sycl-test
70+
```

sycl/test/on-device/lit.cfg.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,18 @@
6666
config.substitutions.append( ('%sycl_source_dir', config.sycl_source_dir) )
6767
config.substitutions.append( ('%opencl_libs_dir', config.opencl_libs_dir) )
6868
config.substitutions.append( ('%opencl_include_dir', config.opencl_include_dir) )
69+
config.substitutions.append( ('%level_zero_include_dir', config.level_zero_include_dir) )
6970
config.substitutions.append( ('%cuda_toolkit_include', config.cuda_toolkit_include) )
7071
config.substitutions.append( ('%sycl_tools_src_dir', config.sycl_tools_src_dir ) )
7172
config.substitutions.append( ('%llvm_build_lib_dir', config.llvm_build_lib_dir ) )
7273
config.substitutions.append( ('%llvm_build_bin_dir', config.llvm_build_bin_dir ) )
7374

75+
if config.level_zero_include_dir:
76+
config.available_features.add("level_zero_headers")
77+
else:
78+
lit_config.warning("Level_Zero headers path is not configured. Dependent tests are skipped.")
79+
80+
7481
llvm_config.use_clang()
7582

7683
llvm_config.add_tool_substitutions(['llvm-spirv'], [config.sycl_tools_dir])
@@ -81,7 +88,9 @@
8188
config.substitutions.append( ('%BE_RUN_PLACEHOLDER', "env SYCL_DEVICE_FILTER={SYCL_PLUGIN} ".format(SYCL_PLUGIN=backend)) )
8289
config.substitutions.append( ('%RUN_ON_HOST', "env SYCL_DEVICE_FILTER=host ") )
8390

84-
get_device_count_by_type_path = os.path.join(config.llvm_tools_dir, "get_device_count_by_type")
91+
get_device_count_by_type_path = lit_config.params.get('GET_DEVICE_TOOL', os.path.join(config.llvm_tools_dir, "get_device_count_by_type"))
92+
if 'GET_DEVICE_TOOL' in lit_config.params.keys():
93+
lit_config.warning("The tool from none-default path is used: "+get_device_count_by_type_path)
8594

8695
def getDeviceCount(device_type):
8796
is_cuda = False;

sycl/test/on-device/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ config.sycl_tools_src_dir = "@SYCL_TOOLS_SRC_DIR@"
1818
config.llvm_build_lib_dir = "@LLVM_BUILD_LIBRARY_DIRS@"
1919
config.llvm_build_bin_dir = "@LLVM_BUILD_BINARY_DIRS@"
2020
config.sycl_clang_extra_flags = "@SYCL_CLANG_EXTRA_FLAGS@"
21+
config.level_zero_include_dir = lit_config.params.get('LEVEL_ZERO_INCLUDE_DIR', "@LEVEL_ZERO_INCLUDE_DIR@")
2122

2223
config.llvm_enable_projects = "@LLVM_ENABLE_PROJECTS@"
2324

sycl/test/on-device/online_compiler/online_compiler_L0.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// REQUIRES: level_zero
1+
// REQUIRES: level_zero, level_zero_headers
22

3-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir -DRUN_KERNELS -lze_loader %s -o %t.out
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %level_zero_include_dir -DRUN_KERNELS -lze_loader %s -o %t.out
44
// RUN: %CPU_RUN_PLACEHOLDER %t.out
55
// RUN: %GPU_RUN_PLACEHOLDER %t.out
6-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir -lze_loader %s -o %th.out
6+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %level_zero_include_dir -lze_loader %s -o %th.out
77
// RUN: %RUN_ON_HOST %th.out
88

99
// This test checks INTEL feature class online_compiler for Level-Zero.

0 commit comments

Comments
 (0)