Skip to content

[SYCL] Adds sycl::stream size functions definition for device. #8519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 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
19 changes: 19 additions & 0 deletions sycl/include/sycl/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,24 @@ class __SYCL_EXPORT __SYCL_SPECIAL_CLASS __SYCL_TYPE(stream) stream
stream(size_t BufferSize, size_t MaxStatementSize, handler &CGH,
const property_list &PropList);

#ifdef __SYCL_DEVICE_ONLY__
// We need the definitions of these functions in the header for device,
// otherwise they are not visible. Also, we cannot use `impl` because it's not
// there on the device, so we rely on GlobalBuf/GlobalFlushBuf.
size_t size() const noexcept { return GlobalBuf.size(); }

size_t get_work_item_buffer_size() const {
return GlobalFlushBuf.size() - detail::FLUSH_BUF_OFFSET_SIZE;
}

__SYCL2020_DEPRECATED(
"get_size() is deprecated since SYCL 2020. Please use size() instead.")
size_t get_size() const { return size(); }

__SYCL2020_DEPRECATED("get_max_statement_size() is deprecated since SYCL "
"2020. Please use get_work_item_buffer_size() instead.")
size_t get_max_statement_size() const { return get_work_item_buffer_size(); }
#else
size_t size() const noexcept;

size_t get_work_item_buffer_size() const;
Expand All @@ -768,6 +786,7 @@ class __SYCL_EXPORT __SYCL_SPECIAL_CLASS __SYCL_TYPE(stream) stream
__SYCL2020_DEPRECATED("get_max_statement_size() is deprecated since SYCL "
"2020. Please use get_work_item_buffer_size() instead.")
size_t get_max_statement_size() const;
#endif

size_t get_precision() const { return Precision; }

Expand Down