From c10ac4d1b46545ae012f421b70bc8050ec5d1fd5 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 22 Aug 2022 12:18:43 -0700 Subject: [PATCH 1/3] [SYCL] Use host device explicitly and add default ctor tests 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 --- SYCL/Basic/default_device.cpp | 21 +++++++++++++++++++++ SYCL/Basic/default_platform.cpp | 21 +++++++++++++++++++++ SYCL/Basic/device_equality.cpp | 4 ++-- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 SYCL/Basic/default_device.cpp create mode 100644 SYCL/Basic/default_platform.cpp diff --git a/SYCL/Basic/default_device.cpp b/SYCL/Basic/default_device.cpp new file mode 100644 index 0000000000..cb13268d18 --- /dev/null +++ b/SYCL/Basic/default_device.cpp @@ -0,0 +1,21 @@ +//==--------- default_device.cpp - SYCL device default ctor test -----------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %HOST_RUN_PLACEHOLDER %t.out +// RUN: %CPU_RUN_PLACEHOLDER %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out + +#include + +int main() { + sycl::device Dev; + assert(Dev == sycl::device{sycl::default_selector_v}); + return 0; +} diff --git a/SYCL/Basic/default_platform.cpp b/SYCL/Basic/default_platform.cpp new file mode 100644 index 0000000000..89c6606581 --- /dev/null +++ b/SYCL/Basic/default_platform.cpp @@ -0,0 +1,21 @@ +//==------- default_platform.cpp - SYCL platform default ctor test ---------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %HOST_RUN_PLACEHOLDER %t.out +// RUN: %CPU_RUN_PLACEHOLDER %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out + +#include + +int main() { + sycl::platform Plt; + assert(Plt == sycl::platform{sycl::default_selector_v}); + return 0; +} diff --git a/SYCL/Basic/device_equality.cpp b/SYCL/Basic/device_equality.cpp index 556cf84a3e..20295a393f 100644 --- a/SYCL/Basic/device_equality.cpp +++ b/SYCL/Basic/device_equality.cpp @@ -37,8 +37,8 @@ int main() { assert((dev1 == dev2) && "Device 1 == Device 2"); assert((plat1 == plat2) && "Platform 1 == Platform 2"); - device h1; - device h2; + device h1{host_selector{}}; + device h2{host_selector{}}; assert(h1.is_host() && "Device h1 is host"); assert(h2.is_host() && "Device h2 is host"); From 2462290798bca6570b2f89e6355abb8e5b9cda40 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 22 Aug 2022 15:16:19 -0700 Subject: [PATCH 2/3] Adjust more tests Signed-off-by: Larsen, Steffen --- SYCL/FilterSelector/select.cpp | 2 +- SYCL/USM/pointer_query.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/SYCL/FilterSelector/select.cpp b/SYCL/FilterSelector/select.cpp index b1400f9726..13dfab8387 100644 --- a/SYCL/FilterSelector/select.cpp +++ b/SYCL/FilterSelector/select.cpp @@ -23,7 +23,7 @@ int main() { std::vector GPUs; std::vector Accels; std::vector Devs; - device host; + device host{host_selector{}}; CPUs = device::get_devices(info::device_type::cpu); GPUs = device::get_devices(info::device_type::gpu); diff --git a/SYCL/USM/pointer_query.cpp b/SYCL/USM/pointer_query.cpp index 8f12fa5358..7280406acd 100644 --- a/SYCL/USM/pointer_query.cpp +++ b/SYCL/USM/pointer_query.cpp @@ -29,7 +29,6 @@ int main() { return 0; usm::alloc Kind; - device D; // Test device allocs array = (int *)malloc_device(N * sizeof(int), q); @@ -48,7 +47,7 @@ int main() { return 3; } } - D = get_pointer_device(array, ctxt); + device D = get_pointer_device(array, ctxt); if (D != dev) { return 4; } From 8b2b2c585814adfa2ca75e0a98bd28e242505e87 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Wed, 24 Aug 2022 07:34:42 -0700 Subject: [PATCH 3/3] Remove unused host device from select.cpp Signed-off-by: Larsen, Steffen --- SYCL/FilterSelector/select.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SYCL/FilterSelector/select.cpp b/SYCL/FilterSelector/select.cpp index 13dfab8387..be3c4432ef 100644 --- a/SYCL/FilterSelector/select.cpp +++ b/SYCL/FilterSelector/select.cpp @@ -23,7 +23,6 @@ int main() { std::vector GPUs; std::vector Accels; std::vector Devs; - device host{host_selector{}}; CPUs = device::get_devices(info::device_type::cpu); GPUs = device::get_devices(info::device_type::gpu);