From 8848ef99295174bad53e77c5bab00ab1eccd7914 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 9 Sep 2022 05:56:55 -0700 Subject: [PATCH 1/2] [SYCL] Move host-compiler tests from in-tree LIT This commit moves fsycl-host-compiler.cpp and fsycl-host-compiler-win.cpp from the intel/llvm in-tree lit tests to the test-suite to allow the device dependence. Signed-off-by: Larsen, Steffen --- SYCL/Regression/fsycl-host-compiler-win.cpp | 48 +++++++++++++++++ SYCL/Regression/fsycl-host-compiler.cpp | 58 +++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 SYCL/Regression/fsycl-host-compiler-win.cpp create mode 100644 SYCL/Regression/fsycl-host-compiler.cpp diff --git a/SYCL/Regression/fsycl-host-compiler-win.cpp b/SYCL/Regression/fsycl-host-compiler-win.cpp new file mode 100644 index 0000000000..9e9be6627d --- /dev/null +++ b/SYCL/Regression/fsycl-host-compiler-win.cpp @@ -0,0 +1,48 @@ +// RUN: %clangxx -fsycl -fsycl-host-compiler=cl -DDEFINE_CHECK -fsycl-host-compiler-options="-DDEFINE_CHECK /std:c++17" /Fe%t.exe %s +// RUN: %CPU_RUN_PLACEHOLDER %t.exe +// RUN: %GPU_RUN_PLACEHOLDER %t.exe +// RUN: %ACC_RUN_PLACEHOLDER %t.exe +// REQUIRES: windows +// +//==------- fsycl-host-compiler-win.cpp - external host compiler 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 +// +//===----------------------------------------------------------------------===// +// +// Uses -fsycl-host-compiler= on a simple test, requires 'cl' + +#include + +#ifndef DEFINE_CHECK +#error predefined macro not set +#endif // DEFINE_CHECK + +using namespace sycl; + +int main() { + int data[] = {0, 0, 0}; + + { + buffer b(data, range<1>(3), {property::buffer::use_host_ptr()}); + queue q; + q.submit([&](handler &cgh) { + auto B = b.get_access(cgh); + cgh.parallel_for(range<1>(3), [=](id<1> idx) { + B[idx] = 1; + }); + }); + } + + bool isSuccess = true; + + for (int i = 0; i < 3; i++) + if (data[i] != 1) isSuccess = false; + + if (!isSuccess) + return -1; + + return 0; +} diff --git a/SYCL/Regression/fsycl-host-compiler.cpp b/SYCL/Regression/fsycl-host-compiler.cpp new file mode 100644 index 0000000000..8c76eea90d --- /dev/null +++ b/SYCL/Regression/fsycl-host-compiler.cpp @@ -0,0 +1,58 @@ +// RUN: %clangxx -fsycl -fsycl-host-compiler=g++ -DDEFINE_CHECK -fsycl-host-compiler-options="-DDEFINE_CHECK -std=c++17" -o %t.out %s +// RUN: %CPU_RUN_PLACEHOLDER %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out +// REQUIRES: linux +//==------- fsycl-host-compiler.cpp - external host compiler 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 +// +//===----------------------------------------------------------------------===// +// +// Uses -fsycl-host-compiler= on a simple test, requires 'g++' + +#include + +#ifndef DEFINE_CHECK +#error predefined macro not set +#endif // DEFINE_CHECK + +using namespace sycl; + +int main() { + int data[] = {0, 0, 0}; + + { + buffer b(data, range<1>(3), {property::buffer::use_host_ptr()}); + queue q; + q.submit([&](handler &cgh) { + auto B = b.get_access(cgh); + cgh.parallel_for(range<1>(3), [=](id<1> idx) { + B[idx] = 1; + }); + }); + } + + bool isSuccess = true; + + for (int i = 0; i < 3; i++) + if (data[i] != 1) isSuccess = false; + + { + buffer b(1); + queue q; + q.submit([&](handler &cgh) { + accessor a{b, cgh}; + cgh.single_task([=] { a[0] = 42; }); + }).wait(); + host_accessor a{b}; + isSuccess &= (a[0] == 42); + } + + if (!isSuccess) + return -1; + + return 0; +} From 4517f6c3a5b8f865603b0b3c9319901b815852ab Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 9 Sep 2022 06:17:37 -0700 Subject: [PATCH 2/2] Fix formatting Signed-off-by: Larsen, Steffen --- SYCL/Regression/fsycl-host-compiler-win.cpp | 7 +++---- SYCL/Regression/fsycl-host-compiler.cpp | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/SYCL/Regression/fsycl-host-compiler-win.cpp b/SYCL/Regression/fsycl-host-compiler-win.cpp index 9e9be6627d..1442b2bae4 100644 --- a/SYCL/Regression/fsycl-host-compiler-win.cpp +++ b/SYCL/Regression/fsycl-host-compiler-win.cpp @@ -30,16 +30,15 @@ int main() { queue q; q.submit([&](handler &cgh) { auto B = b.get_access(cgh); - cgh.parallel_for(range<1>(3), [=](id<1> idx) { - B[idx] = 1; - }); + cgh.parallel_for(range<1>(3), [=](id<1> idx) { B[idx] = 1; }); }); } bool isSuccess = true; for (int i = 0; i < 3; i++) - if (data[i] != 1) isSuccess = false; + if (data[i] != 1) + isSuccess = false; if (!isSuccess) return -1; diff --git a/SYCL/Regression/fsycl-host-compiler.cpp b/SYCL/Regression/fsycl-host-compiler.cpp index 8c76eea90d..c78d474092 100644 --- a/SYCL/Regression/fsycl-host-compiler.cpp +++ b/SYCL/Regression/fsycl-host-compiler.cpp @@ -29,16 +29,15 @@ int main() { queue q; q.submit([&](handler &cgh) { auto B = b.get_access(cgh); - cgh.parallel_for(range<1>(3), [=](id<1> idx) { - B[idx] = 1; - }); + cgh.parallel_for(range<1>(3), [=](id<1> idx) { B[idx] = 1; }); }); } bool isSuccess = true; for (int i = 0; i < 3; i++) - if (data[i] != 1) isSuccess = false; + if (data[i] != 1) + isSuccess = false; { buffer b(1);