Skip to content

[SYCL] Add property list to stream #4898

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 8 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 9 additions & 0 deletions sycl/include/CL/sycl/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,11 @@ class __SYCL_EXPORT __SYCL_SPECIAL_CLASS stream {
// Throws exception in case of invalid input parameters
stream(size_t BufferSize, size_t MaxStatementSize, handler &CGH);

// Property-list constructor variant.
// TODO: Merge with other stream constructor and give PropList default value.
stream(size_t BufferSize, size_t MaxStatementSize, handler &CGH,
const property_list &PropList);

size_t get_size() const;

size_t get_max_statement_size() const;
Expand All @@ -764,6 +769,10 @@ class __SYCL_EXPORT __SYCL_SPECIAL_CLASS stream {

bool operator!=(const stream &LHS) const;

template <typename propertyT> bool has_property() const noexcept;

template <typename propertyT> propertyT get_property() const;

private:
#ifdef __SYCL_DEVICE_ONLY__
char padding[sizeof(std::shared_ptr<detail::stream_impl>)];
Expand Down
8 changes: 7 additions & 1 deletion sycl/source/detail/stream_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ namespace detail {

stream_impl::stream_impl(size_t BufferSize, size_t MaxStatementSize,
handler &CGH)
: BufferSize_(BufferSize), MaxStatementSize_(MaxStatementSize) {
: stream_impl(BufferSize, MaxStatementSize, {}) {
(void)CGH;
}

stream_impl::stream_impl(size_t BufferSize, size_t MaxStatementSize,
const property_list &PropList)
: BufferSize_(BufferSize), MaxStatementSize_(MaxStatementSize),
PropList_(PropList) {
// We need to store stream buffers in the scheduler because they need to be
// alive after submitting the kernel. They cannot be stored in the stream
// object because it causes loop dependency between objects and results in
Expand Down
17 changes: 16 additions & 1 deletion sycl/source/detail/stream_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <CL/sycl/buffer.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/handler.hpp>
#include <CL/sycl/property_list.hpp>
#include <CL/sycl/range.hpp>
#include <CL/sycl/stream.hpp>

Expand All @@ -23,10 +24,13 @@ namespace detail {

class __SYCL_EXPORT stream_impl {
public:
// TODO: Handler argument is not used in constructor.
// TODO: This constructor is unused.
// To be removed when API/ABI changes are allowed.
stream_impl(size_t BufferSize, size_t MaxStatementSize, handler &CGH);

stream_impl(size_t BufferSize, size_t MaxStatementSize,
const property_list &PropList);

// Method to provide an access to the global stream buffer
GlobalBufAccessorT accessGlobalBuf(handler &CGH);

Expand All @@ -44,6 +48,14 @@ class __SYCL_EXPORT stream_impl {

size_t get_max_statement_size() const;

template <typename propertyT> bool has_property() const noexcept {
return PropList_.has_property<propertyT>();
}

template <typename propertyT> propertyT get_property() const {
return PropList_.get_property<propertyT>();
}

private:
// Size of the stream buffer
size_t BufferSize_;
Expand All @@ -52,6 +64,9 @@ class __SYCL_EXPORT stream_impl {
// statement till the semicolon
unsigned MaxStatementSize_;

// Property list
property_list PropList_;

// Additinonal memory is allocated in the beginning of the stream buffer for
// 2 variables: offset in the stream buffer and offset in the flush buffer.
static const size_t OffsetSize = 2 * sizeof(unsigned);
Expand Down
25 changes: 24 additions & 1 deletion sycl/source/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include <CL/sycl/properties/all_properties.hpp>
#include <CL/sycl/stream.hpp>
#include <detail/queue_impl.hpp>
#include <detail/stream_impl.hpp>
Expand All @@ -32,8 +33,12 @@ static size_t CheckMaxStatementSize(const size_t &MaxStatementSize) {
}

stream::stream(size_t BufferSize, size_t MaxStatementSize, handler &CGH)
: stream(BufferSize, MaxStatementSize, CGH, {}) {}

stream::stream(size_t BufferSize, size_t MaxStatementSize, handler &CGH,
const property_list &PropList)
: impl(std::make_shared<detail::stream_impl>(
BufferSize, CheckMaxStatementSize(MaxStatementSize), CGH)),
BufferSize, CheckMaxStatementSize(MaxStatementSize), PropList)),
GlobalBuf(impl->accessGlobalBuf(CGH)),
GlobalOffset(impl->accessGlobalOffset(CGH)),
// Allocate the flush buffer, which contains space for each work item
Expand All @@ -59,6 +64,24 @@ bool stream::operator==(const stream &RHS) const { return (impl == RHS.impl); }

bool stream::operator!=(const stream &RHS) const { return !(impl == RHS.impl); }

#define __SYCL_PARAM_TRAITS_SPEC(param_type) \
template <> \
__SYCL_EXPORT bool stream::has_property<param_type>() const noexcept { \
return impl->has_property<param_type>(); \
}
#include <CL/sycl/detail/properties_traits.def>

#undef __SYCL_PARAM_TRAITS_SPEC

#define __SYCL_PARAM_TRAITS_SPEC(param_type) \
template <> \
__SYCL_EXPORT param_type stream::get_property<param_type>() const { \
return impl->get_property<param_type>(); \
}
#include <CL/sycl/detail/properties_traits.def>

#undef __SYCL_PARAM_TRAITS_SPEC

} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)

36 changes: 32 additions & 4 deletions sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -3787,7 +3787,9 @@ _ZN2cl4sycl6detail11stream_impl15accessGlobalBufERNS0_7handlerE
_ZN2cl4sycl6detail11stream_impl18accessGlobalOffsetERNS0_7handlerE
_ZN2cl4sycl6detail11stream_impl20accessGlobalFlushBufERNS0_7handlerE
_ZN2cl4sycl6detail11stream_impl5flushEv
_ZN2cl4sycl6detail11stream_implC1EmmRKNS0_13property_listE
_ZN2cl4sycl6detail11stream_implC1EmmRNS0_7handlerE
_ZN2cl4sycl6detail11stream_implC2EmmRKNS0_13property_listE
_ZN2cl4sycl6detail11stream_implC2EmmRNS0_7handlerE
_ZN2cl4sycl6detail12compile_implERKNS0_13kernel_bundleILNS0_12bundle_stateE0EEERKSt6vectorINS0_6deviceESaIS8_EERKNS0_13property_listE
_ZN2cl4sycl6detail12isOutOfRangeENS0_3vecIiLi4EEENS0_15addressing_modeENS0_5rangeILi3EEE
Expand Down Expand Up @@ -3894,7 +3896,9 @@ _ZN2cl4sycl6opencl12make_contextEm
_ZN2cl4sycl6opencl12make_programERKNS0_7contextEm
_ZN2cl4sycl6opencl13make_platformEm
_ZN2cl4sycl6streamC1EmmRNS0_7handlerE
_ZN2cl4sycl6streamC1EmmRNS0_7handlerERKNS0_13property_listE
_ZN2cl4sycl6streamC2EmmRNS0_7handlerE
_ZN2cl4sycl6streamC2EmmRNS0_7handlerERKNS0_13property_listE
_ZN2cl4sycl7contextC1EP11_cl_contextSt8functionIFvNS0_14exception_listEEE
_ZN2cl4sycl7contextC1ERKNS0_13property_listE
_ZN2cl4sycl7contextC1ERKNS0_6deviceERKNS0_13property_listE
Expand Down Expand Up @@ -4109,6 +4113,10 @@ _ZNK2cl4sycl6device3hasENS0_6aspectE
_ZNK2cl4sycl6device6is_cpuEv
_ZNK2cl4sycl6device6is_gpuEv
_ZNK2cl4sycl6device7is_hostEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE131072EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE131073EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE131074EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE131075EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE16648EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE16649EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE16650EEENS3_12param_traitsIS4_XT_EE11return_typeEv
Expand Down Expand Up @@ -4237,6 +4245,30 @@ _ZNK2cl4sycl6kernel8get_infoILNS0_4info6kernelE4498EEENS3_12param_traitsIS4_XT_E
_ZNK2cl4sycl6kernel8get_infoILNS0_4info6kernelE4499EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6kernel8get_infoILNS0_4info6kernelE4500EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6kernel8get_infoILNS0_4info6kernelE4501EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6stream12get_propertyINS0_3ext6oneapi8property6buffer22use_pinned_host_memoryEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property5image12use_host_ptrEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property5image13context_boundEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property5image9use_mutexEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property5queue8in_orderEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property6buffer12use_host_ptrEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property6buffer13context_boundEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property6buffer9use_mutexEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property6noinitEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property7context4cuda19use_primary_contextEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property7no_initEEET_v
_ZNK2cl4sycl6stream12get_propertyINS0_8property9reduction22initialize_to_identityEEET_v
_ZNK2cl4sycl6stream12has_propertyINS0_3ext6oneapi8property6buffer22use_pinned_host_memoryEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property5image12use_host_ptrEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property5image13context_boundEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property5image9use_mutexEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property5queue8in_orderEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property6buffer12use_host_ptrEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property6buffer13context_boundEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property6buffer9use_mutexEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property6noinitEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property7context4cuda19use_primary_contextEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property7no_initEEEbv
_ZNK2cl4sycl6stream12has_propertyINS0_8property9reduction22initialize_to_identityEEEbv
_ZNK2cl4sycl6stream22get_max_statement_sizeEv
_ZNK2cl4sycl6stream8get_sizeEv
_ZNK2cl4sycl6streameqERKS1_
Expand Down Expand Up @@ -4371,7 +4403,3 @@ _ZNK2cl4sycl9exception8categoryEv
_ZNK2cl4sycl9kernel_id8get_nameEv
__sycl_register_lib
__sycl_unregister_lib
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE131072EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE131075EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE131074EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE131073EEENS3_12param_traitsIS4_XT_EE11return_typeEv
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The symbol-checker moved these further up. They have not been removed.

Loading