Skip to content

Commit e087d89

Browse files
[NFC][SYCL] Refactor all_props_are_keys_of (#16141)
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 3edd618 commit e087d89

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
@@ -399,38 +399,15 @@ constexpr auto get_property_or(default_t value) {
399399
return value;
400400
}
401401

402-
// helper: check_all_props_are_keys_of
403-
template <typename SyclT> constexpr bool check_all_props_are_keys_of() {
404-
return true;
405-
}
406-
407-
template <typename SyclT, typename FirstProp, typename... RestProps>
408-
constexpr bool check_all_props_are_keys_of() {
409-
return ext::oneapi::experimental::is_property_key_of<FirstProp,
410-
SyclT>::value &&
411-
check_all_props_are_keys_of<SyclT, RestProps...>();
412-
}
413-
414-
// all_props_are_keys_of
415-
template <typename SyclT, typename PropertiesT>
416-
struct all_props_are_keys_of : std::false_type {};
417-
418-
template <typename SyclT>
419-
struct all_props_are_keys_of<SyclT,
420-
ext::oneapi::experimental::empty_properties_t>
421-
: std::true_type {};
422-
423-
template <typename SyclT, typename PropT>
424-
struct all_props_are_keys_of<
425-
SyclT, ext::oneapi::experimental::detail::properties_t<PropT>>
426-
: std::bool_constant<
427-
ext::oneapi::experimental::is_property_key_of<PropT, SyclT>::value> {
428-
};
429-
402+
template <typename SyclT, typename PropListT>
403+
struct all_are_properties_of : std::false_type /* not a properties list */ {};
430404
template <typename SyclT, typename... Props>
431-
struct all_props_are_keys_of<
432-
SyclT, ext::oneapi::experimental::detail::properties_t<Props...>>
433-
: std::bool_constant<check_all_props_are_keys_of<SyclT, Props...>()> {};
405+
struct all_are_properties_of<SyclT, properties_t<Props...>>
406+
: std::bool_constant<((is_property_value_of<Props, SyclT>::value && ...))> {
407+
};
408+
template <typename SyclT, typename PropListT>
409+
inline constexpr bool all_are_properties_of_v =
410+
all_are_properties_of<SyclT, PropListT>::value;
434411

435412
} // namespace detail
436413
} // 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)