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