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

Commit a45a7c5

Browse files
authored
[SYCL] Adds tests for stream size functions within kernel code for device. (#1629)
Checks that stream size functions within kernels running on device return the expected result. --------- Signed-off-by: Maronas, Marcos <[email protected]>
1 parent 0e5799c commit a45a7c5

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

SYCL/Basic/stream/stream.cpp

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,37 @@ int main() {
2424
context Context = Queue.get_context();
2525

2626
// Check constructor and getters
27-
Queue.submit([&](handler &CGH) {
28-
stream Out(1024, 80, CGH,
29-
property_list{property::buffer::context_bound{Context}});
30-
assert(Out.size() == 1024);
31-
assert(Out.get_work_item_buffer_size() == 80);
32-
assert(Out.has_property<property::buffer::context_bound>());
33-
assert(!Out.has_property<property::queue::in_order>());
34-
assert(
35-
Out.get_property<property::buffer::context_bound>().get_context() ==
36-
Context);
37-
38-
CGH.single_task<class DummyTask1>([=]() {});
39-
});
27+
size_t sizeInKernel = 0;
28+
size_t workItemBufferSizeInKernel = 0;
29+
{
30+
sycl::buffer<size_t> bufSize(&sizeInKernel, 1);
31+
sycl::buffer<size_t> bufWorkItemBufferSize(&workItemBufferSizeInKernel,
32+
1);
33+
34+
// Check constructor and getters
35+
Queue.submit([&](handler &CGH) {
36+
stream Out(1024, 80, CGH,
37+
property_list{property::buffer::context_bound{Context}});
38+
assert(Out.size() == 1024);
39+
assert(Out.get_work_item_buffer_size() == 80);
40+
assert(Out.has_property<property::buffer::context_bound>());
41+
assert(!Out.has_property<property::queue::in_order>());
42+
assert(
43+
Out.get_property<property::buffer::context_bound>().get_context() ==
44+
Context);
45+
46+
sycl::accessor accSize(bufSize, CGH, sycl::write_only);
47+
sycl::accessor accWorkItemBufferSize(bufWorkItemBufferSize, CGH,
48+
sycl::write_only);
49+
50+
CGH.single_task<class DummyTask1>([=]() {
51+
accSize[0] = Out.size();
52+
accWorkItemBufferSize[0] = Out.get_work_item_buffer_size();
53+
});
54+
});
55+
}
56+
assert(sizeInKernel == 1024);
57+
assert(workItemBufferSizeInKernel == 80);
4058

4159
// Check common reference semantics
4260
std::hash<stream> Hasher;

0 commit comments

Comments
 (0)