Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 8c8996a

Browse files
[SYCL] Use host device explicitly and add default ctor tests (#1169)
SYCL2020 changes the default constructor of both platform and device from using host to using the objects associated with the default device selector. This commit adjusts for this change in behaviour. Additionally, this commit also adds tests for the default constructor behaviour for both platform and device. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent e63cce9 commit 8c8996a

File tree

5 files changed

+45
-5
lines changed

5 files changed

+45
-5
lines changed

SYCL/Basic/default_device.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//==--------- default_device.cpp - SYCL device default ctor test -----------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
10+
// RUN: %HOST_RUN_PLACEHOLDER %t.out
11+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
12+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
13+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
14+
15+
#include <sycl/sycl.hpp>
16+
17+
int main() {
18+
sycl::device Dev;
19+
assert(Dev == sycl::device{sycl::default_selector_v});
20+
return 0;
21+
}

SYCL/Basic/default_platform.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//==------- default_platform.cpp - SYCL platform default ctor test ---------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
10+
// RUN: %HOST_RUN_PLACEHOLDER %t.out
11+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
12+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
13+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
14+
15+
#include <sycl/sycl.hpp>
16+
17+
int main() {
18+
sycl::platform Plt;
19+
assert(Plt == sycl::platform{sycl::default_selector_v});
20+
return 0;
21+
}

SYCL/Basic/device_equality.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ int main() {
3737
assert((dev1 == dev2) && "Device 1 == Device 2");
3838
assert((plat1 == plat2) && "Platform 1 == Platform 2");
3939

40-
device h1;
41-
device h2;
40+
device h1{host_selector{}};
41+
device h2{host_selector{}};
4242

4343
assert(h1.is_host() && "Device h1 is host");
4444
assert(h2.is_host() && "Device h2 is host");

SYCL/FilterSelector/select.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ int main() {
2323
std::vector<device> GPUs;
2424
std::vector<device> Accels;
2525
std::vector<device> Devs;
26-
device host;
2726

2827
CPUs = device::get_devices(info::device_type::cpu);
2928
GPUs = device::get_devices(info::device_type::gpu);

SYCL/USM/pointer_query.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ int main() {
2929
return 0;
3030

3131
usm::alloc Kind;
32-
device D;
3332

3433
// Test device allocs
3534
array = (int *)malloc_device(N * sizeof(int), q);
@@ -48,7 +47,7 @@ int main() {
4847
return 3;
4948
}
5049
}
51-
D = get_pointer_device(array, ctxt);
50+
device D = get_pointer_device(array, ctxt);
5251
if (D != dev) {
5352
return 4;
5453
}

0 commit comments

Comments
 (0)