Skip to content

Commit 892cbc5

Browse files
[NFCI][SYCL] Move IsProperty[*Value] to property[_value].hpp (#15901)
This should make it easier to follow the logic and understand if template parameters (like `PropertyT`) refer to keys or values.
1 parent 3a8cfdf commit 892cbc5

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ struct IsCompileTimeProperty
264264
std::is_base_of_v<property_key_base_tag, PropertyT> &&
265265
std::is_base_of_v<compile_time_property_key_base_tag, PropertyT>> {};
266266

267+
// Checks if a type is either a runtime property or if it is a compile-time
268+
// property
269+
template <typename T> struct IsProperty {
270+
static constexpr bool value =
271+
IsRuntimeProperty<T>::value || IsCompileTimeProperty<T>::value;
272+
};
273+
267274
// Trait for property compile-time meta names and values.
268275
template <typename PropertyT> struct PropertyMetaInfo {
269276
// Some properties don't have meaningful compile-time values.

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

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#include <sycl/detail/boost/mp11/detail/mp_list.hpp> // for mp_list
1313
#include <sycl/detail/boost/mp11/detail/mp_rename.hpp> // for mp_rename
1414
#include <sycl/detail/boost/mp11/integral.hpp> // for mp_bool
15-
#include <sycl/ext/oneapi/properties/property.hpp> // for PropertyID, IsRun...
15+
#include <sycl/ext/oneapi/properties/property.hpp>
16+
#include <sycl/ext/oneapi/properties/property_value.hpp>
1617

1718
#include <array> // for tuple_element
1819
#include <stddef.h> // for size_t
@@ -48,34 +49,10 @@ struct PrependTuple<T, std::tuple<Ts...>> {
4849
using type = std::tuple<T, Ts...>;
4950
};
5051

51-
// Checks if a type T has a static value member variable.
52-
template <typename T, typename U = int> struct HasValue : std::false_type {};
53-
template <typename T>
54-
struct HasValue<T, decltype((void)T::value, 0)> : std::true_type {};
55-
5652
//******************************************************************************
5753
// Property identification
5854
//******************************************************************************
5955

60-
// Checks if a type is a compile-time property values.
61-
// Note: This is specialized for property_value elsewhere.
62-
template <typename PropertyT>
63-
struct IsCompileTimePropertyValue : std::false_type {};
64-
65-
// Checks if a type is either a runtime property or if it is a compile-time
66-
// property
67-
template <typename T> struct IsProperty {
68-
static constexpr bool value =
69-
IsRuntimeProperty<T>::value || IsCompileTimeProperty<T>::value;
70-
};
71-
72-
// Checks if a type is a valid property value, i.e either runtime property or
73-
// property_value with a valid compile-time property
74-
template <typename T> struct IsPropertyValue {
75-
static constexpr bool value =
76-
IsRuntimeProperty<T>::value || IsCompileTimePropertyValue<T>::value;
77-
};
78-
7956
// Checks that all types in a tuple are valid properties.
8057
template <typename T> struct AllPropertyValues {};
8158
template <typename... Ts>

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
#pragma once
1010

11-
#include <sycl/ext/oneapi/properties/property.hpp> // for IsCompileTi...
12-
#include <sycl/ext/oneapi/properties/property_utils.hpp> // for HasValue
11+
#include <sycl/ext/oneapi/properties/property.hpp>
1312

1413
#include <type_traits> // for enable_if_t
1514

@@ -18,6 +17,11 @@ inline namespace _V1 {
1817
namespace ext::oneapi::experimental {
1918
namespace detail {
2019

20+
// Checks if a type T has a static value member variable.
21+
template <typename T, typename U = int> struct HasValue : std::false_type {};
22+
template <typename T>
23+
struct HasValue<T, decltype((void)T::value, 0)> : std::true_type {};
24+
2125
// Base class for property values with a single non-type value
2226
template <typename T, typename = void> struct SingleNontypePropertyValueBase {};
2327

@@ -80,11 +84,19 @@ template <typename PropertyT, typename... PropertyValueTs>
8084
struct PropertyID<property_value<PropertyT, PropertyValueTs...>>
8185
: PropertyID<PropertyT> {};
8286

83-
// Specialization of IsCompileTimePropertyValue for property values.
87+
// Checks if a type is a compile-time property values.
88+
template <typename PropertyT>
89+
struct IsCompileTimePropertyValue : std::false_type {};
8490
template <typename PropertyT, typename... PropertyValueTs>
8591
struct IsCompileTimePropertyValue<property_value<PropertyT, PropertyValueTs...>>
8692
: IsCompileTimeProperty<PropertyT> {};
8793

94+
// Checks if a type is a valid property value, i.e either runtime property or
95+
// property_value with a valid compile-time property
96+
template <typename T> struct IsPropertyValue {
97+
static constexpr bool value =
98+
IsRuntimeProperty<T>::value || IsCompileTimePropertyValue<T>::value;
99+
};
88100
} // namespace detail
89101
} // namespace ext::oneapi::experimental
90102
} // namespace _V1

sycl/test/include_deps/sycl_detail_core.hpp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
// CHECK-NEXT: ext/oneapi/device_global/properties.hpp
137137
// CHECK-NEXT: ext/oneapi/properties/property.hpp
138138
// CHECK-NEXT: ext/oneapi/properties/property_value.hpp
139-
// CHECK-NEXT: ext/oneapi/properties/property_utils.hpp
140139
// CHECK-NEXT: ext/oneapi/properties/properties.hpp
140+
// CHECK-NEXT: ext/oneapi/properties/property_utils.hpp
141141
// CHECK-NEXT: ext/oneapi/experimental/graph.hpp
142142
// CHECK-NEXT: handler.hpp
143143
// CHECK-NEXT: detail/cl.h

0 commit comments

Comments
 (0)