Skip to content

[SYCL] Rewrite properties storage #13776

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

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion sycl/include/sycl/detail/type_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace sycl {
inline namespace _V1 {
namespace detail {

template <class... T> using type_list = boost::mp11::mp_list<T...>;
template <class... T> struct type_list;

using empty_type_list = type_list<>;

Expand Down
22 changes: 12 additions & 10 deletions sycl/include/sycl/ext/intel/esimd/memory_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class properties
// Deduction guides
template <typename... PropertyValueTs>
properties(PropertyValueTs... props)
-> properties<typename sycl::ext::oneapi::experimental::detail::Sorted<
PropertyValueTs...>::type>;
-> properties<sycl::ext::oneapi::experimental::detail::sort_properties<
sycl::ext::oneapi::experimental::detail::type_list<
PropertyValueTs...>>>;
#endif

/// The 'alignment' property is used to specify the alignment of memory
Expand Down Expand Up @@ -237,14 +238,14 @@ template <typename PropertyListT> struct remove_alignment_property {
using type = PropertyListT;
};
template <size_t Alignment, typename... LastTs>
struct remove_alignment_property<
properties<std::tuple<alignment_key::value_t<Alignment>, LastTs...>>> {
using type = properties<std::tuple<LastTs...>>;
struct remove_alignment_property<properties<
sycl::detail::type_list<alignment_key::value_t<Alignment>, LastTs...>>> {
using type = properties<sycl::detail::type_list<LastTs...>>;
};
template <typename FirstT, size_t Alignment, typename... LastTs>
struct remove_alignment_property<properties<
std::tuple<FirstT, alignment_key::value_t<Alignment>, LastTs...>>> {
using type = properties<std::tuple<FirstT, LastTs...>>;
struct remove_alignment_property<properties<sycl::detail::type_list<
FirstT, alignment_key::value_t<Alignment>, LastTs...>>> {
using type = properties<sycl::detail::type_list<FirstT, LastTs...>>;
};
template <typename PropertyListT>
using remove_alignment_property_t =
Expand Down Expand Up @@ -311,8 +312,9 @@ struct property_value<__ESIMD_NS::cache_hint_L3_key,

// Declare that esimd::properties is a property_list.
template <typename... PropertyValueTs>
struct is_property_list<__ESIMD_NS::properties<std::tuple<PropertyValueTs...>>>
: is_property_list<properties<std::tuple<PropertyValueTs...>>> {};
struct is_property_list<
__ESIMD_NS::properties<detail::type_list<PropertyValueTs...>>>
: is_property_list<properties<detail::type_list<PropertyValueTs...>>> {};

namespace detail {
// We do not override the class ConflictingProperties for cache_hint properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ struct propagateToPtrAnnotation<buffer_location_key> : std::true_type {};
//
namespace detail {
template <typename... Args> struct checkValidFPGAPropertySet {
using list = std::tuple<Args...>;
using list = detail::type_list<Args...>;
static constexpr bool has_BufferLocation =
ContainsProperty<buffer_location_key, list>::value;

Expand All @@ -336,7 +336,7 @@ template <typename... Args> struct checkValidFPGAPropertySet {
};

template <typename... Args> struct checkHasConduitAndRegisterMap {
using list = std::tuple<Args...>;
using list = detail::type_list<Args...>;
static constexpr bool has_Conduit =
ContainsProperty<conduit_key, list>::value;
static constexpr bool has_RegisterMap =
Expand Down
36 changes: 10 additions & 26 deletions sycl/include/sycl/ext/intel/experimental/grf_size_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,17 @@ struct PropertyMetaInfo<
static constexpr unsigned int value = 0;
};

template <typename Properties>
struct ConflictingProperties<sycl::ext::intel::experimental::grf_size_key,
Properties>
: std::bool_constant<
ContainsProperty<
sycl::ext::intel::experimental::grf_size_automatic_key,
Properties>::value ||
ContainsProperty<sycl::detail::register_alloc_mode_key,
Properties>::value> {};

template <typename Properties>
struct ConflictingProperties<
sycl::ext::intel::experimental::grf_size_automatic_key, Properties>
: std::bool_constant<
ContainsProperty<sycl::ext::intel::experimental::grf_size_key,
Properties>::value ||
ContainsProperty<sycl::detail::register_alloc_mode_key,
Properties>::value> {};
template <>
struct ConflictingPropertiesImpl<sycl::ext::intel::experimental::grf_size_key> {
using type = type_list<sycl::ext::intel::experimental::grf_size_automatic_key,
sycl::detail::register_alloc_mode_key>;
};

template <typename Properties>
struct ConflictingProperties<sycl::detail::register_alloc_mode_key, Properties>
: std::bool_constant<
ContainsProperty<sycl::ext::intel::experimental::grf_size_key,
Properties>::value ||
ContainsProperty<
sycl::ext::intel::experimental::grf_size_automatic_key,
Properties>::value> {};
template <>
struct ConflictingPropertiesImpl<
sycl::ext::intel::experimental::grf_size_automatic_key> {
using type = type_list<sycl::detail::register_alloc_mode_key>;
};

} // namespace ext::oneapi::experimental::detail
} // namespace _V1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ annotated_arg(T, Args...)
-> annotated_arg<T, typename detail::DeducedProperties<Args...>::type>;

template <typename T, typename old, typename... ArgT>
annotated_arg(annotated_arg<T, old>, properties<std::tuple<ArgT...>>)
annotated_arg(annotated_arg<T, old>, detail::properties_t<ArgT...>)
-> annotated_arg<
T, detail::merged_properties_t<old, detail::properties_t<ArgT...>>>;

Expand Down Expand Up @@ -114,7 +114,7 @@ __SYCL_TYPE(annotated_arg) annotated_arg<T *, detail::properties_t<Props...>> {
annotated_arg &operator=(annotated_arg &) = default;

annotated_arg(T *_ptr,
const property_list_t &PropList = properties{}) noexcept
const property_list_t &PropList = property_list_t{}) noexcept
: obj(_ptr) {
(void)PropList;
}
Expand Down Expand Up @@ -250,7 +250,7 @@ __SYCL_TYPE(annotated_arg) annotated_arg<T, detail::properties_t<Props...>> {
annotated_arg &operator=(annotated_arg &) = default;

annotated_arg(const T &_obj,
const property_list_t &PropList = properties{}) noexcept
const property_list_t &PropList = property_list_t{}) noexcept
: obj(_obj) {
(void)PropList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ constexpr bool is_ann_ref_v =

template <typename... Ts>
using contains_alignment =
detail::ContainsProperty<alignment_key, std::tuple<Ts...>>;
detail::ContainsProperty<alignment_key, detail::type_list<Ts...>>;

// properties filter
template <typename property_list, template <class...> typename filter>
Expand All @@ -62,7 +62,7 @@ using PropertiesFilter =
// filter properties that are applied on annotations
template <typename... Props>
using annotation_filter = properties<
PropertiesFilter<std::tuple<Props...>, propagateToPtrAnnotation>>;
PropertiesFilter<detail::type_list<Props...>, propagateToPtrAnnotation>>;
} // namespace detail

template <typename I, typename P> struct annotationHelper {};
Expand Down Expand Up @@ -245,7 +245,7 @@ annotated_ptr(T *, Args...)
-> annotated_ptr<T, typename detail::DeducedProperties<Args...>::type>;

template <typename T, typename old, typename... ArgT>
annotated_ptr(annotated_ptr<T, old>, properties<std::tuple<ArgT...>>)
annotated_ptr(annotated_ptr<T, old>, detail::properties_t<ArgT...>)
-> annotated_ptr<
T, detail::merged_properties_t<old, detail::properties_t<ArgT...>>>;
#endif // __cpp_deduction_guides
Expand Down Expand Up @@ -303,7 +303,7 @@ __SYCL_TYPE(annotated_ptr) annotated_ptr<T, detail::properties_t<Props...>> {
annotated_ptr &operator=(const annotated_ptr &) = default;

explicit annotated_ptr(T *Ptr,
const property_list_t & = properties{}) noexcept
const property_list_t & = property_list_t{}) noexcept
: m_Ptr(Ptr) {}

// Constructs an annotated_ptr object from a raw pointer and variadic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,18 @@ struct PropertyMetaInfo<usm_kind_key::value_t<Kind>> {
static constexpr sycl::usm::alloc value = Kind;
};

template <typename PropertyListT> struct IsUsmKindDevice : std::false_type {};
template <typename... Props>
struct IsUsmKindDevice<detail::properties_t<Props...>>
: detail::ContainsProperty<std::remove_const_t<decltype(usm_kind_device)>,
std::tuple<Props...>> {};
template <typename PropertyListT>
using IsUsmKindDevice = detail::ContainsPropertyValue<
std::remove_const_t<decltype(usm_kind_device)>, PropertyListT>;

template <typename PropertyListT> struct IsUsmKindHost : std::false_type {};
template <typename... Props>
struct IsUsmKindHost<detail::properties_t<Props...>>
: detail::ContainsProperty<std::remove_const_t<decltype(usm_kind_host)>,
std::tuple<Props...>> {};

template <typename PropertyListT> struct IsUsmKindShared : std::false_type {};
template <typename... Props>
struct IsUsmKindShared<detail::properties_t<Props...>>
: detail::ContainsProperty<std::remove_const_t<decltype(usm_kind_shared)>,
std::tuple<Props...>> {};
template <typename PropertyListT>
using IsUsmKindHost =
detail::ContainsPropertyValue<std::remove_const_t<decltype(usm_kind_host)>,
PropertyListT>;

template <typename PropertyListT>
using IsUsmKindShared = detail::ContainsPropertyValue<
std::remove_const_t<decltype(usm_kind_shared)>, PropertyListT>;
} // namespace detail

} // namespace experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ std::enable_if_t<
aligned_alloc_annotated(size_t alignment, size_t numBytes,
const device &syclDevice, const context &syclContext,
sycl::usm::alloc kind,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
detail::ValidAllocPropertyList<void, propertyListA>::value;

// The input argument `propList` is useful when propertyListA contains valid
Expand Down Expand Up @@ -86,7 +86,7 @@ std::enable_if_t<
aligned_alloc_annotated(size_t alignment, size_t count,
const device &syclDevice, const context &syclContext,
sycl::usm::alloc kind,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
detail::ValidAllocPropertyList<T, propertyListA>::value;

// The input argument `propList` is useful when propertyListA contains valid
Expand Down Expand Up @@ -127,7 +127,7 @@ std::enable_if_t<
annotated_ptr<void, propertyListB>>
aligned_alloc_annotated(size_t alignment, size_t numBytes,
const queue &syclQueue, sycl::usm::alloc kind,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
return aligned_alloc_annotated(alignment, numBytes, syclQueue.get_device(),
syclQueue.get_context(), kind, propList);
}
Expand All @@ -140,7 +140,7 @@ std::enable_if_t<
annotated_ptr<T, propertyListB>>
aligned_alloc_annotated(size_t alignment, size_t count, const queue &syclQueue,
sycl::usm::alloc kind,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
return aligned_alloc_annotated<T>(alignment, count, syclQueue.get_device(),
syclQueue.get_context(), kind, propList);
}
Expand All @@ -153,7 +153,7 @@ std::enable_if_t<
annotated_ptr<void, propertyListB>>
malloc_annotated(size_t numBytes, const device &syclDevice,
const context &syclContext, sycl::usm::alloc kind,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
return aligned_alloc_annotated(0, numBytes, syclDevice, syclContext, kind,
propList);
}
Expand All @@ -166,7 +166,7 @@ std::enable_if_t<
annotated_ptr<T, propertyListB>>
malloc_annotated(size_t count, const device &syclDevice,
const context &syclContext, sycl::usm::alloc kind,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
return aligned_alloc_annotated<T>(0, count, syclDevice, syclContext, kind,
propList);
}
Expand All @@ -178,7 +178,7 @@ std::enable_if_t<
detail::CheckTAndPropLists<void, propertyListA, propertyListB>::value,
annotated_ptr<void, propertyListB>>
malloc_annotated(size_t numBytes, const queue &syclQueue, sycl::usm::alloc kind,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
return malloc_annotated(numBytes, syclQueue.get_device(),
syclQueue.get_context(), kind, propList);
}
Expand All @@ -190,7 +190,7 @@ std::enable_if_t<
detail::CheckTAndPropLists<T, propertyListA, propertyListB>::value,
annotated_ptr<T, propertyListB>>
malloc_annotated(size_t count, const queue &syclQueue, sycl::usm::alloc kind,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
return malloc_annotated<T>(count, syclQueue.get_device(),
syclQueue.get_context(), kind, propList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ template <typename propertyListA = empty_properties_t,
std::enable_if_t<
CheckDevicePtrTAndPropLists<void, propertyListA, propertyListB>::value,
annotated_ptr<void, propertyListB>>
aligned_alloc_device_annotated(size_t alignment, size_t numBytes,
const device &syclDevice,
const context &syclContext,
const propertyListA &propList = properties{}) {
aligned_alloc_device_annotated(
size_t alignment, size_t numBytes, const device &syclDevice,
const context &syclContext,
const propertyListA &propList = propertyListA{}) {
auto tmp =
aligned_alloc_annotated(alignment, numBytes, syclDevice, syclContext,
sycl::usm::alloc::device, propList);
Expand All @@ -59,10 +59,10 @@ template <typename T, typename propertyListA = empty_properties_t,
std::enable_if_t<
CheckDevicePtrTAndPropLists<T, propertyListA, propertyListB>::value,
annotated_ptr<T, propertyListB>>
aligned_alloc_device_annotated(size_t alignment, size_t count,
const device &syclDevice,
const context &syclContext,
const propertyListA &propList = properties{}) {
aligned_alloc_device_annotated(
size_t alignment, size_t count, const device &syclDevice,
const context &syclContext,
const propertyListA &propList = propertyListA{}) {
auto tmp =
aligned_alloc_annotated<T>(alignment, count, syclDevice, syclContext,
sycl::usm::alloc::device, propList);
Expand All @@ -75,9 +75,9 @@ template <typename propertyListA = empty_properties_t,
std::enable_if_t<
CheckDevicePtrTAndPropLists<void, propertyListA, propertyListB>::value,
annotated_ptr<void, propertyListB>>
aligned_alloc_device_annotated(size_t alignment, size_t numBytes,
const queue &syclQueue,
const propertyListA &propList = properties{}) {
aligned_alloc_device_annotated(
size_t alignment, size_t numBytes, const queue &syclQueue,
const propertyListA &propList = propertyListA{}) {
return aligned_alloc_device_annotated(alignment, numBytes,
syclQueue.get_device(),
syclQueue.get_context(), propList);
Expand All @@ -89,9 +89,9 @@ template <typename T, typename propertyListA = empty_properties_t,
std::enable_if_t<
CheckDevicePtrTAndPropLists<T, propertyListA, propertyListB>::value,
annotated_ptr<T, propertyListB>>
aligned_alloc_device_annotated(size_t alignment, size_t count,
const queue &syclQueue,
const propertyListA &propList = properties{}) {
aligned_alloc_device_annotated(
size_t alignment, size_t count, const queue &syclQueue,
const propertyListA &propList = propertyListA{}) {
return aligned_alloc_device_annotated<T>(alignment, count,
syclQueue.get_device(),
syclQueue.get_context(), propList);
Expand All @@ -112,7 +112,7 @@ std::enable_if_t<
annotated_ptr<void, propertyListB>>
malloc_device_annotated(size_t numBytes, const device &syclDevice,
const context &syclContext,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
return aligned_alloc_device_annotated(0, numBytes, syclDevice, syclContext,
propList);
}
Expand All @@ -125,7 +125,7 @@ std::enable_if_t<
annotated_ptr<T, propertyListB>>
malloc_device_annotated(size_t count, const device &syclDevice,
const context &syclContext,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
return aligned_alloc_device_annotated<T>(0, count, syclDevice, syclContext,
propList);
}
Expand All @@ -137,7 +137,7 @@ std::enable_if_t<
CheckDevicePtrTAndPropLists<void, propertyListA, propertyListB>::value,
annotated_ptr<void, propertyListB>>
malloc_device_annotated(size_t numBytes, const queue &syclQueue,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
return malloc_device_annotated(numBytes, syclQueue.get_device(),
syclQueue.get_context(), propList);
}
Expand All @@ -149,7 +149,7 @@ std::enable_if_t<
CheckDevicePtrTAndPropLists<T, propertyListA, propertyListB>::value,
annotated_ptr<T, propertyListB>>
malloc_device_annotated(size_t count, const queue &syclQueue,
const propertyListA &propList = properties{}) {
const propertyListA &propList = propertyListA{}) {
return malloc_device_annotated<T>(count, syclQueue.get_device(),
syclQueue.get_context(), propList);
}
Expand Down
Loading