Skip to content

Commit

Permalink
[SYCL] Use inheritance to implement oneapi properties (#16024)
Browse files Browse the repository at this point in the history
This is based on @rolandschulz 's
#13776.

The only remaining boost/mp11 usage is to sort/filter properties, I'm
going to remove that in a separate PRs.

I've also left multiple utilities (that accept variadic pack) still
using `std::tuple` as *their* implementation detail. That can be cleaned
up separately as well.

Closes #13677.
  • Loading branch information
aelovikov-intel authored Nov 13, 2024
1 parent 797177b commit 61d963b
Show file tree
Hide file tree
Showing 13 changed files with 687 additions and 653 deletions.
21 changes: 14 additions & 7 deletions sycl/include/sycl/ext/intel/esimd/memory_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,17 @@ template <typename PropertyListT> struct remove_alignment_property {
};
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...>>;
properties<oneapi::experimental::detail::properties_type_list<
alignment_key::value_t<Alignment>, LastTs...>>> {
using type =
properties<oneapi::experimental::detail::properties_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<oneapi::experimental::detail::properties_type_list<
FirstT, alignment_key::value_t<Alignment>, LastTs...>>> {
using type = properties<
oneapi::experimental::detail::properties_type_list<FirstT, LastTs...>>;
};
template <typename PropertyListT>
using remove_alignment_property_t =
Expand Down Expand Up @@ -323,8 +327,11 @@ 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<
oneapi::experimental::detail::properties_type_list<PropertyValueTs...>>>
: is_property_list<
properties<oneapi::experimental::detail::properties_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 @@ -66,7 +66,8 @@ 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>,
properties<detail::properties_type_list<ArgT...>>)
-> annotated_arg<
T, detail::merged_properties_t<old, detail::properties_t<ArgT...>>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ using PropertiesFilter =

// filter properties that are applied on annotations
template <typename... Props>
using annotation_filter = properties<
PropertiesFilter<std::tuple<Props...>, propagateToPtrAnnotation>>;
using annotation_filter =
properties<PropertiesFilter<detail::properties_type_list<Props...>,
propagateToPtrAnnotation>>;
} // namespace detail

template <typename I, typename P> struct annotationHelper {};
Expand Down Expand Up @@ -245,7 +246,8 @@ 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>,
properties<detail::properties_type_list<ArgT...>>)
-> annotated_ptr<
T, detail::merged_properties_t<old, detail::properties_t<ArgT...>>>;
#endif // __cpp_deduction_guides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(work_group_memory) work_group_memory
void __init(decoratedPtr ptr) { this->ptr = ptr; }
#endif
private:
decoratedPtr ptr;
decoratedPtr ptr = nullptr;
};
} // namespace ext::oneapi::experimental
} // namespace _V1
Expand Down
Loading

0 comments on commit 61d963b

Please sign in to comment.