Skip to content

Commit 701c466

Browse files
author
Melanie Blower
committed
[SYCL] Solve name resolution problems due to Windows integer types
There are 3 Windows CTS tests, math_builtin_relational_base, math_builtin_float_double, math_builtin_integer that fail at compile time in all 3 environments. Here's a small reproducer showing the symptom: The error is like this, math_builtin_float_double.cpp:8:12: error: no matching function for call to 'nan' auto x = cl::sycl::nan(y); ^~~~~~~~~~~~~ ...include\CL/sycl/builtins.hpp:398:1: note: candidate template ignored: requirement 'detail::integral_constant<bool, false>::value' was not satisfied [with T = int] nan(T nancode) __NOEXC { ^ 1 error generated. Here’s a smaller version of the invoker, int foo(void) { //unsigned long int y = 1; FAIL like above //long int y = 1; FAIL like above //int y = 1; FAIL like above unsigned y = 1; // This one is OK auto x = cl::sycl::nan(y); } Erich suggested, https://godbolt.org/z/XkWVHg Even on MSVC, “unsigned int” and “unsigned long” are different types, despite sizeof being the same for both. The header itself uses __int32 and __int64, which are just aliases on MSVC for “unsigned int” and “unsigned long long”. THUS, the list in the headers (which I copied below) doesn’t contain ANY version of “unsigned long” on Windows. Ulonglong (the other being checked) is ALSO “unsigned long long” On linux, the list is: cl_uint == unsigned int cl_ulong == unsigned long ulonglong == unsigned long long. Thus, the whole list is covered. I suspect that one of the checks (is_ugenlong probably ) simply needs to have “unsigned long” added to it as an option in addition to cl_ulong. Alternatively, cl_ulong could be corrected. Either way, a header issue. Signed-off-by: Melanie Blower <melanie.blower@intel.com>
1 parent 8535b24 commit 701c466

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

sycl/include/CL/sycl/detail/generic_type_traits.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,9 @@ using is_ulongn = typename is_contained<
238238
// ugenlong: unsigned long int, ulongn
239239
template <typename T>
240240
using is_ugenlong =
241-
std::integral_constant<bool, is_contained<T, type_list<cl_ulong>>::value ||
242-
is_ulongn<T>::value>;
241+
std::integral_constant<bool,
242+
is_contained<T, type_list<unsigned long, cl_ulong>>::value ||
243+
is_ulongn<T>::value>;
243244

244245
// longn: long2, long3, long4, long8, long16
245246
template <typename T>
@@ -249,8 +250,8 @@ using is_longn = typename is_contained<
249250
// genlong: long int, longn
250251
template <typename T>
251252
using is_genlong =
252-
std::integral_constant<bool, is_contained<T, type_list<cl_long>>::value ||
253-
is_longn<T>::value>;
253+
std::integral_constant<bool,
254+
is_contained<T, type_list<long, cl_long>>::value || is_longn<T>::value>;
254255

255256
// ulonglongn: ulonglong2, ulonglong3, ulonglong4,ulonglong8, ulonglong16
256257
template <typename T>
@@ -314,7 +315,8 @@ using is_ugeninteger = std::integral_constant<
314315
template <typename T>
315316
using is_sgeninteger = typename is_contained<
316317
T, type_list<cl_char, cl_schar, cl_uchar, cl_short, cl_ushort, cl_int,
317-
cl_uint, cl_long, cl_ulong, longlong, ulonglong>>::type;
318+
cl_uint, cl_long, cl_ulong, long, unsigned long,
319+
longlong, ulonglong>>::type;
318320

319321
// vgeninteger: charn, scharn, ucharn, shortn, ushortn, intn, uintn, longn,
320322
// ulongn, longlongn, ulonglongn
@@ -329,7 +331,8 @@ using is_vgeninteger = std::integral_constant<
329331
// sigeninteger: char, signed char, short, int, long int, , long long int
330332
template <typename T>
331333
using is_sigeninteger = typename is_contained<
332-
T, type_list<cl_char, cl_schar, cl_short, cl_int, cl_long, longlong>>::type;
334+
T, type_list<cl_char, cl_schar, cl_short, cl_int, cl_long, long,
335+
longlong>>::type;
333336

334337
// sugeninteger: unsigned char, unsigned short, unsigned int, unsigned long
335338
// int, unsigned long long int

sycl/test/basic_tests/generic_type_traits.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ using d_t = double;
1818

1919
struct v {};
2020

21+
void check_many(void)
22+
{
23+
{
24+
unsigned y = 1;
25+
auto x = cl::sycl::nan(y);
26+
}
27+
{
28+
unsigned long y = 1;
29+
auto x = cl::sycl::nan(y);
30+
}
31+
{
32+
long int y = 1;
33+
auto x = cl::sycl::any(y);
34+
}
35+
{
36+
int y = 1;
37+
auto x = cl::sycl::any(y);
38+
}
39+
}
40+
2141
int main() {
2242
// is_floatn
2343
static_assert(d::is_floatn<s::cl_float4>::value == true, "");
@@ -54,6 +74,17 @@ int main() {
5474

5575
static_assert(d::is_ugenint<s::cl_uint3>::value == true, "");
5676

77+
static_assert(d::is_ugenlong<unsigned long>::value, "");
78+
static_assert(d::is_genlong<long>::value, "");
79+
80+
static_assert(d::is_sgeninteger<int>::value, "");
81+
static_assert(d::is_sgeninteger<long int>::value, "");
82+
static_assert(d::is_sgeninteger<long long int>::value, "");
83+
84+
static_assert(d::is_sigeninteger<int>::value, "");
85+
static_assert(d::is_sigeninteger<long int>::value, "");
86+
static_assert(d::is_sigeninteger<long long int>::value, "");
87+
5788
// TODO add checks for the following type traits
5889
/*
5990
is_doublen

0 commit comments

Comments
 (0)