|
| 1 | +// RUN: %clangxx -fsycl -fsyntax-only %s -fpreview-breaking-changes |
| 2 | +// RUN: %clangxx -fsycl -fsyntax-only %s |
| 3 | + |
| 4 | +#include <sycl/sycl.hpp> |
| 5 | + |
| 6 | +template <class From, class To, class = void> |
| 7 | +struct is_explicitly_convertible_to_impl : std::false_type {}; |
| 8 | + |
| 9 | +template <class From, class To> |
| 10 | +struct is_explicitly_convertible_to_impl< |
| 11 | + From, To, std::void_t<decltype(static_cast<To>(std::declval<From>()))>> |
| 12 | + : std::true_type {}; |
| 13 | + |
| 14 | +template <class From, class To> |
| 15 | +struct is_explicitly_convertible_to |
| 16 | + : is_explicitly_convertible_to_impl<From, To> {}; |
| 17 | + |
| 18 | +template <class From, class To> |
| 19 | +inline constexpr bool is_explicitly_convertible_to_v = |
| 20 | + is_explicitly_convertible_to<From, To>::value; |
| 21 | + |
| 22 | +using sycl::half; |
| 23 | +using sycl::vec; |
| 24 | + |
| 25 | +void f_half_v1(vec<half, 1>); |
| 26 | +void f_half_v4(vec<half, 4>); |
| 27 | +void f_float_v1(vec<float, 1>); |
| 28 | +void f_float_v4(vec<float, 4>); |
| 29 | + |
| 30 | +using sw_half_1 = decltype(std::declval<vec<half, 4>>().swizzle<1>()); |
| 31 | +using sw_half_2 = decltype(std::declval<vec<half, 4>>().swizzle<1, 2>()); |
| 32 | + |
| 33 | +using sw_float_1 = decltype(std::declval<vec<float, 4>>().swizzle<1>()); |
| 34 | +using sw_float_2 = decltype(std::declval<vec<float, 4>>().swizzle<1, 2>()); |
| 35 | + |
| 36 | +using sw_double_1 = decltype(std::declval<vec<double, 4>>().swizzle<1>()); |
| 37 | +using sw_double_2 = decltype(std::declval<vec<double, 4>>().swizzle<1, 2>()); |
| 38 | + |
| 39 | +// clang-format off |
| 40 | + |
| 41 | +// NOTE: Empty space is for the future markup using NOT_IN_PREVIEW/PREVIEW_ONLY |
| 42 | +// macros. |
| 43 | + |
| 44 | + |
| 45 | +// IN_PREVIEW_ONLY condition<> |
| 46 | +// EXCEPT_IN_PREVIEW condition<> |
| 47 | + |
| 48 | +static_assert( std::is_invocable_v<decltype(f_half_v1), half>); |
| 49 | +static_assert( std::is_invocable_v<decltype(f_half_v1), float>); |
| 50 | +static_assert( std::is_invocable_v<decltype(f_half_v1), double>); |
| 51 | +static_assert( std::is_invocable_v<decltype(f_half_v1), sw_half_1>); |
| 52 | +static_assert( std::is_invocable_v<decltype(f_half_v1), sw_float_1>); |
| 53 | +static_assert( std::is_invocable_v<decltype(f_half_v1), sw_double_1>); |
| 54 | +static_assert( std::is_invocable_v<decltype(f_half_v1), vec<half, 1>>); |
| 55 | +static_assert( std::is_invocable_v<decltype(f_half_v1), vec<float, 1>>); |
| 56 | +static_assert( std::is_invocable_v<decltype(f_half_v1), vec<double, 1>>); |
| 57 | + |
| 58 | +static_assert( std::is_invocable_v<decltype(f_float_v1), half>); |
| 59 | +static_assert( std::is_invocable_v<decltype(f_float_v1), float>); |
| 60 | +static_assert( std::is_invocable_v<decltype(f_float_v1), double>); |
| 61 | +static_assert( std::is_invocable_v<decltype(f_float_v1), sw_half_1>); |
| 62 | +static_assert( std::is_invocable_v<decltype(f_float_v1), sw_float_1>); |
| 63 | +static_assert( std::is_invocable_v<decltype(f_float_v1), sw_double_1>); |
| 64 | +static_assert( std::is_invocable_v<decltype(f_float_v1), vec<half, 1>>); |
| 65 | +static_assert( std::is_invocable_v<decltype(f_float_v1), vec<float, 1>>); |
| 66 | +static_assert( std::is_invocable_v<decltype(f_float_v1), vec<double, 1>>); |
| 67 | + |
| 68 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), half>); |
| 69 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), float>); |
| 70 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), double>); |
| 71 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), sw_half_1>); |
| 72 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), sw_float_1>); |
| 73 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), sw_double_1>); |
| 74 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), sw_half_2, sw_half_2>); |
| 75 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), sw_float_2, sw_float_2>); |
| 76 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), sw_double_2, sw_double_2>); |
| 77 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), sw_half_2, sw_float_2>); |
| 78 | +static_assert( !std::is_invocable_v<decltype(f_half_v4), sw_half_2, sw_double_2>); |
| 79 | + |
| 80 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), half>); |
| 81 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), float>); |
| 82 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), double>); |
| 83 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), sw_half_1>); |
| 84 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), sw_float_1>); |
| 85 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), sw_double_1>); |
| 86 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), sw_half_2, sw_half_2>); |
| 87 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), sw_float_2, sw_float_2>); |
| 88 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), sw_double_2, sw_double_2>); |
| 89 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), sw_float_2, sw_float_2>); |
| 90 | +static_assert( !std::is_invocable_v<decltype(f_float_v4), sw_float_2, sw_double_2>); |
| 91 | + |
| 92 | +static_assert( is_explicitly_convertible_to_v<half, vec<half, 1>>); |
| 93 | +static_assert( is_explicitly_convertible_to_v<float, vec<half, 1>>); |
| 94 | +static_assert( is_explicitly_convertible_to_v<double, vec<half, 1>>); |
| 95 | +static_assert( is_explicitly_convertible_to_v<sw_half_1, vec<half, 1>>); |
| 96 | +static_assert( is_explicitly_convertible_to_v<sw_float_1, vec<half, 1>>); |
| 97 | +static_assert( is_explicitly_convertible_to_v<sw_double_1, vec<half, 1>>); |
| 98 | + |
| 99 | +static_assert( is_explicitly_convertible_to_v<half, vec<float, 1>>); |
| 100 | +static_assert( is_explicitly_convertible_to_v<float, vec<float, 1>>); |
| 101 | +static_assert( is_explicitly_convertible_to_v<double, vec<float, 1>>); |
| 102 | +static_assert( is_explicitly_convertible_to_v<sw_half_1, vec<float, 1>>); |
| 103 | +static_assert( is_explicitly_convertible_to_v<sw_float_1, vec<float, 1>>); |
| 104 | +static_assert( is_explicitly_convertible_to_v<sw_double_1, vec<float, 1>>); |
| 105 | + |
| 106 | +static_assert( is_explicitly_convertible_to_v<half, vec<half, 4>>); |
| 107 | +static_assert( is_explicitly_convertible_to_v<float, vec<half, 4>>); |
| 108 | +static_assert( is_explicitly_convertible_to_v<double, vec<half, 4>>); |
| 109 | +static_assert( is_explicitly_convertible_to_v<sw_half_1, vec<half, 4>>); |
| 110 | +static_assert( is_explicitly_convertible_to_v<sw_float_1, vec<half, 4>>); |
| 111 | +static_assert( is_explicitly_convertible_to_v<sw_double_1, vec<half, 4>>); |
| 112 | +static_assert( !is_explicitly_convertible_to_v<sw_half_2, vec<half, 4>>); |
| 113 | +static_assert( !is_explicitly_convertible_to_v<sw_float_2, vec<half, 4>>); |
| 114 | +static_assert( !is_explicitly_convertible_to_v<sw_double_2, vec<half, 4>>); |
| 115 | +static_assert( !is_explicitly_convertible_to_v<sw_half_2, vec<half, 4>>); |
| 116 | +static_assert( !is_explicitly_convertible_to_v<sw_half_2, vec<half, 4>>); |
| 117 | +static_assert( is_explicitly_convertible_to_v<sw_half_2, vec<half, 2>>); |
| 118 | +static_assert( !is_explicitly_convertible_to_v<sw_float_2, vec<half, 2>>); |
| 119 | +static_assert( !is_explicitly_convertible_to_v<sw_double_2, vec<half, 2>>); |
| 120 | +static_assert( is_explicitly_convertible_to_v<sw_half_2, vec<half, 2>>); |
| 121 | +static_assert( is_explicitly_convertible_to_v<sw_half_2, vec<half, 2>>); |
| 122 | + |
| 123 | +static_assert( is_explicitly_convertible_to_v<vec<half, 1>, half>); |
| 124 | +#if __SYCL_DEVICE_ONLY__ |
| 125 | +static_assert( is_explicitly_convertible_to_v<vec<half, 1>, float>); |
| 126 | +static_assert( is_explicitly_convertible_to_v<vec<half, 1>, double>); |
| 127 | +#else |
| 128 | +static_assert( !is_explicitly_convertible_to_v<vec<half, 1>, float>); |
| 129 | +static_assert( !is_explicitly_convertible_to_v<vec<half, 1>, double>); |
| 130 | +#endif |
| 131 | + |
| 132 | +static_assert( is_explicitly_convertible_to_v<vec<float, 1>, half>); |
| 133 | +static_assert( is_explicitly_convertible_to_v<vec<float, 1>, float>); |
| 134 | +static_assert( is_explicitly_convertible_to_v<vec<float, 1>, double>); |
0 commit comments