Skip to content

Commit aba998f

Browse files
authored
[SYCL][E2E] Add SPIR-V fat object smoke test (#9990)
Add a test for the most basic use case to make sure we don't break anything. Signed-off-by: Sarnie, Nick <[email protected]>
1 parent aa5d3f1 commit aba998f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// UNSUPPORTED: cuda || hip
2+
// RUN: clang++ -fsycl -fsycl-device-obj=spirv -c -o %t.o %s
3+
// RUN: clang++ -fsycl -o %t.out %t.o
4+
// RUN: %{run} %t.out
5+
6+
// This test verifies SPIR-V based fat objects.
7+
8+
#include <sycl/sycl.hpp>
9+
10+
int main() {
11+
sycl::buffer<size_t, 1> Buffer(4);
12+
13+
sycl::queue Queue;
14+
15+
sycl::range<1> NumOfWorkItems{Buffer.size()};
16+
17+
Queue.submit([&](sycl::handler &cgh) {
18+
sycl::accessor Accessor{Buffer, cgh, sycl::write_only};
19+
cgh.parallel_for<class FillBuffer>(NumOfWorkItems, [=](sycl::id<1> WIid) {
20+
Accessor[WIid] = WIid.get(0);
21+
});
22+
});
23+
24+
sycl::host_accessor HostAccessor{Buffer, sycl::read_only};
25+
26+
bool MismatchFound = false;
27+
for (size_t I = 0; I < Buffer.size(); ++I) {
28+
if (HostAccessor[I] != I) {
29+
std::cout << "The result is incorrect for element: " << I
30+
<< " , expected: " << I << " , got: " << HostAccessor[I]
31+
<< std::endl;
32+
MismatchFound = true;
33+
}
34+
}
35+
36+
return MismatchFound;
37+
}

0 commit comments

Comments
 (0)