Skip to content

Commit 557cb61

Browse files
committed
[SYCL] use lambda instead of callback for threads
1 parent cb2a6bd commit 557cb61

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

tests/extension/oneapi_current_device/current_device.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ TEST_CASE(
2929
#ifndef SYCL_EXT_ONEAPI_CURRENT_DEVICE
3030
SKIP(
3131
"The sycl_ext_oneapi_current_device extension is not supported "
32-
"by an implementation");
32+
"by this implementation");
3333
#else
3434
if (sycl::device::get_devices().size() < 1) {
3535
SKIP("Test requires at least one device");
@@ -49,7 +49,7 @@ TEST_CASE(
4949
"set_current_device function") {
5050
#ifndef SYCL_EXT_ONEAPI_CURRENT_DEVICE
5151
SKIP(
52-
"The sycl_ext_oneapi_current_device extension is not supported by an "
52+
"The sycl_ext_oneapi_current_device extension is not supported by this "
5353
"implementation");
5454
#else
5555
for (const auto& device : sycl::device::get_devices()) {
@@ -77,7 +77,7 @@ TEST_CASE(
7777
#ifndef SYCL_EXT_ONEAPI_CURRENT_DEVICE
7878
SKIP(
7979
"The sycl_ext_oneapi_current_device extension is not supported "
80-
"by an implementation");
80+
"by this implementation");
8181
#else
8282
const auto devices = sycl::device::get_devices();
8383
if (devices.size() < 2) {
@@ -88,10 +88,19 @@ TEST_CASE(
8888
sycl::device t1_current_device;
8989
sycl::device t2_current_device;
9090

91-
std::thread t1(thread_callback, std::cref(t1_device_to_set),
92-
std::ref(t1_current_device));
93-
std::thread t2(thread_callback, std::cref(t2_device_to_set),
94-
std::ref(t2_current_device));
91+
std::thread t1([&t1_device_to_set, &t1_current_device]() {
92+
sycl::ext::oneapi::experimental::this_thread::set_current_device(
93+
t1_device_to_set);
94+
t1_current_device =
95+
sycl::ext::oneapi::experimental::this_thread::get_current_device();
96+
});
97+
std::thread t2([&t2_device_to_set, &t2_current_device]() {
98+
sycl::ext::oneapi::experimental::this_thread::set_current_device(
99+
t2_device_to_set);
100+
t2_current_device =
101+
sycl::ext::oneapi::experimental::this_thread::get_current_device();
102+
});
103+
95104
t1.join();
96105
t2.join();
97106

0 commit comments

Comments
 (0)