Skip to content

Commit 0bb2a29

Browse files
[SYCL] Add regression test for local_accessor 3D subscript (intel/llvm-test-suite#1191)
Adds a regression test checking that the subscript operator on a 3-dimensional local_accessor compiles and runs as expected. This is related to intel#6669 Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 1cfd02e commit 0bb2a29

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
3+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
4+
5+
//==------------------ local_accessor_3d_subscript.cpp ---------------------==//
6+
//
7+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8+
// See https://llvm.org/LICENSE.txt for license information.
9+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10+
//
11+
//===----------------------------------------------------------------------===//
12+
// Tests that the subscript operator on a 3-dimensional local_accessor correctly
13+
// compiles and runs.
14+
15+
#include <iostream>
16+
#include <sycl/sycl.hpp>
17+
18+
int main() {
19+
size_t Result = 0;
20+
sycl::queue Q;
21+
{
22+
sycl::buffer<size_t, 1> Buf(&Result, 1);
23+
Q.submit([&](sycl::handler &CGH) {
24+
sycl::local_accessor<size_t, 3> LocalMem(sycl::range<3>(1, 1, 1), CGH);
25+
auto Acc = Buf.get_access(CGH);
26+
CGH.parallel_for(1, [=](sycl::item<1> It) {
27+
LocalMem[It][It][It] = 42;
28+
Acc[It] = LocalMem[It][It][It];
29+
});
30+
});
31+
}
32+
assert(Result == 42);
33+
std::cout << "success!" << std::endl;
34+
return 0;
35+
}

0 commit comments

Comments
 (0)