Skip to content

Commit 8e29e9c

Browse files
committed
Merge remote-tracking branch 'upstream/sycl' into private/dvodopya/update-oneapi-and-intel-extensions
2 parents 3854aa9 + 8ab843b commit 8e29e9c

23 files changed

+614
-67
lines changed

sycl/include/CL/sycl/aliases.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ using half __SYCL2020_DEPRECATED("use 'sycl::half' instead") =
6868

6969
__SYCL_INLINE_NAMESPACE(cl) {
7070
namespace sycl {
71-
using byte __SYCL2020_DEPRECATED("use std::byte instead") = std::uint8_t;
7271
using schar = signed char;
7372
using uchar = unsigned char;
7473
using ushort = unsigned short;

sycl/include/CL/sycl/backend.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#pragma once
1010

1111
#include <CL/sycl/accessor.hpp>
12+
#include <CL/sycl/backend.hpp>
1213
#include <CL/sycl/backend_types.hpp>
1314
#include <CL/sycl/buffer.hpp>
1415
#include <CL/sycl/context.hpp>

sycl/include/CL/sycl/context.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class __SYCL_EXPORT context {
216216
///
217217
/// \return a native handle, the type of which defined by the backend.
218218
template <backend BackendName>
219+
__SYCL_DEPRECATED("Use SYCL-2020 sycl::get_native free function")
219220
auto get_native() const -> typename interop<BackendName, context>::type {
220221
return reinterpret_cast<typename interop<BackendName, context>::type>(
221222
getNative());

sycl/include/CL/sycl/detail/image_impl.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
__SYCL_INLINE_NAMESPACE(cl) {
2323
namespace sycl {
24-
2524
// forward declarations
2625
enum class image_channel_order : unsigned int;
2726
enum class image_channel_type : unsigned int;
@@ -36,7 +35,7 @@ class handler;
3635
namespace detail {
3736

3837
// utility functions and typedefs for image_impl
39-
using image_allocator = aligned_allocator<byte>;
38+
using image_allocator = aligned_allocator<unsigned char>;
4039

4140
// utility function: Returns the Number of Channels for a given Order.
4241
__SYCL_EXPORT uint8_t getImageNumberChannels(image_channel_order Order);

sycl/include/CL/sycl/device.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class __SYCL_EXPORT device {
184184
///
185185
/// \return a native handle, the type of which defined by the backend.
186186
template <backend BackendName>
187+
__SYCL_DEPRECATED("Use SYCL-2020 sycl::get_native free function")
187188
auto get_native() const -> typename interop<BackendName, device>::type {
188189
return (typename interop<BackendName, device>::type)getNative();
189190
}

sycl/include/CL/sycl/image.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ enum class image_channel_type : unsigned int {
5959
fp32 = 14
6060
};
6161

62-
using byte = unsigned char;
63-
64-
using image_allocator = detail::aligned_allocator<byte>;
62+
using image_allocator = detail::aligned_allocator<unsigned char>;
6563

6664
/// Defines a shared image data.
6765
///

sycl/include/CL/sycl/platform.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class __SYCL_EXPORT platform {
116116
///
117117
/// \return a native handle, the type of which defined by the backend.
118118
template <backend BackendName>
119+
__SYCL_DEPRECATED("Use SYCL-2020 sycl::get_native free function")
119120
auto get_native() const -> typename interop<BackendName, platform>::type {
120121
return reinterpret_cast<typename interop<BackendName, platform>::type>(
121122
getNative());

sycl/include/CL/sycl/sycl_span.hpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ template<class Container>
138138
__SYCL_INLINE_NAMESPACE(cl) {
139139
namespace sycl {
140140

141-
// byte is unsigned char at sycl/image.hpp:58
142-
using byte = unsigned char;
143-
144141
// asserts suppressed for device compatibility.
145142
// TODO: enable
146143
#if defined(__SYCL_DEVICE_ONLY__)
@@ -384,16 +381,17 @@ template <typename _Tp, size_t _Extent> class _SYCL_SPAN_TEMPLATE_VIS span {
384381
return rev_iterator(begin());
385382
}
386383

387-
_SYCL_SPAN_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)>
384+
_SYCL_SPAN_INLINE_VISIBILITY
385+
span<const std::byte, _Extent * sizeof(element_type)>
388386
__as_bytes() const noexcept {
389-
return span<const byte, _Extent * sizeof(element_type)>{
390-
reinterpret_cast<const byte *>(data()), size_bytes()};
387+
return span<const std::byte, _Extent * sizeof(element_type)>{
388+
reinterpret_cast<const std::byte *>(data()), size_bytes()};
391389
}
392390

393-
_SYCL_SPAN_INLINE_VISIBILITY span<byte, _Extent * sizeof(element_type)>
391+
_SYCL_SPAN_INLINE_VISIBILITY span<std::byte, _Extent * sizeof(element_type)>
394392
__as_writable_bytes() const noexcept {
395-
return span<byte, _Extent * sizeof(element_type)>{
396-
reinterpret_cast<byte *>(data()), size_bytes()};
393+
return span<std::byte, _Extent * sizeof(element_type)>{
394+
reinterpret_cast<std::byte *>(data()), size_bytes()};
397395
}
398396

399397
private:
@@ -577,14 +575,14 @@ class _SYCL_SPAN_TEMPLATE_VIS span<_Tp, dynamic_extent> {
577575
return rev_iterator(begin());
578576
}
579577

580-
_SYCL_SPAN_INLINE_VISIBILITY span<const byte, dynamic_extent>
578+
_SYCL_SPAN_INLINE_VISIBILITY span<const std::byte, dynamic_extent>
581579
__as_bytes() const noexcept {
582-
return {reinterpret_cast<const byte *>(data()), size_bytes()};
580+
return {reinterpret_cast<const std::byte *>(data()), size_bytes()};
583581
}
584582

585-
_SYCL_SPAN_INLINE_VISIBILITY span<byte, dynamic_extent>
583+
_SYCL_SPAN_INLINE_VISIBILITY span<std::byte, dynamic_extent>
586584
__as_writable_bytes() const noexcept {
587-
return {reinterpret_cast<byte *>(data()), size_bytes()};
585+
return {reinterpret_cast<std::byte *>(data()), size_bytes()};
588586
}
589587

590588
private:

sycl/include/CL/sycl/types.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@
4646
#error "SYCL device compiler is built without ext_vector_type support"
4747
#endif // __HAS_EXT_VECTOR_TYPE__
4848

49-
#include <CL/sycl/aliases.hpp>
5049
#include <CL/sycl/access/access.hpp>
50+
#include <CL/sycl/aliases.hpp>
5151
#include <CL/sycl/detail/common.hpp>
5252
#include <CL/sycl/detail/helpers.hpp>
5353
#include <CL/sycl/detail/type_traits.hpp>
5454
#include <CL/sycl/half_type.hpp>
55+
#include <CL/sycl/marray.hpp>
5556
#include <CL/sycl/multi_ptr.hpp>
5657

5758
#include <array>
@@ -2333,6 +2334,12 @@ struct is_device_copyable<std::tuple<T, Ts...>>
23332334
: detail::bool_constant<is_device_copyable<T>::value &&
23342335
is_device_copyable<std::tuple<Ts...>>::value> {};
23352336

2337+
// marray is device copyable if element type is device copyable
2338+
template <typename T, std::size_t N>
2339+
struct is_device_copyable<sycl::marray<T, N>,
2340+
std::enable_if_t<is_device_copyable<T>::value>>
2341+
: std::true_type {};
2342+
23362343
namespace detail {
23372344
template <typename T, typename = void>
23382345
struct IsDeprecatedDeviceCopyable : std::false_type {};

sycl/include/sycl/ext/oneapi/backend/level_zero.hpp

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,36 @@ struct interop<backend::level_zero,
6060
using type = ze_image_handle_t;
6161
};
6262

63+
namespace ext {
64+
namespace oneapi {
65+
namespace level_zero {
66+
// Since Level-Zero is not doing any reference counting itself, we have to
67+
// be explicit about the ownership of the native handles used in the
68+
// interop functions below.
69+
//
70+
enum class ownership { transfer, keep };
71+
} // namespace level_zero
72+
} // namespace oneapi
73+
} // namespace ext
74+
6375
namespace detail {
76+
77+
template <> struct BackendInput<backend::level_zero, context> {
78+
using type = struct {
79+
interop<backend::level_zero, context>::type NativeHandle;
80+
std::vector<device> DeviceList;
81+
level_zero::ownership Ownership;
82+
};
83+
};
84+
6485
template <> struct BackendReturn<backend::level_zero, kernel> {
6586
using type = ze_kernel_handle_t;
6687
};
6788

6889
template <> struct InteropFeatureSupportMap<backend::level_zero> {
6990
static constexpr bool MakePlatform = true;
70-
static constexpr bool MakeDevice = false;
71-
static constexpr bool MakeContext = false;
91+
static constexpr bool MakeDevice = true;
92+
static constexpr bool MakeContext = true;
7293
static constexpr bool MakeQueue = false;
7394
static constexpr bool MakeEvent = true;
7495
static constexpr bool MakeBuffer = false;
@@ -80,15 +101,9 @@ template <> struct InteropFeatureSupportMap<backend::level_zero> {
80101
namespace ext {
81102
namespace oneapi {
82103
namespace level_zero {
83-
84-
// Since Level-Zero is not doing any reference counting itself, we have to
85-
// be explicit about the ownership of the native handles used in the
86-
// interop functions below.
87-
//
88-
enum class ownership { transfer, keep };
89-
90104
// Implementation of various "make" functions resides in libsycl.so and thus
91105
// their interface needs to be backend agnostic.
106+
// TODO: remove/merge with similar functions in sycl::detail
92107
__SYCL_EXPORT platform make_platform(pi_native_handle NativeHandle);
93108
__SYCL_EXPORT device make_device(const platform &Platform,
94109
pi_native_handle NativeHandle);
@@ -107,13 +122,15 @@ __SYCL_EXPORT event make_event(const context &Context,
107122
// Construction of SYCL platform.
108123
template <typename T, typename detail::enable_if_t<
109124
std::is_same<T, platform>::value> * = nullptr>
125+
__SYCL_DEPRECATED("Use SYCL-2020 sycl::make_platform free function")
110126
T make(typename interop<backend::level_zero, T>::type Interop) {
111127
return make_platform(reinterpret_cast<pi_native_handle>(Interop));
112128
}
113129

114130
// Construction of SYCL device.
115131
template <typename T, typename detail::enable_if_t<
116132
std::is_same<T, device>::value> * = nullptr>
133+
__SYCL_DEPRECATED("Use SYCL-2020 sycl::make_device free function")
117134
T make(const platform &Platform,
118135
typename interop<backend::level_zero, T>::type Interop) {
119136
return make_device(Platform, reinterpret_cast<pi_native_handle>(Interop));
@@ -130,6 +147,7 @@ T make(const platform &Platform,
130147
///
131148
template <typename T, typename std::enable_if<
132149
std::is_same<T, context>::value>::type * = nullptr>
150+
__SYCL_DEPRECATED("Use SYCL-2020 sycl::make_context free function")
133151
T make(const std::vector<device> &DeviceList,
134152
typename interop<backend::level_zero, T>::type Interop,
135153
ownership Ownership = ownership::transfer) {
@@ -164,11 +182,21 @@ T make(const context &Context,
164182
return make_event(Context, reinterpret_cast<pi_native_handle>(Interop),
165183
Ownership == ownership::keep);
166184
}
167-
168185
} // namespace level_zero
169186
} // namespace oneapi
170187
} // namespace ext
171188

189+
// Specialization of sycl::make_context for Level-Zero backend.
190+
template <>
191+
context make_context<backend::level_zero>(
192+
const backend_input_t<backend::level_zero, context> &BackendObject,
193+
const async_handler &Handler) {
194+
return level_zero::make_context(
195+
BackendObject.DeviceList,
196+
detail::pi::cast<pi_native_handle>(BackendObject.NativeHandle),
197+
BackendObject.Ownership == level_zero::ownership::keep);
198+
}
199+
172200
namespace __SYCL2020_DEPRECATED("use 'ext::oneapi::level_zero' instead")
173201
level_zero {
174202
using namespace ext::oneapi::level_zero;

sycl/source/detail/allowlist.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
7777
"doc/EnvironmentVariables.md",
7878
PI_INVALID_VALUE);
7979

80+
const std::string &DeprecatedKeyNameDeviceName = DeviceNameKeyName;
81+
const std::string &DeprecatedKeyNamePlatformName = PlatformNameKeyName;
82+
83+
bool IsDeprecatedKeyNameDeviceNameWasUsed = false;
84+
bool IsDeprecatedKeyNamePlatformNameWasUsed = false;
85+
8086
while ((KeyEnd = AllowListRaw.find(DelimiterBtwKeyAndValue, KeyStart)) !=
8187
std::string::npos) {
8288
if ((ValueStart = AllowListRaw.find_first_not_of(
@@ -96,6 +102,13 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
96102
PI_INVALID_VALUE);
97103
}
98104

105+
if (Key == DeprecatedKeyNameDeviceName) {
106+
IsDeprecatedKeyNameDeviceNameWasUsed = true;
107+
}
108+
if (Key == DeprecatedKeyNamePlatformName) {
109+
IsDeprecatedKeyNamePlatformNameWasUsed = true;
110+
}
111+
99112
bool ShouldAllocateNewDeviceDescMap = false;
100113

101114
std::string Value;
@@ -241,6 +254,27 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
241254
}
242255
}
243256

257+
if (IsDeprecatedKeyNameDeviceNameWasUsed &&
258+
IsDeprecatedKeyNamePlatformNameWasUsed) {
259+
std::cout << "\nWARNING: " << DeprecatedKeyNameDeviceName << " and "
260+
<< DeprecatedKeyNamePlatformName
261+
<< " in SYCL_DEVICE_ALLOWLIST are deprecated. ";
262+
} else if (IsDeprecatedKeyNameDeviceNameWasUsed) {
263+
std::cout << "\nWARNING: " << DeprecatedKeyNameDeviceName
264+
<< " in SYCL_DEVICE_ALLOWLIST is deprecated. ";
265+
} else if (IsDeprecatedKeyNamePlatformNameWasUsed) {
266+
std::cout << "\nWARNING: " << DeprecatedKeyNamePlatformName
267+
<< " in SYCL_DEVICE_ALLOWLIST is deprecated. ";
268+
}
269+
if (IsDeprecatedKeyNameDeviceNameWasUsed ||
270+
IsDeprecatedKeyNamePlatformNameWasUsed) {
271+
std::cout << "Please use " << BackendNameKeyName << ", "
272+
<< DeviceTypeKeyName << " and " << DeviceVendorIdKeyName
273+
<< " instead. For details, please refer to "
274+
"https://github.com/intel/llvm/blob/sycl/sycl/doc/"
275+
"EnvironmentVariables.md\n\n";
276+
}
277+
244278
return AllowListParsed;
245279
}
246280

0 commit comments

Comments
 (0)