Skip to content

Commit 8c32128

Browse files
[SYCL] Add cmake support for the SYCL End-to-End tests
We plan to move the intel/llvm-test-suite back in-tree. In order to do this we need to update the infrastructure first (e.g., CI). Enable that by adding require CMake support and a "fake" test. We plan to run the tests in a "standalone" mode, similarly how current intel/llvm-test-suite is used. As such, CMake target is decoupled from general check-* processing and is not include into check-all automatically.
1 parent 14bf9d9 commit 8c32128

File tree

5 files changed

+564
-0
lines changed

5 files changed

+564
-0
lines changed

sycl/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,6 @@ add_custom_target(deploy-sycl-toolchain
486486

487487
# SYCL Runtime documentation
488488
add_subdirectory(doc)
489+
490+
# SYCL End-to-End tests (former intel/llvm-test-suite).
491+
add_subdirectory(test-e2e)

sycl/test-e2e/CMakeLists.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
message("Configuring SYCL End-to-End Tests")
4+
5+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
6+
project(sycl-e2e-test-suite C CXX)
7+
set(SYCL_TEST_E2E_STANDALONE TRUE)
8+
endif()
9+
10+
if(SYCL_TEST_E2E_STANDALONE)
11+
if( NOT OpenCL_LIBRARY )
12+
find_package(OpenCL)
13+
endif()
14+
endif() # Standalone.
15+
16+
if(SYCL_TEST_E2E_STANDALONE)
17+
set(SYCL_CXX_COMPILER ${CMAKE_CXX_COMPILER})
18+
else()
19+
set(SYCL_CXX_COMPILER "${LLVM_BINARY_DIR}/bin/clang++")
20+
endif() # Standalone.
21+
22+
find_package(Threads REQUIRED)
23+
set(SYCL_THREADS_LIB ${CMAKE_THREAD_LIBS_INIT})
24+
25+
if(NOT LLVM_LIT)
26+
find_program(LLVM_LIT
27+
NAMES llvm-lit lit.py lit
28+
PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit"
29+
DOC "Path to lit.py")
30+
endif()
31+
32+
set(SYCL_E2E_TESTS_LIT_FLAGS "-sv" CACHE STRING "Flags used when running lit")
33+
34+
find_package(Python3 REQUIRED COMPONENTS Interpreter)
35+
36+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in"
37+
"${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg")
38+
39+
if(SYCL_TEST_E2E_TARGETS)
40+
message("Configure iterative execution on multiple backends")
41+
add_custom_target(check-sycl-e2e)
42+
foreach(TARGET_STR ${SYCL_TEST_E2E_TARGETS})
43+
string(REPLACE ":" ";" TARGET_LIST ${TARGET_STR})
44+
list (GET TARGET_LIST 0 TARGET_BE)
45+
list (GET TARGET_LIST 1 TARGET_DEVICES)
46+
47+
if ("${TARGET_BE}" STREQUAL "")
48+
message(FATAL_ERROR
49+
"invalid empty target backend specification in SYCL_TEST_E2E_TARGETS")
50+
elseif("${TARGET_DEVICES}" STREQUAL "")
51+
message(FATAL_ERROR
52+
"invalid empty target device specification in SYCL_TEST_E2E_TARGETS")
53+
endif()
54+
message("Run on ${TARGET_DEVICES} for ${TARGET_BE}")
55+
56+
string(REPLACE "," "_" TARGET check-sycl-e2e-${TARGET_BE}-${TARGET_DEVICES})
57+
58+
add_custom_target(${TARGET}
59+
COMMAND ${Python3_EXECUTABLE} ${LLVM_LIT} ${SYCL_E2E_TESTS_LIT_FLAGS} --param sycl_be=${TARGET_BE} --param target_devices=${TARGET_DEVICES} .
60+
COMMENT "Running the SYCL tests for ${TARGET} backend"
61+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
62+
USES_TERMINAL
63+
)
64+
set_target_properties(${TARGET} PROPERTIES FOLDER "SYCL Level Zero tests")
65+
add_dependencies(check-sycl-e2e ${TARGET})
66+
67+
endforeach()
68+
endif(SYCL_TEST_E2E_TARGETS)
69+
70+
# TODO: Re-enable when moving the entire intel/llvm-test-suite back in-tree.
71+
# add_subdirectory(External)
72+
# add_subdirectory(ExtraTests)

sycl/test-e2e/TestSuiteMove/hello.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
3+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
4+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
5+
6+
// XFAIL: cpu
7+
8+
#include <sycl/sycl.hpp>
9+
10+
int main() {
11+
sycl::queue q;
12+
return q.get_device().get_info<sycl::info::device::device_type>() ==
13+
sycl::info::device_type::cpu;
14+
}

0 commit comments

Comments
 (0)