Skip to content

Commit 51095ee

Browse files
steffenlarsenbb-sycl
authored andcommitted
[SYCL] Move host-compiler tests from in-tree LIT (intel#1240)
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 <[email protected]>
1 parent 8eeff87 commit 51095ee

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// RUN: %clangxx -fsycl -fsycl-host-compiler=cl -DDEFINE_CHECK -fsycl-host-compiler-options="-DDEFINE_CHECK /std:c++17" /Fe%t.exe %s
2+
// RUN: %CPU_RUN_PLACEHOLDER %t.exe
3+
// RUN: %GPU_RUN_PLACEHOLDER %t.exe
4+
// RUN: %ACC_RUN_PLACEHOLDER %t.exe
5+
// REQUIRES: windows
6+
//
7+
//==------- fsycl-host-compiler-win.cpp - external host compiler test ------==//
8+
//
9+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
10+
// See https://llvm.org/LICENSE.txt for license information.
11+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
12+
//
13+
//===----------------------------------------------------------------------===//
14+
//
15+
// Uses -fsycl-host-compiler=<compiler> on a simple test, requires 'cl'
16+
17+
#include <sycl/sycl.hpp>
18+
19+
#ifndef DEFINE_CHECK
20+
#error predefined macro not set
21+
#endif // DEFINE_CHECK
22+
23+
using namespace sycl;
24+
25+
int main() {
26+
int data[] = {0, 0, 0};
27+
28+
{
29+
buffer<int, 1> b(data, range<1>(3), {property::buffer::use_host_ptr()});
30+
queue q;
31+
q.submit([&](handler &cgh) {
32+
auto B = b.get_access<access::mode::write>(cgh);
33+
cgh.parallel_for<class test>(range<1>(3), [=](id<1> idx) { B[idx] = 1; });
34+
});
35+
}
36+
37+
bool isSuccess = true;
38+
39+
for (int i = 0; i < 3; i++)
40+
if (data[i] != 1)
41+
isSuccess = false;
42+
43+
if (!isSuccess)
44+
return -1;
45+
46+
return 0;
47+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// RUN: %clangxx -fsycl -fsycl-host-compiler=g++ -DDEFINE_CHECK -fsycl-host-compiler-options="-DDEFINE_CHECK -std=c++17" -o %t.out %s
2+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
3+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
4+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
5+
// REQUIRES: linux
6+
//==------- fsycl-host-compiler.cpp - external host compiler test ----------==//
7+
//
8+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9+
// See https://llvm.org/LICENSE.txt for license information.
10+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11+
//
12+
//===----------------------------------------------------------------------===//
13+
//
14+
// Uses -fsycl-host-compiler=<compiler> on a simple test, requires 'g++'
15+
16+
#include <sycl/sycl.hpp>
17+
18+
#ifndef DEFINE_CHECK
19+
#error predefined macro not set
20+
#endif // DEFINE_CHECK
21+
22+
using namespace sycl;
23+
24+
int main() {
25+
int data[] = {0, 0, 0};
26+
27+
{
28+
buffer<int, 1> b(data, range<1>(3), {property::buffer::use_host_ptr()});
29+
queue q;
30+
q.submit([&](handler &cgh) {
31+
auto B = b.get_access<access::mode::write>(cgh);
32+
cgh.parallel_for<class test>(range<1>(3), [=](id<1> idx) { B[idx] = 1; });
33+
});
34+
}
35+
36+
bool isSuccess = true;
37+
38+
for (int i = 0; i < 3; i++)
39+
if (data[i] != 1)
40+
isSuccess = false;
41+
42+
{
43+
buffer<int, 1> b(1);
44+
queue q;
45+
q.submit([&](handler &cgh) {
46+
accessor a{b, cgh};
47+
cgh.single_task<class test2>([=] { a[0] = 42; });
48+
}).wait();
49+
host_accessor a{b};
50+
isSuccess &= (a[0] == 42);
51+
}
52+
53+
if (!isSuccess)
54+
return -1;
55+
56+
return 0;
57+
}

0 commit comments

Comments
 (0)