@@ -55,7 +55,7 @@ bool check_vectors_equal(sycl::vec<T, 4> a, sycl::vec<T, 4> b,
55
55
return result;
56
56
}
57
57
58
- template <typename From, typename To> bool check_convert () {
58
+ template <typename From, typename To> bool check_convert (sycl::queue q ) {
59
59
sycl::vec<From, 4 > input;
60
60
if constexpr (std::is_signed_v<From>) {
61
61
input = sycl::vec<From, 4 >{static_cast <From>(37 ), static_cast <From>(0 ),
@@ -68,7 +68,6 @@ template <typename From, typename To> bool check_convert() {
68
68
sycl::vec<To, 4 > hostResult = input.template convert <To>();
69
69
70
70
sycl::buffer<sycl::vec<To, 4 >> buf (sycl::range{1 });
71
- sycl::queue q;
72
71
q.submit ([&](sycl::handler &cgh) {
73
72
sycl::accessor acc (buf, cgh);
74
73
cgh.single_task ([=]() { acc[0 ] = input.template convert <To>(); });
@@ -106,53 +105,55 @@ constexpr auto has_unsigned_v =
106
105
std::is_integral_v<T> && !std::is_same_v<T, bool > &&
107
106
!std::is_same_v<T, sycl::byte> && !std::is_same_v<T, std::byte>;
108
107
109
- template <typename From, typename To> bool check_signed_unsigned_convert_to () {
108
+ template <typename From, typename To>
109
+ bool check_signed_unsigned_convert_to (sycl::queue q) {
110
110
bool pass = true ;
111
- pass &= check_convert<From, To>();
111
+ pass &= check_convert<From, To>(q );
112
112
if constexpr (has_unsigned_v<To>)
113
- pass &= check_convert<From, std::make_unsigned_t <To>>();
113
+ pass &= check_convert<From, std::make_unsigned_t <To>>(q );
114
114
if constexpr (has_unsigned_v<From>)
115
- pass &= check_convert<std::make_unsigned_t <From>, To>();
115
+ pass &= check_convert<std::make_unsigned_t <From>, To>(q );
116
116
if constexpr (has_unsigned_v<To> && has_unsigned_v<From>)
117
117
pass &=
118
- check_convert<std::make_unsigned_t <From>, std::make_unsigned_t <To>>();
118
+ check_convert<std::make_unsigned_t <From>, std::make_unsigned_t <To>>(q );
119
119
return pass;
120
120
}
121
121
122
- template <typename From> bool check_convert_from () {
122
+ template <typename From> bool check_convert_from (sycl::queue q ) {
123
123
bool pass = true ;
124
- pass &= check_signed_unsigned_convert_to<From, sycl::byte>();
125
- pass &= check_signed_unsigned_convert_to<From, std::byte>();
126
- pass &= check_signed_unsigned_convert_to<From, std::int8_t >();
127
- pass &= check_signed_unsigned_convert_to<From, std::int16_t >();
128
- pass &= check_signed_unsigned_convert_to<From, std::int32_t >();
129
- pass &= check_signed_unsigned_convert_to<From, std::int64_t >();
130
- pass &= check_signed_unsigned_convert_to<From, bool >();
131
- pass &= check_signed_unsigned_convert_to<From, char >();
132
- pass &= check_signed_unsigned_convert_to<From, signed char >();
133
- pass &= check_signed_unsigned_convert_to<From, short >();
134
- pass &= check_signed_unsigned_convert_to<From, int >();
135
- pass &= check_signed_unsigned_convert_to<From, long >();
136
- pass &= check_signed_unsigned_convert_to<From, long long >();
124
+ pass &= check_signed_unsigned_convert_to<From, sycl::byte>(q );
125
+ pass &= check_signed_unsigned_convert_to<From, std::byte>(q );
126
+ pass &= check_signed_unsigned_convert_to<From, std::int8_t >(q );
127
+ pass &= check_signed_unsigned_convert_to<From, std::int16_t >(q );
128
+ pass &= check_signed_unsigned_convert_to<From, std::int32_t >(q );
129
+ pass &= check_signed_unsigned_convert_to<From, std::int64_t >(q );
130
+ pass &= check_signed_unsigned_convert_to<From, bool >(q );
131
+ pass &= check_signed_unsigned_convert_to<From, char >(q );
132
+ pass &= check_signed_unsigned_convert_to<From, signed char >(q );
133
+ pass &= check_signed_unsigned_convert_to<From, short >(q );
134
+ pass &= check_signed_unsigned_convert_to<From, int >(q );
135
+ pass &= check_signed_unsigned_convert_to<From, long >(q );
136
+ pass &= check_signed_unsigned_convert_to<From, long long >(q );
137
137
138
138
return pass;
139
139
}
140
140
141
141
int main () {
142
+ sycl::queue q;
142
143
bool pass = true ;
143
- pass &= check_convert_from<sycl::byte>();
144
- pass &= check_convert_from<std::byte>();
145
- pass &= check_convert_from<std::int8_t >();
146
- pass &= check_convert_from<std::int16_t >();
147
- pass &= check_convert_from<std::int32_t >();
148
- pass &= check_convert_from<std::int64_t >();
149
- pass &= check_convert_from<char >();
150
- pass &= check_convert_from<signed char >();
151
- pass &= check_convert_from<short >();
152
- pass &= check_convert_from<int >();
153
- pass &= check_convert_from<long >();
154
- pass &= check_convert_from<long long >();
155
- pass &= check_convert_from<bool >();
144
+ pass &= check_convert_from<sycl::byte>(q );
145
+ pass &= check_convert_from<std::byte>(q );
146
+ pass &= check_convert_from<std::int8_t >(q );
147
+ pass &= check_convert_from<std::int16_t >(q );
148
+ pass &= check_convert_from<std::int32_t >(q );
149
+ pass &= check_convert_from<std::int64_t >(q );
150
+ pass &= check_convert_from<char >(q );
151
+ pass &= check_convert_from<signed char >(q );
152
+ pass &= check_convert_from<short >(q );
153
+ pass &= check_convert_from<int >(q );
154
+ pass &= check_convert_from<long >(q );
155
+ pass &= check_convert_from<long long >(q );
156
+ pass &= check_convert_from<bool >(q );
156
157
157
158
return static_cast <int >(!pass);
158
159
}
0 commit comments