diff --git a/SYCL/Regression/fsycl-host-compiler-win.cpp b/SYCL/Regression/fsycl-host-compiler-win.cpp new file mode 100644 index 0000000000..1442b2bae4 --- /dev/null +++ b/SYCL/Regression/fsycl-host-compiler-win.cpp @@ -0,0 +1,47 @@ +// 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..c78d474092 --- /dev/null +++ b/SYCL/Regression/fsycl-host-compiler.cpp @@ -0,0 +1,57 @@ +// 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; +}