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

[SYCL] Move host-compiler tests from in-tree LIT #1240

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions SYCL/Regression/fsycl-host-compiler-win.cpp
Original file line number Diff line number Diff line change
@@ -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=<compiler> on a simple test, requires 'cl'

#include <sycl/sycl.hpp>

#ifndef DEFINE_CHECK
#error predefined macro not set
#endif // DEFINE_CHECK

using namespace sycl;

int main() {
int data[] = {0, 0, 0};

{
buffer<int, 1> b(data, range<1>(3), {property::buffer::use_host_ptr()});
queue q;
q.submit([&](handler &cgh) {
auto B = b.get_access<access::mode::write>(cgh);
cgh.parallel_for<class test>(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;
}
57 changes: 57 additions & 0 deletions SYCL/Regression/fsycl-host-compiler.cpp
Original file line number Diff line number Diff line change
@@ -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=<compiler> on a simple test, requires 'g++'

#include <sycl/sycl.hpp>

#ifndef DEFINE_CHECK
#error predefined macro not set
#endif // DEFINE_CHECK

using namespace sycl;

int main() {
int data[] = {0, 0, 0};

{
buffer<int, 1> b(data, range<1>(3), {property::buffer::use_host_ptr()});
queue q;
q.submit([&](handler &cgh) {
auto B = b.get_access<access::mode::write>(cgh);
cgh.parallel_for<class test>(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<int, 1> b(1);
queue q;
q.submit([&](handler &cgh) {
accessor a{b, cgh};
cgh.single_task<class test2>([=] { a[0] = 42; });
}).wait();
host_accessor a{b};
isSuccess &= (a[0] == 42);
}

if (!isSuccess)
return -1;

return 0;
}