11 #include <sycl/detail/boost/mp11/algorithm.hpp>
12 #include <sycl/detail/boost/mp11/detail/mp_list.hpp>
13 #include <sycl/detail/boost/mp11/detail/mp_rename.hpp>
14 #include <sycl/detail/boost/mp11/integral.hpp>
20 #include <type_traits>
24 inline namespace _V1 {
25 namespace ext::oneapi::experimental {
28 template <
typename PropertyT,
typename... Ts>
struct property_value;
37 template <
typename T>
struct IsTuple : std::false_type {};
38 template <
typename... Ts>
struct IsTuple<
std::tuple<Ts...>> : std::true_type {};
41 template <
typename... Ts>
42 using GetFirstType =
typename std::tuple_element<0, std::tuple<Ts...>>::type;
46 template <
typename T,
typename... Ts>
48 using type = std::tuple<T, Ts...>;
52 template <
typename T,
typename U =
int>
struct HasValue : std::false_type {};
54 struct HasValue<T, decltype((void)T::value, 0)> : std::true_type {};
62 template <
typename PropertyT>
81 template <
typename... Ts>
83 template <
typename T,
typename... Ts>
85 : std::conditional_t<IsPropertyValue<T>::value,
86 AllPropertyValues<std::tuple<Ts...>>,
95 template <
typename T1,
bool ShouldSplit>
struct HeadSplit {};
96 template <
typename T,
typename... Ts>
99 using ttype = std::tuple<Ts...>;
118 template <
typename T1,
typename T2>
122 template <
typename... Ts>
struct Sorted {
124 "Unrecognized property in property list.");
125 using properties = sycl::detail::boost::mp11::mp_list<Ts...>;
127 sycl::detail::boost::mp11::mp_sort_q<properties, SortByPropertyId>;
129 sycl::detail::boost::mp11::mp_rename<sortedProperties, std::tuple>;
134 template <
typename... Ts>
136 template <
typename T>
struct IsSorted<
std::tuple<T>> : std::true_type {};
137 template <
typename L,
typename R,
typename... Rest>
139 : std::conditional_t<PropertyID<L>::value <= PropertyID<R>::value,
140 IsSorted<std::tuple<R, Rest...>>, std::false_type> {};
143 template <typename T> struct SortedAllUnique {};
144 template <typename... Ts>
145 struct SortedAllUnique<std::tuple<Ts...>> : std::true_type {};
146 template <typename T> struct SortedAllUnique<std::tuple<T>> : std::true_type {};
147 template <typename L, typename R, typename... Rest>
148 struct SortedAllUnique<std::tuple<L, R, Rest...>>
149 : std::conditional_t<PropertyID<L>::value != PropertyID<R>::value,
150 SortedAllUnique<std::tuple<R, Rest...>>,
160 template <typename LHSPropertyT, typename RHSPropertyT> struct MergeProperties;
162 template <> struct MergeProperties<std::tuple<>, std::tuple<>> {
163 using type = std::tuple<>;
166 template <typename... LHSPropertyTs>
167 struct MergeProperties<std::tuple<LHSPropertyTs...>, std::tuple<>> {
168 using type = std::tuple<LHSPropertyTs...>;
171 template <typename... RHSPropertyTs>
172 struct MergeProperties<std::tuple<>, std::tuple<RHSPropertyTs...>> {
173 using type = std::tuple<RHSPropertyTs...>;
177 template <typename PropertyT, typename... LHSPropertyTs,
178 typename... RHSPropertyTs>
179 struct MergeProperties<std::tuple<PropertyT, LHSPropertyTs...>,
180 std::tuple<PropertyT, RHSPropertyTs...>> {
182 typename MergeProperties<std::tuple<LHSPropertyTs...>,
183 std::tuple<RHSPropertyTs...>>::type;
184 using type = typename PrependTuple<PropertyT, merge_tails>::type;
187 template <typename... LHSPropertyTs, typename... RHSPropertyTs>
188 struct MergeProperties<std::tuple<LHSPropertyTs...>,
189 std::tuple<RHSPropertyTs...>> {
190 using l_head = GetFirstType<LHSPropertyTs...>;
191 using r_head = GetFirstType<RHSPropertyTs...>;
193 PropertyID<l_head>::value != PropertyID<r_head>::value,
194 "Failed to merge property lists due to conflicting properties.");
195 static constexpr bool left_has_min =
196 PropertyID<l_head>::value < PropertyID<r_head>::value;
197 using l_split = HeadSplit<std::tuple<LHSPropertyTs...>, left_has_min>;
198 using r_split = HeadSplit<std::tuple<RHSPropertyTs...>, !left_has_min>;
199 using min = typename SelectNonVoid<typename l_split::htype,
200 typename r_split::htype>::type;
201 using merge_tails = typename MergeProperties<typename l_split::ttype,
202 typename r_split::ttype>::type;
203 using type = typename PrependTuple<min, merge_tails>::type;
211 template <size_t... Sizes> struct SizeList {};
212 template <char... Sizes> struct CharList {};
215 template <char... Chars> struct CharsToStr {
216 static constexpr const char value[] = {Chars..., '\0'};
223 template <typename List, typename ParsedList, char... Chars>
224 struct SizeListToStrHelper;
237 template <size_t Value, size_t... Values, char... ParsedChars, char... Chars>
238 struct SizeListToStrHelper<SizeList<Value, Values...>, CharList<ParsedChars...>,
240 : SizeListToStrHelper<SizeList<Value / 10, Values...>,
241 CharList<ParsedChars...>, '0' + (Value % 10),
254 template <size_t... Values, char... ParsedChars, char... Chars>
255 struct SizeListToStrHelper<SizeList<0, Values...>, CharList<ParsedChars...>,
257 : SizeListToStrHelper<SizeList<Values...>,
258 CharList<ParsedChars..., Chars..., ','>> {};
270 template <size_t... Values, char... ParsedChars>
271 struct SizeListToStrHelper<SizeList<0, Values...>, CharList<ParsedChars...>>
272 : SizeListToStrHelper<SizeList<Values...>,
273 CharList<ParsedChars..., '0', ','>> {};
287 template <char... ParsedChars, char... Chars>
288 struct SizeListToStrHelper<SizeList<0>, CharList<ParsedChars...>, Chars...>
289 : CharsToStr<ParsedChars..., Chars...> {};
301 template <char... ParsedChars>
302 struct SizeListToStrHelper<SizeList<0>, CharList<ParsedChars...>>
303 : CharsToStr<ParsedChars..., '0'> {};
308 struct SizeListToStrHelper<SizeList<>, CharList<>> : CharsToStr<> {};
311 template <size_t... Sizes>
312 struct SizeListToStr : SizeListToStrHelper<SizeList<Sizes...>, CharList<>> {};
320 template <typename PropKey, typename Properties>
321 struct ConflictingProperties : std::false_type {};
323 template <typename Properties, typename T>
324 struct NoConflictingPropertiesHelper {};
326 template <typename Properties, typename... Ts>
327 struct NoConflictingPropertiesHelper<Properties, std::tuple<Ts...>>
330 template <typename Properties, typename T, typename... Ts>
331 struct NoConflictingPropertiesHelper<Properties, std::tuple<T, Ts...>>
332 : NoConflictingPropertiesHelper<Properties, std::tuple<Ts...>> {};
334 template <typename Properties, typename... Rest, typename PropT,
335 typename... PropValuesTs>
336 struct NoConflictingPropertiesHelper<
337 Properties, std::tuple<property_value<PropT, PropValuesTs...>, Rest...>>
338 : std::conditional_t<
339 ConflictingProperties<PropT, Properties>::value, std::false_type,
340 NoConflictingPropertiesHelper<Properties, std::tuple<Rest...>>> {};
341 template <typename PropertiesT>
342 struct NoConflictingProperties
343 : NoConflictingPropertiesHelper<PropertiesT, PropertiesT> {};
351 struct IgnoredPropertyMetaInfo {
352 static constexpr const char *name = "";
353 static constexpr std::nullptr_t value = nullptr;
358 template <typename PropT, bool Condition>
359 struct ConditionalPropertyMetaInfo
360 : std::conditional_t<Condition, PropertyMetaInfo<PropT>,
361 IgnoredPropertyMetaInfo> {};
sycl::ext::oneapi::experimental::property_value< PropertyT, Ts... > property_value
typename std::tuple_element< 0, std::tuple< Ts... > >::type GetFirstType
std::tuple< Ts... > ttype
std::tuple< Ts... > ttype
static constexpr bool value
static constexpr bool value
std::tuple< T, Ts... > type
sycl::detail::boost::mp11::mp_bool<(PropertyID< T1 >::value< PropertyID< T2 >::value)> fn
sycl::detail::boost::mp11::mp_rename< sortedProperties, std::tuple > type
sycl::detail::boost::mp11::mp_list< Ts... > properties
sycl::detail::boost::mp11::mp_sort_q< properties, SortByPropertyId > sortedProperties