Skip to content

Commit c557d78

Browse files
authored
[SYCL][ESIMD] Move some ESIMD APIs outside of experimental namespace (#5729)
* [SYCL][ESIMD] Move some ESIMD APIs outside of experimental namespace Signed-off-by: Sergey Dmitriev <[email protected]>
1 parent a9dcdf7 commit c557d78

File tree

83 files changed

+6747
-6315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+6747
-6315
lines changed

llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,15 +1596,14 @@ SmallPtrSet<Type *, 4> collectGenXVolatileTypes(Module &M) {
15961596
// TODO FIXME relying on type name in LLVM IR is fragile, needs rework
15971597
if (!GTy || !GTy->getName()
15981598
.rtrim(".0123456789")
1599-
.endswith("sycl::ext::intel::experimental::esimd::simd"))
1599+
.endswith("sycl::ext::intel::esimd::simd"))
16001600
continue;
16011601
assert(GTy->getNumContainedTypes() == 1);
16021602
auto VTy = GTy->getContainedType(0);
16031603
if ((GTy = dyn_cast<StructType>(VTy))) {
16041604
assert(GTy->getName()
16051605
.rtrim(".0123456789")
1606-
.endswith("sycl::ext::intel::experimental::esimd::detail::"
1607-
"simd_obj_impl"));
1606+
.endswith("sycl::ext::intel::esimd::detail::simd_obj_impl"));
16081607
VTy = GTy->getContainedType(0);
16091608
}
16101609
assert(VTy->isVectorTy());

sycl/include/CL/sycl/accessor.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,12 @@ namespace sycl {
206206
class stream;
207207
namespace ext {
208208
namespace intel {
209-
namespace experimental {
210209
namespace esimd {
211210
namespace detail {
212211
// Forward declare a "back-door" access class to support ESIMD.
213212
class AccessorPrivateProxy;
214213
} // namespace detail
215214
} // namespace esimd
216-
} // namespace experimental
217215
} // namespace intel
218216
} // namespace ext
219217

@@ -478,8 +476,7 @@ class image_accessor
478476
#endif
479477

480478
private:
481-
friend class sycl::ext::intel::experimental::esimd::detail::
482-
AccessorPrivateProxy;
479+
friend class sycl::ext::intel::esimd::detail::AccessorPrivateProxy;
483480

484481
#ifdef __SYCL_DEVICE_ONLY__
485482
const OCLImageTy getNativeImageObj() const { return MImageObj; }
@@ -971,8 +968,7 @@ class __SYCL_SPECIAL_CLASS accessor :
971968

972969
private:
973970
friend class sycl::stream;
974-
friend class sycl::ext::intel::experimental::esimd::detail::
975-
AccessorPrivateProxy;
971+
friend class sycl::ext::intel::esimd::detail::AccessorPrivateProxy;
976972

977973
public:
978974
using value_type = DataT;

sycl/include/CL/sycl/builtins_esimd.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <CL/sycl/detail/common.hpp>
1414
#include <CL/sycl/detail/generic_type_traits.hpp>
1515
#include <CL/sycl/types.hpp>
16-
#include <sycl/ext/intel/experimental/esimd/detail/math_intrin.hpp>
16+
#include <sycl/ext/intel/esimd/detail/math_intrin.hpp>
1717

1818
// TODO Decide whether to mark functions with this attribute.
1919
#define __NOEXC /*noexcept*/

sycl/include/CL/sycl/detail/accessor_impl.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ namespace sycl {
2020

2121
namespace ext {
2222
namespace intel {
23-
namespace experimental {
2423
namespace esimd {
2524
namespace detail {
2625
// Forward declare a "back-door" access class to support ESIMD.
2726
class AccessorPrivateProxy;
2827
} // namespace detail
2928
} // namespace esimd
30-
} // namespace experimental
3129
} // namespace intel
3230
} // namespace ext
3331

@@ -164,8 +162,7 @@ class AccessorBaseHost {
164162
AccessorImplPtr impl;
165163

166164
private:
167-
friend class sycl::ext::intel::experimental::esimd::detail::
168-
AccessorPrivateProxy;
165+
friend class sycl::ext::intel::esimd::detail::AccessorPrivateProxy;
169166
};
170167

171168
class __SYCL_EXPORT LocalAccessorImplHost {

sycl/include/CL/sycl/half_type.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ namespace sycl {
3838

3939
namespace ext {
4040
namespace intel {
41-
namespace experimental {
4241
namespace esimd {
4342
namespace detail {
4443
class WrapperElementTypeProxy;
4544
} // namespace detail
4645
} // namespace esimd
47-
} // namespace experimental
4846
} // namespace intel
4947
} // namespace ext
5048

@@ -268,8 +266,7 @@ class __SYCL_EXPORT half_v2 {
268266
// Initialize underlying data
269267
constexpr explicit half_v2(uint16_t x) : Buf(x) {}
270268

271-
friend class sycl::ext::intel::experimental::esimd::detail::
272-
WrapperElementTypeProxy;
269+
friend class sycl::ext::intel::esimd::detail::WrapperElementTypeProxy;
273270

274271
private:
275272
uint16_t Buf;
@@ -407,8 +404,7 @@ class half {
407404

408405
template <typename Key> friend struct std::hash;
409406

410-
friend class sycl::ext::intel::experimental::esimd::detail::
411-
WrapperElementTypeProxy;
407+
friend class sycl::ext::intel::esimd::detail::WrapperElementTypeProxy;
412408

413409
private:
414410
StorageT Data;

sycl/include/sycl/ext/intel/experimental/esimd.hpp renamed to sycl/include/sycl/ext/intel/esimd.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@
7171

7272
/// @} sycl_esimd
7373

74-
#include <sycl/ext/intel/experimental/esimd/alt_ui.hpp>
75-
#include <sycl/ext/intel/experimental/esimd/common.hpp>
74+
#include <sycl/ext/intel/esimd/alt_ui.hpp>
75+
#include <sycl/ext/intel/esimd/common.hpp>
76+
#include <sycl/ext/intel/esimd/math.hpp>
77+
#include <sycl/ext/intel/esimd/memory.hpp>
78+
#include <sycl/ext/intel/esimd/simd.hpp>
79+
#include <sycl/ext/intel/esimd/simd_view.hpp>
7680
#include <sycl/ext/intel/experimental/esimd/math.hpp>
7781
#include <sycl/ext/intel/experimental/esimd/memory.hpp>
78-
#include <sycl/ext/intel/experimental/esimd/simd.hpp>
79-
#include <sycl/ext/intel/experimental/esimd/simd_view.hpp>

sycl/include/sycl/ext/intel/experimental/esimd/alt_ui.hpp renamed to sycl/include/sycl/ext/intel/esimd/alt_ui.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@
88
// "Alternative" convenience Explicit SIMD APIs.
99
//===----------------------------------------------------------------------===//
1010

11-
#include <sycl/ext/intel/experimental/esimd/simd.hpp>
12-
#include <sycl/ext/intel/experimental/esimd/simd_view.hpp>
11+
#include <sycl/ext/intel/esimd/simd.hpp>
12+
#include <sycl/ext/intel/esimd/simd_view.hpp>
1313

1414
__SYCL_INLINE_NAMESPACE(cl) {
15-
namespace sycl {
16-
namespace ext {
17-
namespace intel {
18-
namespace experimental {
19-
namespace esimd {
15+
namespace __ESIMD_NS {
2016

2117
/// @addtogroup sycl_esimd_misc
2218
/// @{
@@ -69,9 +65,5 @@ __ESIMD_API auto merge(simd_view<BaseT1, RegionT1> v1,
6965

7066
/// @} sycl_esimd_misc
7167

72-
} // namespace esimd
73-
} // namespace experimental
74-
} // namespace intel
75-
} // namespace ext
76-
} // namespace sycl
68+
} // namespace __ESIMD_NS
7769
} // __SYCL_INLINE_NAMESPACE(cl)
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
//==---------------- common.hpp - DPC++ Explicit SIMD API ----------------==//
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+
// definitions used in Explicit SIMD APIs.
9+
//===----------------------------------------------------------------------===//
10+
11+
#pragma once
12+
13+
#include <CL/sycl/detail/defines.hpp>
14+
15+
#include <cstdint> // for uint* types
16+
#include <type_traits>
17+
18+
/// @cond ESIMD_DETAIL
19+
20+
#ifdef __SYCL_DEVICE_ONLY__
21+
#define SYCL_ESIMD_KERNEL __attribute__((sycl_explicit_simd))
22+
#define SYCL_ESIMD_FUNCTION __attribute__((sycl_explicit_simd))
23+
24+
// Mark a function being nodebug.
25+
#define ESIMD_NODEBUG __attribute__((nodebug))
26+
// Mark a "ESIMD global": accessible from all functions in current translation
27+
// unit, separate copy per subgroup (work-item), mapped to SPIR-V private
28+
// storage class.
29+
#define ESIMD_PRIVATE \
30+
__attribute__((opencl_private)) __attribute__((sycl_explicit_simd))
31+
// Bind a ESIMD global variable to a specific register.
32+
#define ESIMD_REGISTER(n) __attribute__((register_num(n)))
33+
34+
#define __ESIMD_API ESIMD_NODEBUG ESIMD_INLINE
35+
36+
#define __ESIMD_UNSUPPORTED_ON_HOST
37+
38+
#else // __SYCL_DEVICE_ONLY__
39+
#define SYCL_ESIMD_KERNEL
40+
#define SYCL_ESIMD_FUNCTION
41+
42+
// TODO ESIMD define what this means on Windows host
43+
#define ESIMD_NODEBUG
44+
// On host device ESIMD global is a thread local static var. This assumes that
45+
// each work-item is mapped to a separate OS thread on host device.
46+
#define ESIMD_PRIVATE thread_local
47+
#define ESIMD_REGISTER(n)
48+
49+
#define __ESIMD_API ESIMD_INLINE
50+
51+
#define __ESIMD_UNSUPPORTED_ON_HOST throw cl::sycl::feature_not_supported()
52+
53+
#endif // __SYCL_DEVICE_ONLY__
54+
55+
// Mark a function being noinline
56+
#define ESIMD_NOINLINE __attribute__((noinline))
57+
// Force a function to be inlined. 'inline' is used to preserve ODR for
58+
// functions defined in a header.
59+
#define ESIMD_INLINE inline __attribute__((always_inline))
60+
61+
// Macros for internal use
62+
#define __ESIMD_NS sycl::ext::intel::esimd
63+
#define __ESIMD_DNS sycl::ext::intel::esimd::detail
64+
#define __ESIMD_EMU_DNS sycl::ext::intel::esimd::emu::detail
65+
66+
#define __ESIMD_QUOTE1(m) #m
67+
#define __ESIMD_QUOTE(m) __ESIMD_QUOTE1(m)
68+
#define __ESIMD_NS_QUOTED __ESIMD_QUOTE(__ESIMD_NS)
69+
#define __ESIMD_DEPRECATED(new_api) \
70+
__SYCL_DEPRECATED("use " __ESIMD_NS_QUOTED "::" __ESIMD_QUOTE(new_api))
71+
72+
/// @endcond ESIMD_DETAIL
73+
74+
__SYCL_INLINE_NAMESPACE(cl) {
75+
namespace __ESIMD_NS {
76+
77+
/// @addtogroup sycl_esimd_core
78+
/// @{
79+
80+
using uchar = unsigned char;
81+
using ushort = unsigned short;
82+
using uint = unsigned int;
83+
84+
/// Gen hardware supports applying saturation to results of certain operations.
85+
/// This type tag represents "saturation on" behavior.
86+
struct saturation_on_tag : std::true_type {};
87+
88+
/// This type tag represents "saturation off" behavior.
89+
struct saturation_off_tag : std::false_type {};
90+
91+
/// Type tag object representing "saturation off" behavior.
92+
static inline constexpr saturation_off_tag saturation_off{};
93+
94+
/// Type tag object representing "saturation on" behavior.
95+
static inline constexpr saturation_on_tag saturation_on{};
96+
97+
/// Represents a pixel's channel.
98+
enum class rgba_channel : uint8_t { R, G, B, A };
99+
100+
/// Surface index type. Surface is an internal representation of a memory block
101+
/// addressable by GPU in "stateful" memory model, and each surface is
102+
/// identified by its "binding table index" - surface index.
103+
using SurfaceIndex = unsigned int;
104+
105+
namespace detail {
106+
template <rgba_channel Ch>
107+
static inline constexpr uint8_t ch = 1 << static_cast<int>(Ch);
108+
static inline constexpr uint8_t chR = ch<rgba_channel::R>;
109+
static inline constexpr uint8_t chG = ch<rgba_channel::G>;
110+
static inline constexpr uint8_t chB = ch<rgba_channel::B>;
111+
static inline constexpr uint8_t chA = ch<rgba_channel::A>;
112+
113+
// Shared Local Memory Binding Table Index (aka surface index).
114+
static inline constexpr SurfaceIndex SLM_BTI = 254;
115+
static inline constexpr SurfaceIndex INVALID_BTI =
116+
static_cast<SurfaceIndex>(-1);
117+
} // namespace detail
118+
119+
/// Represents a pixel's channel mask - all possible combinations of enabled
120+
/// channels.
121+
enum class rgba_channel_mask : uint8_t {
122+
R = detail::chR,
123+
G = detail::chG,
124+
GR = detail::chG | detail::chR,
125+
B = detail::chB,
126+
BR = detail::chB | detail::chR,
127+
BG = detail::chB | detail::chG,
128+
BGR = detail::chB | detail::chG | detail::chR,
129+
A = detail::chA,
130+
AR = detail::chA | detail::chR,
131+
AG = detail::chA | detail::chG,
132+
AGR = detail::chA | detail::chG | detail::chR,
133+
AB = detail::chA | detail::chB,
134+
ABR = detail::chA | detail::chB | detail::chR,
135+
ABG = detail::chA | detail::chB | detail::chG,
136+
ABGR = detail::chA | detail::chB | detail::chG | detail::chR,
137+
};
138+
139+
constexpr int is_channel_enabled(rgba_channel_mask M, rgba_channel Ch) {
140+
int Pos = static_cast<int>(Ch);
141+
return (static_cast<int>(M) & (1 << Pos)) >> Pos;
142+
}
143+
144+
constexpr int get_num_channels_enabled(rgba_channel_mask M) {
145+
return is_channel_enabled(M, rgba_channel::R) +
146+
is_channel_enabled(M, rgba_channel::G) +
147+
is_channel_enabled(M, rgba_channel::B) +
148+
is_channel_enabled(M, rgba_channel::A);
149+
}
150+
151+
/// Represents an atomic operation. Operations always return the old value(s) of
152+
/// the target memory location(s) as it was before the operation was applied.
153+
/// Each operation is annotated with a pseudocode illustrating its semantics,
154+
/// \c addr is a memory address (one of the many, as the atomic operation is
155+
/// vector) the operation is applied at, \c src0 is its first argumnet,
156+
/// \c src1 - second.
157+
enum class atomic_op : uint8_t {
158+
/// Addition: <code>*addr = *addr + src0</code>.
159+
add = 0x0,
160+
/// Subtraction: <code>*addr = *addr - src0</code>.
161+
sub = 0x1,
162+
/// Increment: <code>*addr = *addr + 1</code>.
163+
inc = 0x2,
164+
/// Decrement: <code>*addr = *addr - 1</code>.
165+
dec = 0x3,
166+
/// Minimum: <code>*addr = min(*addr, src0)</code>.
167+
min = 0x4,
168+
/// Maximum: <code>*addr = max(*addr, src0)</code>.
169+
max = 0x5,
170+
/// Exchange. <code>*addr == src0;</code>
171+
xchg = 0x6,
172+
/// Compare and exchange. <code>if (*addr == src0) *sddr = src1;</code>
173+
cmpxchg = 0x7,
174+
/// Bit \c and: <code>*addr = *addr & src0</code>.
175+
bit_and = 0x8,
176+
/// Bit \c or: <code>*addr = *addr | src0</code>.
177+
bit_or = 0x9,
178+
/// Bit \c xor: <code>*addr = *addr | src0</code>.
179+
bit_xor = 0xa,
180+
/// Minimum (signed integer): <code>*addr = min(*addr, src0)</code>.
181+
minsint = 0xb,
182+
/// Maximum (signed integer): <code>*addr = max(*addr, src0)</code>.
183+
maxsint = 0xc,
184+
/// Minimum (floating point): <code>*addr = min(*addr, src0)</code>.
185+
fmax = 0x10,
186+
/// Maximum (floating point): <code>*addr = max(*addr, src0)</code>.
187+
fmin = 0x11,
188+
/// Compare and exchange (floating point).
189+
/// <code>if (*addr == src0) *addr = src1;</code>
190+
fcmpwr = 0x12,
191+
fadd = 0x13,
192+
fsub = 0x14,
193+
load = 0x15,
194+
store = 0x16,
195+
/// Decrement: <code>*addr = *addr - 1</code>. The only operation which
196+
/// returns new value of the destination rather than old.
197+
predec = 0xff,
198+
};
199+
200+
/// @} sycl_esimd_core
201+
202+
} // namespace __ESIMD_NS
203+
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/sycl/ext/intel/experimental/esimd/detail/elem_type_traits.hpp renamed to sycl/include/sycl/ext/intel/esimd/detail/elem_type_traits.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@
8181

8282
#pragma once
8383

84-
#include <sycl/ext/intel/experimental/esimd/detail/types.hpp>
84+
#include <sycl/ext/intel/esimd/detail/types.hpp>
8585

8686
#include <CL/sycl/half_type.hpp>
8787

8888
/// @cond ESIMD_DETAIL
8989

9090
__SYCL_INLINE_NAMESPACE(cl) {
91-
namespace __SEIEED {
91+
namespace __ESIMD_DNS {
9292

9393
// Primitive C++ operations supported by simd objects and templated upon by some
9494
// of the functions/classes.
@@ -710,7 +710,7 @@ inline std::istream &operator>>(std::istream &I, sycl::half &rhs) {
710710
////////////////////////////////////////////////////////////////////////////////
711711
// TODO
712712

713-
} // namespace __SEIEED
713+
} // namespace __ESIMD_DNS
714714
} // __SYCL_INLINE_NAMESPACE(cl)
715715

716716
/// @endcond ESIMD_DETAIL

0 commit comments

Comments
 (0)