From 701c46644576c259fb2db6b91528de918c989c6e Mon Sep 17 00:00:00 2001 From: Melanie Blower Date: Fri, 16 Aug 2019 14:54:02 -0700 Subject: [PATCH] [SYCL] Solve name resolution problems due to Windows integer types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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::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 --- .../CL/sycl/detail/generic_type_traits.hpp | 15 +++++---- sycl/test/basic_tests/generic_type_traits.cpp | 31 +++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/sycl/include/CL/sycl/detail/generic_type_traits.hpp b/sycl/include/CL/sycl/detail/generic_type_traits.hpp index 323fa9783b1a3..f89e7ac6ecf4a 100644 --- a/sycl/include/CL/sycl/detail/generic_type_traits.hpp +++ b/sycl/include/CL/sycl/detail/generic_type_traits.hpp @@ -238,8 +238,9 @@ using is_ulongn = typename is_contained< // ugenlong: unsigned long int, ulongn template using is_ugenlong = - std::integral_constant>::value || - is_ulongn::value>; + std::integral_constant>::value || + is_ulongn::value>; // longn: long2, long3, long4, long8, long16 template @@ -249,8 +250,8 @@ using is_longn = typename is_contained< // genlong: long int, longn template using is_genlong = - std::integral_constant>::value || - is_longn::value>; + std::integral_constant>::value || is_longn::value>; // ulonglongn: ulonglong2, ulonglong3, ulonglong4,ulonglong8, ulonglong16 template @@ -314,7 +315,8 @@ using is_ugeninteger = std::integral_constant< template using is_sgeninteger = typename is_contained< T, type_list>::type; + cl_uint, cl_long, cl_ulong, long, unsigned long, + longlong, ulonglong>>::type; // vgeninteger: charn, scharn, ucharn, shortn, ushortn, intn, uintn, longn, // ulongn, longlongn, ulonglongn @@ -329,7 +331,8 @@ using is_vgeninteger = std::integral_constant< // sigeninteger: char, signed char, short, int, long int, , long long int template using is_sigeninteger = typename is_contained< - T, type_list>::type; + T, type_list>::type; // sugeninteger: unsigned char, unsigned short, unsigned int, unsigned long // int, unsigned long long int diff --git a/sycl/test/basic_tests/generic_type_traits.cpp b/sycl/test/basic_tests/generic_type_traits.cpp index f1afd3b1d5c75..6eb2ea4d929c0 100644 --- a/sycl/test/basic_tests/generic_type_traits.cpp +++ b/sycl/test/basic_tests/generic_type_traits.cpp @@ -18,6 +18,26 @@ using d_t = double; struct v {}; +void check_many(void) +{ + { + unsigned y = 1; + auto x = cl::sycl::nan(y); + } + { + unsigned long y = 1; + auto x = cl::sycl::nan(y); + } + { + long int y = 1; + auto x = cl::sycl::any(y); + } + { + int y = 1; + auto x = cl::sycl::any(y); + } +} + int main() { // is_floatn static_assert(d::is_floatn::value == true, ""); @@ -54,6 +74,17 @@ int main() { static_assert(d::is_ugenint::value == true, ""); + static_assert(d::is_ugenlong::value, ""); + static_assert(d::is_genlong::value, ""); + + static_assert(d::is_sgeninteger::value, ""); + static_assert(d::is_sgeninteger::value, ""); + static_assert(d::is_sgeninteger::value, ""); + + static_assert(d::is_sigeninteger::value, ""); + static_assert(d::is_sigeninteger::value, ""); + static_assert(d::is_sigeninteger::value, ""); + // TODO add checks for the following type traits /* is_doublen