Skip to content

Commit f48c33c

Browse files
alexeyvoronov-intelbader
authored andcommitted
[SYCL] Recovery align aliases with SYCL specification patch.
Fixed aliases of some vectors to follow requirements from SYCL specification 4.10.2.2 Aliases. Moved to separate file(aliases.hpp). Added the half type intp cl::sycl namespace as w/a for Khronos CTS. Signed-off-by: Alexey Voronov <[email protected]>
1 parent 7644658 commit f48c33c

File tree

5 files changed

+287
-287
lines changed

5 files changed

+287
-287
lines changed

sycl/include/CL/sycl/aliases.hpp

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
//==----------- aliases.hpp --- SYCL type aliases --------------------------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#pragma once
10+
11+
#include <CL/sycl/detail/common.hpp>
12+
13+
#include <cstddef>
14+
#include <cstdint>
15+
16+
namespace cl {
17+
namespace sycl {
18+
template <typename T, int N> class vec;
19+
namespace detail {
20+
namespace half_impl {
21+
class half;
22+
} // namespace half_impl
23+
} // namespace detail
24+
} // namespace sycl
25+
} // namespace cl
26+
27+
#ifdef __SYCL_DEVICE_ONLY__
28+
using half = _Float16;
29+
#else
30+
using half = cl::sycl::detail::half_impl::half;
31+
#endif
32+
33+
#define MAKE_VECTOR_ALIAS(ALIAS, TYPE, N) \
34+
using ALIAS##N = cl::sycl::vec<TYPE, N>;
35+
36+
#define MAKE_VECTOR_ALIASES_FOR_ARITHMETIC_TYPES(N) \
37+
MAKE_VECTOR_ALIAS(char, char, N) \
38+
MAKE_VECTOR_ALIAS(short, short, N) \
39+
MAKE_VECTOR_ALIAS(int, int, N) \
40+
MAKE_VECTOR_ALIAS(long, long, N) \
41+
MAKE_VECTOR_ALIAS(float, float, N) \
42+
MAKE_VECTOR_ALIAS(double, double, N) \
43+
MAKE_VECTOR_ALIAS(half, half, N)
44+
45+
#define MAKE_VECTOR_ALIASES_FOR_OPENCL_TYPES(N) \
46+
MAKE_VECTOR_ALIAS(cl_char, cl::sycl::cl_char, N) \
47+
MAKE_VECTOR_ALIAS(cl_uchar, cl::sycl::cl_uchar, N) \
48+
MAKE_VECTOR_ALIAS(cl_short, cl::sycl::cl_short, N) \
49+
MAKE_VECTOR_ALIAS(cl_ushort, cl::sycl::cl_ushort, N) \
50+
MAKE_VECTOR_ALIAS(cl_int, cl::sycl::cl_int, N) \
51+
MAKE_VECTOR_ALIAS(cl_uint, cl::sycl::cl_uint, N) \
52+
MAKE_VECTOR_ALIAS(cl_long, cl::sycl::cl_long, N) \
53+
MAKE_VECTOR_ALIAS(cl_ulong, cl::sycl::cl_ulong, N) \
54+
MAKE_VECTOR_ALIAS(cl_float, cl::sycl::cl_float, N) \
55+
MAKE_VECTOR_ALIAS(cl_double, cl::sycl::cl_double, N) \
56+
MAKE_VECTOR_ALIAS(cl_half, cl::sycl::cl_half, N)
57+
58+
#define MAKE_VECTOR_ALIASES_FOR_SIGNED_AND_UNSIGNED_TYPES(N) \
59+
MAKE_VECTOR_ALIAS(schar, signed char, N) \
60+
MAKE_VECTOR_ALIAS(uchar, unsigned char, N) \
61+
MAKE_VECTOR_ALIAS(ushort, unsigned short, N) \
62+
MAKE_VECTOR_ALIAS(uint, unsigned int, N) \
63+
MAKE_VECTOR_ALIAS(ulong, unsigned long, N) \
64+
MAKE_VECTOR_ALIAS(longlong, long long, N) \
65+
MAKE_VECTOR_ALIAS(ulonglong, unsigned long long, N)
66+
67+
#define MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(N) \
68+
MAKE_VECTOR_ALIASES_FOR_ARITHMETIC_TYPES(N) \
69+
MAKE_VECTOR_ALIASES_FOR_OPENCL_TYPES(N) \
70+
MAKE_VECTOR_ALIASES_FOR_SIGNED_AND_UNSIGNED_TYPES(N)
71+
72+
namespace cl {
73+
namespace sycl {
74+
using byte = std::uint8_t;
75+
using schar = signed char;
76+
using uchar = unsigned char;
77+
using ushort = unsigned short;
78+
using uint = unsigned int;
79+
using ulong = unsigned long;
80+
using longlong = long long;
81+
using ulonglong = unsigned long long;
82+
// TODO cl::sycl::half is not in SYCL specification, but is used by Khronos CTS.
83+
using half = half;
84+
using cl_bool = bool;
85+
using cl_char = std::int8_t;
86+
using cl_uchar = std::uint8_t;
87+
using cl_short = std::int16_t;
88+
using cl_ushort = std::uint16_t;
89+
using cl_int = std::int32_t;
90+
using cl_uint = std::uint32_t;
91+
using cl_long = std::int64_t;
92+
using cl_ulong = std::uint64_t;
93+
using cl_half = half;
94+
using cl_float = float;
95+
using cl_double = double;
96+
97+
MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(2)
98+
MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(3)
99+
MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(4)
100+
MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(8)
101+
MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(16)
102+
} // namespace sycl
103+
} // namespace cl
104+
105+
#undef MAKE_VECTOR_ALIAS
106+
#undef MAKE_VECTOR_ALIASES_FOR_ARITHMETIC_TYPES
107+
#undef MAKE_VECTOR_ALIASES_FOR_OPENCL_TYPES
108+
#undef MAKE_VECTOR_ALIASES_FOR_SIGNED_AND_UNSIGNED_TYPES
109+
#undef MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ using is_charn = typename is_contained<
160160
// scharn: schar2, schar3, schar4, schar8, schar16
161161
template <typename T>
162162
using is_scharn = typename is_contained<
163-
T, type_list<cl_schar2, cl_schar3, cl_schar4, cl_schar8, cl_schar16>>::type;
163+
T, type_list<schar2, schar3, schar4, schar8, schar16>>::type;
164164

165165
// ucharn: uchar2, uchar3, uchar4, uchar8, uchar16
166166
template <typename T>
@@ -170,7 +170,7 @@ using is_ucharn = typename is_contained<
170170
// igenchar: signed char, scharn
171171
template <typename T>
172172
using is_igenchar =
173-
std::integral_constant<bool, is_contained<T, type_list<cl_schar>>::value ||
173+
std::integral_constant<bool, is_contained<T, type_list<schar>>::value ||
174174
is_scharn<T>::value>;
175175

176176
// ugenchar: unsigned char, ucharn
@@ -313,7 +313,7 @@ using is_ugeninteger = std::integral_constant<
313313
// int
314314
template <typename T>
315315
using is_sgeninteger = typename is_contained<
316-
T, type_list<cl_char, cl_schar, cl_uchar, cl_short, cl_ushort, cl_int,
316+
T, type_list<cl_char, schar, cl_uchar, cl_short, cl_ushort, cl_int,
317317
cl_uint, cl_long, cl_ulong, longlong, ulonglong>>::type;
318318

319319
// vgeninteger: charn, scharn, ucharn, shortn, ushortn, intn, uintn, longn,
@@ -329,7 +329,7 @@ using is_vgeninteger = std::integral_constant<
329329
// sigeninteger: char, signed char, short, int, long int, , long long int
330330
template <typename T>
331331
using is_sigeninteger = typename is_contained<
332-
T, type_list<cl_char, cl_schar, cl_short, cl_int, cl_long, longlong>>::type;
332+
T, type_list<cl_char, schar, cl_short, cl_int, cl_long, longlong>>::type;
333333

334334
// sugeninteger: unsigned char, unsigned short, unsigned int, unsigned long
335335
// int, unsigned long long int

0 commit comments

Comments
 (0)