20
20
namespace sycl {
21
21
inline namespace _V1 {
22
22
namespace ext ::intel::experimental {
23
- namespace detail {
24
23
25
- // Hide the base implementation in details so that manipulation
26
- // of properties parameter pack can be modularized away from main logic
27
- template <typename T, typename ... Props> class fpga_mem_base {
24
+ // Primary template should never be deduced. Needed to establish which
25
+ // parameters fpga_mem can be templated on
26
+ template <typename T, typename PropertyListT =
27
+ ext::oneapi::experimental::empty_properties_t >
28
+ class fpga_mem {
29
+
30
+ static_assert (
31
+ ext::oneapi::experimental::is_property_list<PropertyListT>::value,
32
+ " Property list is invalid." );
33
+ };
34
+
35
+ // Template specialization that all calls should use. Separates Props from
36
+ // properties_t which allows the class to apply Props as attributes.
37
+ template <typename T, typename ... Props>
38
+ class
39
+ #ifdef __SYCL_DEVICE_ONLY__
40
+ [[__sycl_detail__::add_ir_attributes_global_variable(
41
+ " sycl-resource" ,
42
+ ext::oneapi::experimental::detail::PropertyMetaInfo<Props>::name...,
43
+ " DEFAULT" ,
44
+ ext::oneapi::experimental::detail::PropertyMetaInfo<Props>::value...)]]
45
+ #endif
46
+ fpga_mem<T, ext::oneapi::experimental::detail::properties_t <Props...>> {
28
47
29
48
protected:
30
49
T val
@@ -47,14 +66,14 @@ template <typename T, typename... Props> class fpga_mem_base {
47
66
// All the initialization
48
67
// constexpr is used as a hint to the compiler to try and evaluate the
49
68
// constructor at compile-time
50
- template <typename ... S> constexpr fpga_mem_base (S... args) : val{args...} {}
69
+ template <typename ... S> constexpr fpga_mem (S... args) : val{args...} {}
51
70
52
- fpga_mem_base () = default ;
71
+ fpga_mem () = default ;
53
72
54
- fpga_mem_base (const fpga_mem_base &) = default ;
55
- fpga_mem_base (fpga_mem_base &&) = default ;
56
- fpga_mem_base &operator =(const fpga_mem_base &) = default ;
57
- fpga_mem_base &operator =(fpga_mem_base &&) = default ;
73
+ fpga_mem (const fpga_mem &) = default ;
74
+ fpga_mem (fpga_mem &&) = default ;
75
+ fpga_mem &operator =(const fpga_mem &) = default ;
76
+ fpga_mem &operator =(fpga_mem &&) = default ;
58
77
59
78
T &get () noexcept { return val; }
60
79
@@ -66,75 +85,24 @@ template <typename T, typename... Props> class fpga_mem_base {
66
85
// Allows for implicit conversion from this to T
67
86
constexpr operator const T &() const noexcept { return get (); }
68
87
69
- fpga_mem_base &operator =(const T &newValue) noexcept {
88
+ fpga_mem &operator =(const T &newValue) noexcept {
70
89
val = newValue;
71
90
return *this ;
72
91
}
73
92
74
- // Note that there is no need for "fpga_mem_base " to define member functions
93
+ // Note that there is no need for "fpga_mem " to define member functions
75
94
// for operators like "++", "[]", "->", comparison, etc. Instead, the type
76
95
// "T" need only define these operators as non-member functions. Because
77
- // there is an implicit conversion from "fpga_mem_base" to "T&".
78
- };
79
- } // namespace detail
80
-
81
- // alias for proper namespace
82
- template <typename ... Props>
83
- using properties_t = ext::oneapi::experimental::detail::properties_t <Props...>;
84
-
85
- // Empty property list specialization
86
- template <typename T, typename PropertyListT =
87
- ext::oneapi::experimental::empty_properties_t >
88
- class
89
- #ifdef __SYCL_DEVICE_ONLY__
90
- [[__sycl_detail__::add_ir_attributes_global_variable(" sycl-resource" ,
91
- " DEFAULT" )]]
92
- #endif
93
- fpga_mem : public detail::fpga_mem_base<T> {
94
-
95
- using property_list_t = ext::oneapi::experimental::empty_properties_t ;
96
-
97
- // Inherits the base class' constructors
98
- using detail::fpga_mem_base<T>::fpga_mem_base;
99
-
100
- public:
101
- template <typename propertyT> static constexpr bool has_property () {
102
- return property_list_t ::template has_property<propertyT>();
103
- }
104
-
105
- template <typename propertyT> static constexpr auto get_property () {
106
- return property_list_t ::template get_property<propertyT>();
107
- }
108
- };
109
-
110
- template <typename T, typename ... Props>
111
- class
112
- #ifdef __SYCL_DEVICE_ONLY__
113
- [[__sycl_detail__::add_ir_attributes_global_variable(
114
- " sycl-resource" ,
115
- ext::oneapi::experimental::detail::PropertyMetaInfo<Props>::name...,
116
- " DEFAULT" ,
117
- ext::oneapi::experimental::detail::PropertyMetaInfo<Props>::value...)]]
118
- #endif
119
- fpga_mem<T, properties_t <Props...>>
120
- : public detail::fpga_mem_base<T, Props...> {
121
-
122
- using property_list_t = properties_t <Props...>;
123
-
124
- // Inherits the base class' constructors
125
- using detail::fpga_mem_base<T, Props...>::fpga_mem_base;
126
-
127
- public:
128
- static_assert (
129
- ext::oneapi::experimental::is_property_list<property_list_t >::value,
130
- " Property list is invalid." );
96
+ // there is an implicit conversion from "fpga_mem" to "T&".
131
97
132
98
template <typename propertyT> static constexpr bool has_property () {
133
- return property_list_t ::template has_property<propertyT>();
99
+ return ext::oneapi::experimental::detail::properties_t <
100
+ Props...>::template has_property<propertyT>();
134
101
}
135
102
136
103
template <typename propertyT> static constexpr auto get_property () {
137
- return property_list_t ::template get_property<propertyT>();
104
+ return ext::oneapi::experimental::detail::properties_t <
105
+ Props...>::template get_property<propertyT>();
138
106
}
139
107
};
140
108
0 commit comments