Skip to content

Commit 55e3001

Browse files
committed
Add conflicting property checking infrastructure
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent f362bc9 commit 55e3001

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed

sycl/include/sycl/ext/intel/experimental/grf_size_properties.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ struct PropertyMetaInfo<
7272
static constexpr const char *name = "sycl-grf-size";
7373
static constexpr unsigned int value = 0;
7474
};
75+
76+
template <typename Properties>
77+
struct ConflictingProperties<sycl::ext::intel::experimental::grf_size_key,
78+
Properties>
79+
: ContainsProperty<sycl::ext::intel::experimental::grf_size_automatic_key,
80+
Properties> {};
81+
82+
template <typename Properties>
83+
struct ConflictingProperties<
84+
sycl::ext::intel::experimental::grf_size_automatic_key, Properties>
85+
: ContainsProperty<sycl::ext::intel::experimental::grf_size_key,
86+
Properties> {};
87+
7588
} // namespace detail
7689
} // namespace ext::oneapi::experimental
7790
} // __SYCL_INLINE_VER_NAMESPACE(_V1)

sycl/include/sycl/ext/oneapi/properties/properties.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ template <typename PropertiesT> class properties {
131131
"Properties in property list are not sorted.");
132132
static_assert(detail::SortedAllUnique<PropertiesT>::value,
133133
"Duplicate properties in property list.");
134+
static_assert(detail::NoConflictingProperties<PropertiesT>::value,
135+
"Conflicting properties in property list.");
134136

135137
public:
136138
template <typename... PropertyValueTs>

sycl/include/sycl/ext/oneapi/properties/property_utils.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,37 @@ struct SizeListToStrHelper<SizeList<>, CharList<>> : CharsToStr<> {};
305305
template <size_t... Sizes>
306306
struct SizeListToStr : SizeListToStrHelper<SizeList<Sizes...>, CharList<>> {};
307307

308+
//******************************************************************************
309+
// Property mutual exclusivity
310+
//******************************************************************************
311+
312+
// Specializations of the following trait should not consider itself a
313+
// conflicting property.
314+
template <typename PropKey, typename Properties>
315+
struct ConflictingProperties : std::false_type {};
316+
317+
template <typename Properties, typename T>
318+
struct NoConflictingPropertiesHelper {};
319+
320+
template <typename Properties, typename... Ts>
321+
struct NoConflictingPropertiesHelper<Properties, std::tuple<Ts...>>
322+
: std::true_type {};
323+
324+
template <typename Properties, typename T, typename... Ts>
325+
struct NoConflictingPropertiesHelper<Properties, std::tuple<T, Ts...>>
326+
: NoConflictingPropertiesHelper<Properties, std::tuple<Ts...>> {};
327+
328+
template <typename Properties, typename... Rest, typename PropT,
329+
typename... PropValuesTs>
330+
struct NoConflictingPropertiesHelper<
331+
Properties, std::tuple<property_value<PropT, PropValuesTs...>, Rest...>>
332+
: std::conditional_t<
333+
ConflictingProperties<PropT, Properties>::value, std::false_type,
334+
NoConflictingPropertiesHelper<Properties, std::tuple<Rest...>>> {};
335+
template <typename PropertiesT>
336+
struct NoConflictingProperties
337+
: NoConflictingPropertiesHelper<PropertiesT, PropertiesT> {};
338+
308339
} // namespace detail
309340
} // namespace ext::oneapi::experimental
310341
} // __SYCL_INLINE_VER_NAMESPACE(_V1)

sycl/test/extensions/properties/mock_compile_time_properties.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ template <> struct IsCompileTimeProperty<boo_key> : std::true_type {};
134134
template <> struct IsRuntimeProperty<foo_key> : std::true_type {};
135135
template <> struct IsRuntimeProperty<foz_key> : std::true_type {};
136136
template <> struct IsRuntimeProperty<fir_key> : std::true_type {};
137+
138+
template <typename Properties>
139+
struct ConflictingProperties<boo_key, Properties>
140+
: ContainsProperty<fir_key, Properties> {};
141+
142+
template <typename Properties>
143+
struct ConflictingProperties<fir_key, Properties>
144+
: ContainsProperty<boo_key, Properties> {};
145+
137146
} // namespace detail
138147
} // namespace experimental
139148
} // namespace oneapi

sycl/test/extensions/properties/properties_ctor_negative.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,15 @@ int main() {
2020
auto InvalidPropertyList4 = sycl::ext::oneapi::experimental::properties(
2121
sycl::ext::oneapi::experimental::bar,
2222
sycl::ext::oneapi::experimental::bar);
23+
// expected-error-re@sycl/ext/oneapi/properties/properties.hpp:* {{static assertion failed due to requirement {{.+}}: Conflicting properties in property list.}}
24+
auto InvalidPropertyList5 = sycl::ext::oneapi::experimental::properties(
25+
sycl::ext::oneapi::experimental::boo<int>,
26+
sycl::ext::oneapi::experimental::fir(3.14, false));
27+
// expected-error-re@sycl/ext/oneapi/properties/properties.hpp:* {{static assertion failed due to requirement {{.+}}: Conflicting properties in property list.}}
28+
auto InvalidPropertyList6 = sycl::ext::oneapi::experimental::properties(
29+
sycl::ext::oneapi::experimental::foo{0},
30+
sycl::ext::oneapi::experimental::boo<int>,
31+
sycl::ext::oneapi::experimental::bar,
32+
sycl::ext::oneapi::experimental::fir(3.14, false));
2333
return 0;
2434
}

0 commit comments

Comments
 (0)