@@ -32,6 +32,20 @@ struct initialize_to_identity_key
3232};
3333inline constexpr initialize_to_identity_key::value_t initialize_to_identity;
3434
35+ namespace detail {
36+ struct reduction_property_check_anchor {};
37+ } // namespace detail
38+
39+ template <>
40+ struct is_property_key_of <deterministic_key,
41+ detail::reduction_property_check_anchor>
42+ : std::true_type {};
43+
44+ template <>
45+ struct is_property_key_of <initialize_to_identity_key,
46+ detail::reduction_property_check_anchor>
47+ : std::true_type {};
48+
3549} // namespace experimental
3650} // namespace oneapi
3751} // namespace ext
@@ -83,9 +97,17 @@ template <typename BinaryOperation>
8397struct IsDeterministicOperator <DeterministicOperatorWrapper<BinaryOperation>>
8498 : std::true_type {};
8599
100+ template <typename PropertyList>
101+ inline constexpr bool is_valid_reduction_prop_list =
102+ ext::oneapi::experimental::detail::all_are_properties_of_v<
103+ ext::oneapi::experimental::detail::reduction_property_check_anchor,
104+ PropertyList>;
105+
86106} // namespace detail
87107
88- template <typename BufferT, typename BinaryOperation, typename PropertyList>
108+ template <typename BufferT, typename BinaryOperation, typename PropertyList,
109+ typename = std::enable_if_t <
110+ detail::is_valid_reduction_prop_list<PropertyList>>>
89111auto reduction (BufferT vars, handler &cgh, BinaryOperation combiner,
90112 PropertyList properties) {
91113 detail::CheckReductionIdentity<typename BufferT::value_type, BinaryOperation>(
@@ -95,16 +117,20 @@ auto reduction(BufferT vars, handler &cgh, BinaryOperation combiner,
95117 return reduction (vars, cgh, WrappedOp, RuntimeProps);
96118}
97119
98- template <typename T, typename BinaryOperation, typename PropertyList>
120+ template <typename T, typename BinaryOperation, typename PropertyList,
121+ typename = std::enable_if_t <
122+ detail::is_valid_reduction_prop_list<PropertyList>>>
99123auto reduction (T *var, BinaryOperation combiner, PropertyList properties) {
100124 detail::CheckReductionIdentity<T, BinaryOperation>(properties);
101125 auto WrappedOp = detail::WrapOp (combiner, properties);
102126 auto RuntimeProps = detail::GetReductionPropertyList (properties);
103127 return reduction (var, WrappedOp, RuntimeProps);
104128}
105129
106- template <typename T, size_t Extent, typename BinaryOperation,
107- typename PropertyList>
130+ template <
131+ typename T, size_t Extent, typename BinaryOperation, typename PropertyList,
132+ typename =
133+ std::enable_if_t <detail::is_valid_reduction_prop_list<PropertyList>>>
108134auto reduction (span<T, Extent> vars, BinaryOperation combiner,
109135 PropertyList properties) {
110136 detail::CheckReductionIdentity<T, BinaryOperation>(properties);
@@ -113,7 +139,9 @@ auto reduction(span<T, Extent> vars, BinaryOperation combiner,
113139 return reduction (vars, WrappedOp, RuntimeProps);
114140}
115141
116- template <typename BufferT, typename BinaryOperation, typename PropertyList>
142+ template <typename BufferT, typename BinaryOperation, typename PropertyList,
143+ typename = std::enable_if_t <
144+ detail::is_valid_reduction_prop_list<PropertyList>>>
117145auto reduction (BufferT vars, handler &cgh,
118146 const typename BufferT::value_type &identity,
119147 BinaryOperation combiner, PropertyList properties) {
@@ -122,16 +150,20 @@ auto reduction(BufferT vars, handler &cgh,
122150 return reduction (vars, cgh, identity, WrappedOp, RuntimeProps);
123151}
124152
125- template <typename T, typename BinaryOperation, typename PropertyList>
153+ template <typename T, typename BinaryOperation, typename PropertyList,
154+ typename = std::enable_if_t <
155+ detail::is_valid_reduction_prop_list<PropertyList>>>
126156auto reduction (T *var, const T &identity, BinaryOperation combiner,
127157 PropertyList properties) {
128158 auto WrappedOp = detail::WrapOp (combiner, properties);
129159 auto RuntimeProps = detail::GetReductionPropertyList (properties);
130160 return reduction (var, identity, WrappedOp, RuntimeProps);
131161}
132162
133- template <typename T, size_t Extent, typename BinaryOperation,
134- typename PropertyList>
163+ template <
164+ typename T, size_t Extent, typename BinaryOperation, typename PropertyList,
165+ typename =
166+ std::enable_if_t <detail::is_valid_reduction_prop_list<PropertyList>>>
135167auto reduction (span<T, Extent> vars, const T &identity,
136168 BinaryOperation combiner, PropertyList properties) {
137169 auto WrappedOp = detail::WrapOp (combiner, properties);
0 commit comments