Skip to content

Commit e419f0d

Browse files
committed
Add test for static device global
Make sure that static device globals work.
1 parent 8106a51 commit e419f0d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %{build} -o %t.out
2+
// RUN: %{run} %t.out
3+
//
4+
// The OpenCL GPU backends do not currently support device_global backend
5+
// calls.
6+
// UNSUPPORTED: opencl && gpu
7+
//
8+
// Tests basic device_global access through device kernels.
9+
10+
#include "common.hpp"
11+
12+
static device_global<int[4], TestProperties> DeviceGlobalVar;
13+
14+
int main() {
15+
queue Q;
16+
17+
Q.single_task([=]() { DeviceGlobalVar.get()[0] = 42; });
18+
// Make sure that the write happens before subsequent read
19+
Q.wait();
20+
21+
int OutVal = 0;
22+
{
23+
buffer<int, 1> OutBuf(&OutVal, 1);
24+
Q.submit([&](handler &CGH) {
25+
auto OutAcc = OutBuf.get_access<access::mode::write>(CGH);
26+
CGH.single_task([=]() { OutAcc[0] = DeviceGlobalVar.get()[0]; });
27+
});
28+
}
29+
assert(OutVal == 42 && "Read value does not match.");
30+
return 0;
31+
}
32+

0 commit comments

Comments
 (0)