DPC++ Runtime
Runtime libraries for oneAPI DPC++
aliases.hpp
Go to the documentation of this file.
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 <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
12 #include <sycl/half_type.hpp> // for half
13 
14 #include <cstdint> // for uint8_t, int16_t, int32_t
15 
16 namespace sycl {
17 inline namespace _V1 {
18 template <typename T, int N> class vec;
19 namespace detail::half_impl {
20 class half;
21 } // namespace detail::half_impl
22 } // namespace _V1
23 } // namespace sycl
24 
25 #define __SYCL_MAKE_VECTOR_ALIAS(ALIAS, TYPE, N) \
26  using ALIAS##N = sycl::vec<TYPE, N>;
27 
28 #define __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(ALIAS, TYPE, N, MESSAGE) \
29  using ALIAS##N __SYCL2020_DEPRECATED(MESSAGE) = sycl::vec<TYPE, N>;
30 
31 #define __SYCL_MAKE_VECTOR_ALIASES_FOR_ARITHMETIC_TYPES(N) \
32  __SYCL_MAKE_VECTOR_ALIAS(char, char, N) \
33  __SYCL_MAKE_VECTOR_ALIAS(short, short, N) \
34  __SYCL_MAKE_VECTOR_ALIAS(int, int, N) \
35  __SYCL_MAKE_VECTOR_ALIAS(long, long, N) \
36  __SYCL_MAKE_VECTOR_ALIAS(float, float, N) \
37  __SYCL_MAKE_VECTOR_ALIAS(double, double, N) \
38  __SYCL_MAKE_VECTOR_ALIAS(half, half, N)
39 
40 // There are no 'cl_*' vec aliases in SYCL 2020
41 #define __SYCL_MAKE_VECTOR_ALIASES_FOR_OPENCL_TYPES(N) \
42  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_char, sycl::cl_char, N, "") \
43  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_uchar, sycl::cl_uchar, N, "") \
44  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_short, sycl::cl_short, N, "") \
45  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_ushort, sycl::cl_ushort, N, "") \
46  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_int, sycl::cl_int, N, "") \
47  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_uint, sycl::cl_uint, N, "") \
48  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_long, sycl::cl_long, N, "") \
49  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_ulong, sycl::cl_ulong, N, "") \
50  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_float, sycl::cl_float, N, "") \
51  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_double, sycl::cl_double, N, "") \
52  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(cl_half, sycl::cl_half, N, "")
53 
54 #define __SYCL_MAKE_VECTOR_ALIASES_FOR_SIGNED_AND_UNSIGNED_TYPES(N) \
55  __SYCL_MAKE_VECTOR_ALIAS(schar, signed char, N) \
56  __SYCL_MAKE_VECTOR_ALIAS(uchar, unsigned char, N) \
57  __SYCL_MAKE_VECTOR_ALIAS(ushort, unsigned short, N) \
58  __SYCL_MAKE_VECTOR_ALIAS(uint, unsigned int, N) \
59  __SYCL_MAKE_VECTOR_ALIAS(ulong, unsigned long, N) \
60  __SYCL_MAKE_VECTOR_ALIAS(longlong, long long, N) \
61  __SYCL_MAKE_VECTOR_ALIAS(ulonglong, unsigned long long, N)
62 
63 #define __SYCL_MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(N) \
64  __SYCL_MAKE_VECTOR_ALIASES_FOR_ARITHMETIC_TYPES(N) \
65  __SYCL_MAKE_VECTOR_ALIASES_FOR_OPENCL_TYPES(N) \
66  __SYCL_MAKE_VECTOR_ALIASES_FOR_SIGNED_AND_UNSIGNED_TYPES(N)
67 
68 // FIXME: OpenCL vector aliases are not defined by SYCL 2020 spec and should be
69 // removed from here. See intel/llvm#7888. They are deprecated for now.
70 // FIXME: schar, longlong and ulonglong aliases are not defined by SYCL 2020
71 // spec, but they are preserved in SYCL 2020 mode, because SYCL-CTS is
72 // still using them.
73 // See KhronosGroup/SYCL-CTS#446 and KhronosGroup/SYCL-Docs#335
74 #define __SYCL_2020_MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(N) \
75  __SYCL_MAKE_VECTOR_ALIASES_FOR_OPENCL_TYPES(N) \
76  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(schar, std::int8_t, N, "") \
77  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(longlong, std::int64_t, N, "") \
78  __SYCL_2020_MAKE_DEPRECATED_VECTOR_ALIAS(ulonglong, std::uint64_t, N, "") \
79  __SYCL_MAKE_VECTOR_ALIAS(char, std::int8_t, N) \
80  __SYCL_MAKE_VECTOR_ALIAS(uchar, std::uint8_t, N) \
81  __SYCL_MAKE_VECTOR_ALIAS(short, std::int16_t, N) \
82  __SYCL_MAKE_VECTOR_ALIAS(ushort, std::uint16_t, N) \
83  __SYCL_MAKE_VECTOR_ALIAS(int, std::int32_t, N) \
84  __SYCL_MAKE_VECTOR_ALIAS(uint, std::uint32_t, N) \
85  __SYCL_MAKE_VECTOR_ALIAS(long, std::int64_t, N) \
86  __SYCL_MAKE_VECTOR_ALIAS(ulong, std::uint64_t, N) \
87  __SYCL_MAKE_VECTOR_ALIAS(float, float, N) \
88  __SYCL_MAKE_VECTOR_ALIAS(double, double, N) \
89  __SYCL_MAKE_VECTOR_ALIAS(half, half, N)
90 
91 namespace sycl {
92 inline namespace _V1 {
93 using byte __SYCL2020_DEPRECATED("use std::byte instead") = std::uint8_t;
94 using schar __SYCL2020_DEPRECATED("") = signed char;
95 using uchar __SYCL2020_DEPRECATED("") = unsigned char;
96 using ushort __SYCL2020_DEPRECATED("") = unsigned short;
97 using uint __SYCL2020_DEPRECATED("") = unsigned int;
98 using ulong __SYCL2020_DEPRECATED("") = unsigned long;
99 using longlong __SYCL2020_DEPRECATED("") = long long;
100 using ulonglong __SYCL2020_DEPRECATED("") = unsigned long long;
102 
103 using cl_bool __SYCL2020_DEPRECATED("use sycl::opencl::cl_bool instead") = bool;
104 using cl_char
105  __SYCL2020_DEPRECATED("use sycl::opencl::cl_char instead") = std::int8_t;
106 using cl_uchar
107  __SYCL2020_DEPRECATED("use sycl::opencl::cl_uchar instead") = std::uint8_t;
108 using cl_short
109  __SYCL2020_DEPRECATED("use sycl::opencl::cl_short instead") = std::int16_t;
110 using cl_ushort __SYCL2020_DEPRECATED("use sycl::opencl::cl_ushort instead") =
111  std::uint16_t;
112 using cl_int
113  __SYCL2020_DEPRECATED("use sycl::opencl::cl_int instead") = std::int32_t;
114 using cl_uint
115  __SYCL2020_DEPRECATED("use sycl::opencl::cl_uint instead") = std::uint32_t;
116 using cl_long
117  __SYCL2020_DEPRECATED("use sycl::opencl::cl_long instead") = std::int64_t;
118 using cl_ulong
119  __SYCL2020_DEPRECATED("use sycl::opencl::cl_ulong instead") = std::uint64_t;
120 using cl_half __SYCL2020_DEPRECATED("use sycl::opencl::cl_half instead") = half;
121 using cl_float
122  __SYCL2020_DEPRECATED("use sycl::opencl::cl_float instead") = float;
123 using cl_double
124  __SYCL2020_DEPRECATED("use sycl::opencl::cl_double instead") = double;
125 
126 namespace opencl {
127 // Strictly speaking, cl_* aliases should not be defined in opencl namespace in
128 // SYCL 1.2.1 mode, but we do so to simplify our implementation
129 using cl_bool = bool;
130 using cl_char = std::int8_t;
131 using cl_uchar = std::uint8_t;
132 using cl_short = std::int16_t;
133 using cl_ushort = std::uint16_t;
134 using cl_int = std::int32_t;
135 using cl_uint = std::uint32_t;
137 using cl_ulong = std::uint64_t;
138 using cl_half = half;
139 using cl_float = float;
140 using cl_double = double;
141 } // namespace opencl
142 
143 // Vector aliases are different between SYCL 1.2.1 and SYCL 2020
144 #if SYCL_LANGUAGE_VERSION >= 202001
150 #else
156 #endif
157 } // namespace _V1
158 } // namespace sycl
159 
160 #undef __SYCL_MAKE_VECTOR_ALIAS
161 #undef __SYCL_MAKE_VECTOR_ALIASES_FOR_ARITHMETIC_TYPES
162 #undef __SYCL_MAKE_VECTOR_ALIASES_FOR_OPENCL_TYPES
163 #undef __SYCL_MAKE_VECTOR_ALIASES_FOR_SIGNED_AND_UNSIGNED_TYPES
164 #undef __SYCL_MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH
165 #undef __SYCL_2020_MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH
#define __SYCL_2020_MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(N)
Definition: aliases.hpp:74
#define __SYCL_MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(N)
Definition: aliases.hpp:63
unsigned short ushort
Definition: common.hpp:41
conditional< sizeof(long)==8, long, long long >::type int64_t
Definition: kernel_desc.hpp:35
std::uint64_t cl_ulong
Definition: aliases.hpp:137
std::int32_t cl_int
Definition: aliases.hpp:134
std::int8_t cl_char
Definition: aliases.hpp:130
std::uint8_t cl_uchar
Definition: aliases.hpp:131
std::uint16_t cl_ushort
Definition: aliases.hpp:133
std::int16_t cl_short
Definition: aliases.hpp:132
std::uint32_t cl_uint
Definition: aliases.hpp:135
std::int64_t cl_long
Definition: aliases.hpp:136
signed char __SYCL2020_DEPRECATED
Definition: aliases.hpp:94
sycl::detail::half_impl::half half
Definition: aliases.hpp:101
Definition: access.hpp:18