Skip to content

Commit bce2da2

Browse files
authored
[SYCL][CUDA] Fix LIT fails on machines without non-NVIDIA OpenCL (#1613)
Make the backend used explicit in more LIT tests. These tests failed on machines with only NVIDIA OpenCL available as it is not supported. Pass the SYCL_BE environment variable to the SYCL-Unit unit tests. Signed-off-by: Bjoern Knafla <[email protected]>
1 parent 0681a36 commit bce2da2

File tree

6 files changed

+29
-27
lines changed

6 files changed

+29
-27
lines changed

sycl/test/Unit/lit.cfg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ def find_shlibpath_var():
6666
else:
6767
lit_config.warning("unable to inject shared library path on '{}'"
6868
.format(platform.system()))
69+
70+
config.environment['SYCL_BE'] = lit_config.params.get('SYCL_BE', "PI_OPENCL")
71+
lit_config.note("Backend (SYCL_BE): {}".format(config.environment['SYCL_BE']))

sycl/test/basic_tests/diagnostics/device-check.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
// RUN: %clangxx -fsycl %s -o %t.out
2-
// RUN: env SYCL_DEVICE_TYPE=cpu %t.out
3-
// RUN: env SYCL_DEVICE_TYPE=gpu %t.out
4-
// RUN: env SYCL_DEVICE_TYPE=acc %t.out
5-
// RUN: env SYCL_DEVICE_TYPE=host %t.out
6-
// RUN: env SYCL_DEVICE_TYPE=CPU %t.out
7-
// RUN: env SYCL_DEVICE_TYPE=GPU %t.out
8-
// RUN: env SYCL_DEVICE_TYPE=ACC %t.out
9-
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
10-
// RUN: env SYCL_DEVICE_TYPE=Cpu %t.out
11-
// RUN: env SYCL_DEVICE_TYPE=Gpu %t.out
12-
// RUN: env SYCL_DEVICE_TYPE=Acc %t.out
13-
// RUN: env SYCL_DEVICE_TYPE=Host %t.out
14-
// RUN: env SYCL_DEVICE_TYPE=XPU %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=cpu %t.out
3+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=gpu %t.out
4+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=acc %t.out
5+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=host %t.out
6+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=CPU %t.out
7+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=GPU %t.out
8+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=ACC %t.out
9+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=HOST %t.out
10+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=Cpu %t.out
11+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=Gpu %t.out
12+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=Acc %t.out
13+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=Host %t.out
14+
// RUN: env SYCL_BE=%sycl_be SYCL_DEVICE_TYPE=XPU %t.out
1515

1616
//==------------------- device-check.cpp --------------------------==//
1717
// This is a diagnostic test which ensures that
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
// RUN: %clangxx -fsycl %s -o %t.out
2-
// RUN: %t.out | FileCheck %s
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: env SYCL_BE=%sycl_be %t.out | FileCheck %s
33
//==------------------- handler.cpp ----------------------------------------==//
4-
//
54
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
65
// See https://llvm.org/LICENSE.txt for license information.
76
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
87
//
98
//===----------------------------------------------------------------------===//
109

1110
#include <CL/sycl.hpp>
11+
#include <cassert>
1212

1313
using namespace cl;
1414

1515
int main() {
1616

17-
bool Failed = false;
18-
1917
sycl::queue Queue([](sycl::exception_list ExceptionList) {
2018
if (ExceptionList.size() != 1) {
2119
std::cerr << "Should be one exception in exception list" << std::endl;
@@ -30,8 +28,9 @@ int main() {
3028
CGH.single_task<class Dummy2>([]() {});
3129
});
3230
Queue.throw_asynchronous();
33-
} catch (sycl::exception &E) {
31+
assert(!"Expected exception not caught");
32+
} catch (sycl::exception &ExpectedException) {
3433
// CHECK: Attempt to set multiple actions for the command group
35-
std::cout << E.what() << std::endl;
34+
std::cout << ExpectedException.what() << std::endl;
3635
}
3736
}

sycl/test/basic_tests/get_nonhost_devices.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %clangxx -fsycl %s -o %t.out
2-
// RUN: %t.out
3-
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: env SYCL_BE=%sycl_be %t.out
3+
//
44
// Check that the host device is not included in devices returned by
55
// get_devices() if a non-host device type is specified.
66

sycl/test/basic_tests/queue.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
3-
// RUN: %t.out
2+
// RUN: env SYCL_BE=%sycl_be %t.out
43
//==--------------- queue.cpp - SYCL queue test ----------------------------==//
54
//
65
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

sycl/test/lit.cfg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
llvm_config.add_tool_substitutions(['llvm-spirv'], [config.sycl_tools_dir])
7474

7575
backend=lit_config.params.get('SYCL_BE', "PI_OPENCL")
76-
lit_config.note("Backend: {BACKEND}".format(BACKEND=backend))
76+
lit_config.note("Backend (SYCL_BE): {}".format(backend))
77+
config.substitutions.append( ('%sycl_be', backend) )
7778

7879
get_device_count_by_type_path = os.path.join(config.llvm_tools_dir, "get_device_count_by_type")
7980

0 commit comments

Comments
 (0)