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

[SYCL] Adds tests for stream size functions within kernel code for device. #1629

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions SYCL/Basic/stream/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,37 @@ int main() {
context Context = Queue.get_context();

// Check constructor and getters
Queue.submit([&](handler &CGH) {
stream Out(1024, 80, CGH,
property_list{property::buffer::context_bound{Context}});
assert(Out.size() == 1024);
assert(Out.get_work_item_buffer_size() == 80);
assert(Out.has_property<property::buffer::context_bound>());
assert(!Out.has_property<property::queue::in_order>());
assert(
Out.get_property<property::buffer::context_bound>().get_context() ==
Context);

CGH.single_task<class DummyTask1>([=]() {});
});
size_t sizeInKernel = 0;
size_t workItemBufferSizeInKernel = 0;
{
sycl::buffer<size_t> bufSize(&sizeInKernel, 1);
sycl::buffer<size_t> bufWorkItemBufferSize(&workItemBufferSizeInKernel,
1);

// Check constructor and getters
Queue.submit([&](handler &CGH) {
stream Out(1024, 80, CGH,
property_list{property::buffer::context_bound{Context}});
assert(Out.size() == 1024);
assert(Out.get_work_item_buffer_size() == 80);
assert(Out.has_property<property::buffer::context_bound>());
assert(!Out.has_property<property::queue::in_order>());
assert(
Out.get_property<property::buffer::context_bound>().get_context() ==
Context);

sycl::accessor accSize(bufSize, CGH, sycl::write_only);
sycl::accessor accWorkItemBufferSize(bufWorkItemBufferSize, CGH,
sycl::write_only);

CGH.single_task<class DummyTask1>([=]() {
accSize[0] = Out.size();
accWorkItemBufferSize[0] = Out.get_work_item_buffer_size();
});
});
}
assert(sizeInKernel == 1024);
assert(workItemBufferSizeInKernel == 80);

// Check common reference semantics
std::hash<stream> Hasher;
Expand Down