-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL] Don't use boost/mp11 for properties filtering #16076
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,6 +305,50 @@ struct ConditionalPropertyMetaInfo | |
: std::conditional_t<Condition, PropertyMetaInfo<PropT>, | ||
IgnoredPropertyMetaInfo> {}; | ||
|
||
template <template <typename> typename predicate, typename... property_tys> | ||
struct filter_properties_impl { | ||
static constexpr auto idx_info = []() constexpr { | ||
constexpr int N = sizeof...(property_tys); | ||
std::array<int, N> indexes{}; | ||
int num_matched = 0; | ||
int idx = 0; | ||
(((predicate<property_tys>::value ? indexes[num_matched++] = idx++ : idx++), | ||
...)); | ||
|
||
return std::pair{indexes, num_matched}; | ||
}(); | ||
|
||
// Helper to convert constexpr indices values to an std::index_sequence type. | ||
// Values -> type is the key here. | ||
template <int... Idx> | ||
static constexpr auto idx_seq(std::integer_sequence<int, Idx...>) { | ||
return std::integer_sequence<int, idx_info.first[Idx]...>{}; | ||
} | ||
|
||
using selected_idx_seq = | ||
decltype(idx_seq(std::make_integer_sequence<int, idx_info.second>{})); | ||
|
||
// Using prop_list_ty so that we don't need to explicitly spell out | ||
// `properties` template parameters' implementation-details. | ||
template <typename prop_list_ty, int... Idxs> | ||
static constexpr auto apply_impl(const prop_list_ty &props, | ||
std::integer_sequence<int, Idxs...>) { | ||
return properties{props.template get_property< | ||
typename nth_type_t<Idxs, property_tys...>::key_t>()...}; | ||
} | ||
|
||
template <typename prop_list_ty> | ||
static constexpr auto apply(const prop_list_ty &props) { | ||
return apply_impl(props, selected_idx_seq{}); | ||
} | ||
}; | ||
|
||
template <template <typename> typename predicate, typename... property_tys> | ||
constexpr auto filter_properties( | ||
const properties<properties_type_list<property_tys...>> &props) { | ||
return filter_properties_impl<predicate, property_tys...>::apply(props); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The naming scheme used in this patch does not seem to follow the surrounding code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed offline - I'm following the style in |
||
} // namespace detail | ||
} // namespace ext::oneapi::experimental | ||
} // namespace _V1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of mental association, I would add another set of parenthesis:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make a note of that and will implement in a separate PR with final touches after major refactorings are all finished.