Skip to content

Commit 1b7c057

Browse files
[NFC][SYCL] Refactor all_props_are_keys_of
First, rename it, because it's just the accident that all its current users only supply runtime properties that just happen to be property keys in addition to being property values. Second, use C++17.
1 parent 42e63c1 commit 1b7c057

File tree

2 files changed

+18
-51
lines changed

2 files changed

+18
-51
lines changed

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

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -312,38 +312,15 @@ constexpr auto get_property_or(default_t value) {
312312
return value;
313313
}
314314

315-
// helper: check_all_props_are_keys_of
316-
template <typename SyclT> constexpr bool check_all_props_are_keys_of() {
317-
return true;
318-
}
319-
320-
template <typename SyclT, typename FirstProp, typename... RestProps>
321-
constexpr bool check_all_props_are_keys_of() {
322-
return ext::oneapi::experimental::is_property_key_of<FirstProp,
323-
SyclT>::value &&
324-
check_all_props_are_keys_of<SyclT, RestProps...>();
325-
}
326-
327-
// all_props_are_keys_of
328-
template <typename SyclT, typename PropertiesT>
329-
struct all_props_are_keys_of : std::false_type {};
330-
331-
template <typename SyclT>
332-
struct all_props_are_keys_of<SyclT,
333-
ext::oneapi::experimental::empty_properties_t>
334-
: std::true_type {};
335-
336-
template <typename SyclT, typename PropT>
337-
struct all_props_are_keys_of<
338-
SyclT, ext::oneapi::experimental::detail::properties_t<PropT>>
339-
: std::bool_constant<
340-
ext::oneapi::experimental::is_property_key_of<PropT, SyclT>::value> {
341-
};
342-
315+
template <typename SyclT, typename PropListT>
316+
struct all_are_properties_of : std::false_type /* not a properties list */ {};
343317
template <typename SyclT, typename... Props>
344-
struct all_props_are_keys_of<
345-
SyclT, ext::oneapi::experimental::detail::properties_t<Props...>>
346-
: std::bool_constant<check_all_props_are_keys_of<SyclT, Props...>()> {};
318+
struct all_are_properties_of<SyclT, properties_t<Props...>>
319+
: std::bool_constant<((is_property_value_of<Props, SyclT>::value && ...))> {
320+
};
321+
template <typename SyclT, typename PropListT>
322+
inline constexpr bool all_are_properties_of_v =
323+
all_are_properties_of<SyclT, PropListT>::value;
347324

348325
} // namespace detail
349326
} // namespace ext::oneapi::experimental

sycl/include/sycl/kernel_bundle.hpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,12 +1058,9 @@ build_from_source(kernel_bundle<bundle_state::ext_oneapi_source> &SourceKB,
10581058
/////////////////////////
10591059
// syclex::create_kernel_bundle_from_source
10601060
/////////////////////////
1061-
template <
1062-
typename PropertyListT = empty_properties_t,
1063-
typename = std::enable_if_t<
1064-
is_property_list_v<PropertyListT> &&
1065-
detail::all_props_are_keys_of<detail::create_bundle_from_source_props,
1066-
PropertyListT>::value>>
1061+
template <typename PropertyListT = empty_properties_t,
1062+
typename = std::enable_if_t<detail::all_are_properties_of_v<
1063+
detail::create_bundle_from_source_props, PropertyListT>>>
10671064
kernel_bundle<bundle_state::ext_oneapi_source> create_kernel_bundle_from_source(
10681065
const context &SyclContext, source_language Language,
10691066
const std::string &Source, PropertyListT props = {}) {
@@ -1077,12 +1074,9 @@ kernel_bundle<bundle_state::ext_oneapi_source> create_kernel_bundle_from_source(
10771074
}
10781075

10791076
#if (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
1080-
template <
1081-
typename PropertyListT = empty_properties_t,
1082-
typename = std::enable_if_t<
1083-
is_property_list_v<PropertyListT> &&
1084-
detail::all_props_are_keys_of<detail::create_bundle_from_source_props,
1085-
PropertyListT>::value>>
1077+
template <typename PropertyListT = empty_properties_t,
1078+
typename = std::enable_if_t<detail::all_are_properties_of_v<
1079+
detail::create_bundle_from_source_props, PropertyListT>>>
10861080
kernel_bundle<bundle_state::ext_oneapi_source> create_kernel_bundle_from_source(
10871081
const context &SyclContext, source_language Language,
10881082
const std::vector<std::byte> &Bytes, PropertyListT props = {}) {
@@ -1101,10 +1095,8 @@ kernel_bundle<bundle_state::ext_oneapi_source> create_kernel_bundle_from_source(
11011095
/////////////////////////
11021096

11031097
template <typename PropertyListT = empty_properties_t,
1104-
typename = std::enable_if_t<
1105-
is_property_list_v<PropertyListT> &&
1106-
detail::all_props_are_keys_of<detail::build_source_bundle_props,
1107-
PropertyListT>::value>>
1098+
typename = std::enable_if_t<detail::all_are_properties_of_v<
1099+
detail::build_source_bundle_props, PropertyListT>>>
11081100

11091101
kernel_bundle<bundle_state::executable>
11101102
build(kernel_bundle<bundle_state::ext_oneapi_source> &SourceKB,
@@ -1127,10 +1119,8 @@ build(kernel_bundle<bundle_state::ext_oneapi_source> &SourceKB,
11271119
}
11281120

11291121
template <typename PropertyListT = empty_properties_t,
1130-
typename = std::enable_if_t<
1131-
is_property_list_v<PropertyListT> &&
1132-
detail::all_props_are_keys_of<detail::build_source_bundle_props,
1133-
PropertyListT>::value>>
1122+
typename = std::enable_if_t<detail::all_are_properties_of_v<
1123+
detail::build_source_bundle_props, PropertyListT>>>
11341124
kernel_bundle<bundle_state::executable>
11351125
build(kernel_bundle<bundle_state::ext_oneapi_source> &SourceKB,
11361126
PropertyListT props = {}) {

0 commit comments

Comments
 (0)