Skip to content

Commit 0ceb0bb

Browse files
author
andrei.elovikov
committed
[SYCL] Add support for the in-tree end-to-end tests
We plan to move the intel/llvm-test-suite back in-tree. In order to do that, we need to update the infrastructure first, both in this repository and internally. Start by adding a single trivial test and enabling cmake/Linux CI support. 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 806775f commit 0ceb0bb

File tree

8 files changed

+632
-4
lines changed

8 files changed

+632
-4
lines changed

.github/workflows/sycl_linux_build_and_test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ jobs:
160160
run: tar -cJf llvm_sycl.tar.xz -C $GITHUB_WORKSPACE/build/install .
161161
- name: Pack LIT
162162
run: tar -cJf lit.tar.xz -C $GITHUB_WORKSPACE/src/llvm/utils/lit .
163+
- name: Pack End-to-End LIT tests
164+
run: tar -cJf e2e_tests.tar.xz -C $GITHUB_WORKSPACE/src/sycl/test-e2e .
163165
- name: Upload toolchain
164166
uses: actions/upload-artifact@v3
165167
with:
@@ -170,6 +172,11 @@ jobs:
170172
with:
171173
name: sycl_lit_${{ inputs.build_artifact_suffix }}
172174
path: lit.tar.xz
175+
- name: Upload End-to-End LIT tests
176+
uses: actions/upload-artifact@v3
177+
with:
178+
name: sycl_e2e_tests_${{ inputs.build_artifact_suffix }}
179+
path: e2e_tests.tar.xz
173180

174181
aws-start:
175182
name: Start AWS
@@ -229,21 +236,40 @@ jobs:
229236
fi
230237
# FIXME cached_checkout fails here, but works everywhere else
231238
- uses: actions/checkout@v3
239+
id: checkout
232240
with:
233241
persist-credentials: false
234242
path: llvm
235243
# TODO should this action be packed into container as well?
244+
- uses: ./llvm/devops/actions/llvm_test_suite
245+
name: Run LLVM Test Suite In-Tree
246+
with:
247+
test_ref: ${{ inputs.lts_ref }}
248+
sycl_artifact: sycl_linux_${{ inputs.build_artifact_suffix }}
249+
sycl_archive: llvm_sycl.tar.xz
250+
lit_artifact: sycl_lit_${{ inputs.build_artifact_suffix }}
251+
lit_archive: lit.tar.xz
252+
e2e_tests_artifact: sycl_e2e_tests_${{ inputs.build_artifact_suffix }}
253+
e2e_tests_archive: e2e_tests.tar.xz
254+
check_sycl_all: ${{ matrix.check_sycl_all }}
255+
results_name_suffix: ${{ matrix.config }}_${{ inputs.build_artifact_suffix }}
256+
cmake_args: '${{ matrix.cmake_args }} ${{ inputs.lts_cmake_extra_args }}'
257+
in_tree_e2e: true
236258
- uses: ./llvm/devops/actions/llvm_test_suite
237259
name: Run LLVM Test Suite
260+
if: ${{ always() && !cancelled() && steps.checkout.outcome == 'success' }}
238261
with:
239262
test_ref: ${{ inputs.lts_ref }}
240263
sycl_artifact: sycl_linux_${{ inputs.build_artifact_suffix }}
241264
sycl_archive: llvm_sycl.tar.xz
242265
lit_artifact: sycl_lit_${{ inputs.build_artifact_suffix }}
243266
lit_archive: lit.tar.xz
267+
e2e_tests_artifact: sycl_e2e_tests_${{ inputs.build_artifact_suffix }}
268+
e2e_tests_archive: e2e_tests.tar.xz
244269
check_sycl_all: ${{ matrix.check_sycl_all }}
245270
results_name_suffix: ${{ matrix.config }}_${{ inputs.build_artifact_suffix }}
246271
cmake_args: '${{ matrix.cmake_args }} ${{ inputs.lts_cmake_extra_args }}'
272+
in_tree_e2e: false
247273

248274
khronos_sycl_cts:
249275
needs: build

devops/actions/llvm_test_suite/action.yml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ inputs:
1919
description: 'Name of LIT archive file'
2020
required: false
2121
default: 'lit.tar.xz'
22+
e2e_tests_artifact:
23+
description: 'Name of the artifact, that contains End-to-End LIT Tests'
24+
required: true
25+
e2e_tests_archive:
26+
description: 'Name of End-to-End LIT Tests archive file'
27+
required: false
28+
default: 'e2e_tests.tar.xz'
2229
results_name_suffix:
2330
description: 'Name suffix of the results artifact'
2431
required: true
@@ -28,6 +35,10 @@ inputs:
2835
cmake_args:
2936
description: 'Extra arguments to cmake command'
3037
required: false
38+
in_tree_e2e:
39+
description: "Flag directing to use in-tree End-to-End LIT tests"
40+
required: false
41+
default: false
3142

3243
post-if: false
3344
runs:
@@ -66,13 +77,33 @@ runs:
6677
ls -la
6778
tar -xf ${{ inputs.lit_archive }} -C lit
6879
rm -f ${{ inputs.lit_archive }}
80+
- name: Download End-to-End LIT Tests
81+
if: inputs.in_tree_e2e
82+
uses: actions/download-artifact@v3
83+
with:
84+
name: ${{ inputs.e2e_tests_artifact }}
85+
- name: Extract End-to-End LIT Tests
86+
if: inputs.in_tree_e2e
87+
shell: bash
88+
run: |
89+
mkdir test_e2e
90+
ls -la
91+
tar -xf ${{ inputs.e2e_tests_archive }} -C test_e2e
92+
ls -R test_e2e
93+
rm -f ${{ inputs.e2e_tests_archive }}
6994
- name: Configure
7095
shell: bash
7196
run: |
7297
echo "::group::CMake configuration"
7398
mkdir build
7499
export PATH=$PWD/toolchain/bin/:$PATH
75-
cmake -GNinja -B./build -S./llvm_test_suite -DTEST_SUITE_SUBDIRS=SYCL -DCHECK_SYCL_ALL="${{ inputs.check_sycl_all }}" -DCMAKE_CXX_COMPILER="$PWD/toolchain/bin/clang++" -DTEST_SUITE_LIT="$PWD/lit/lit.py" ${{ inputs.cmake_args }}
100+
if ${{ inputs.in_tree_e2e }}
101+
then
102+
# TODO: Rename check_sycl_all input
103+
cmake -GNinja -B./build -S./test_e2e -DSYCL_TEST_E2E_TARGETS="${{ inputs.check_sycl_all }}" -DCMAKE_CXX_COMPILER="$PWD/toolchain/bin/clang++" -DLLVM_LIT="$PWD/lit/lit.py" ${{ inputs.cmake_args }}
104+
else
105+
cmake -GNinja -B./build -S./llvm_test_suite -DTEST_SUITE_SUBDIRS=SYCL -DCHECK_SYCL_ALL="${{ inputs.check_sycl_all }}" -DCMAKE_CXX_COMPILER="$PWD/toolchain/bin/clang++" -DTEST_SUITE_LIT="$PWD/lit/lit.py" ${{ inputs.cmake_args }}
106+
fi
76107
echo "::endgroup::"
77108
- name: Run testing
78109
shell: bash
@@ -81,7 +112,7 @@ runs:
81112
export PATH=$PWD/toolchain/bin/:$PATH
82113
# TODO make this part of container build
83114
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rocm/hip/lib/:/opt/rocm/lib
84-
export LIT_OPTS="-v --no-progress-bar --show-unsupported --max-time 3600 --time-tests -o $PWD/build/results_${{ inputs.results_name_suffix }}.json"
115+
export LIT_OPTS="-v --no-progress-bar --show-unsupported --max-time 3600 --time-tests -o $PWD/build/results_${{ inputs.results_name_suffix }}_${{ inputs.in_tree_e2e }}.json"
85116
if [ -e /runtimes/oneapi-tbb/env/vars.sh ]; then
86117
source /runtimes/oneapi-tbb/env/vars.sh;
87118
elif [ -e /opt/runtimes/oneapi-tbb/env/vars.sh ]; then
@@ -103,13 +134,18 @@ runs:
103134
SYCL_PI_TRACE=-1 sycl-ls
104135
echo "::endgroup::"
105136
cd build
106-
ninja check-sycl-all
137+
if ${{ inputs.in_tree_e2e }}
138+
then
139+
ninja check-sycl-e2e
140+
else
141+
ninja check-sycl-all
142+
fi
107143
- name: Upload test results
108144
uses: actions/upload-artifact@v1
109145
if: always()
110146
with:
111147
name: lit_results
112-
path: build/results_${{ inputs.results_name_suffix }}.json
148+
path: build/results_${{ inputs.results_name_suffix }}_${{ inputs.in_tree_e2e}}.json
113149
- name: Cleanup
114150
shell: bash
115151
if: always()
@@ -118,3 +154,4 @@ runs:
118154
rm -rf lit
119155
rm -rf build
120156
rm -rf llvm_test_suite
157+
rm -rf test-e2e

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/ESIMD/pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// RUN: true

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)