Skip to content

Commit aebf26b

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents f802317 + 430c722 commit aebf26b

Some content is hidden

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

53 files changed

+1074
-808
lines changed

sycl/doc/EnvironmentVariables.md

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ variables in production code.</span>
238238
| `SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS` | Integer | When set to a positive value enables use of Level Zero immediate commandlists, which means there is no batching and all commands are immediately submitted for execution. Default is 0. Note: When immediate commandlist usage is enabled it is necessary to also set SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS to either 0 or 1. |
239239
| `SYCL_PI_LEVEL_ZERO_USE_MULTIPLE_COMMANDLIST_BARRIERS` | Integer | When set to a positive value enables use of multiple Level Zero commandlists when submitting barriers. Default is 1. |
240240
| `SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_FILL` | Integer | When set to a positive value enables use of a copy engine for memory fill operations. Default is 0. |
241+
| `SYCL_PI_LEVEL_ZERO_SINGLE_ROOT_DEVICE_BUFFER_MIGRATION` | Integer | When set to "0" tells to use single root-device allocation for all devices in a context where all devices have same root. Otherwise performs regular buffer migration. Default is 1. |
241242

242243
## Debugging variables for CUDA Plugin
243244

sycl/include/sycl/detail/pi.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@
5252
// 10.13 Added new PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS queue property.
5353
// 10.14 Add PI_EXT_INTEL_DEVICE_INFO_FREE_MEMORY as an extension for
5454
// piDeviceGetInfo.
55+
// 11.15 piEventCreate creates even in the signalled state now.
5556

56-
#define _PI_H_VERSION_MAJOR 10
57-
#define _PI_H_VERSION_MINOR 14
57+
#define _PI_H_VERSION_MAJOR 11
58+
#define _PI_H_VERSION_MINOR 15
5859

5960
#define _PI_STRING_HELPER(a) #a
6061
#define _PI_CONCAT(a, b) _PI_STRING_HELPER(a.b)
@@ -1397,6 +1398,11 @@ piextKernelGetNativeHandle(pi_kernel kernel, pi_native_handle *nativeHandle);
13971398
//
13981399
// Events
13991400
//
1401+
1402+
/// Create PI event object in a signalled/completed state.
1403+
///
1404+
/// \param context is the PI context of the event.
1405+
/// \param ret_event is the PI even created.
14001406
__SYCL_EXPORT pi_result piEventCreate(pi_context context, pi_event *ret_event);
14011407

14021408
__SYCL_EXPORT pi_result piEventGetInfo(pi_event event, pi_event_info param_name,

sycl/include/sycl/ext/oneapi/kernel_properties/properties.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#pragma once
1010

11+
#include <sycl/aspects.hpp>
1112
#include <sycl/ext/oneapi/properties/property.hpp>
1213
#include <sycl/ext/oneapi/properties/property_value.hpp>
1314

@@ -53,9 +54,18 @@ struct SizeListToStrHelper<SizeList<0, Values...>, CharList<ParsedChars...>,
5354
Chars...>
5455
: SizeListToStrHelper<SizeList<Values...>,
5556
CharList<ParsedChars..., Chars..., ','>> {};
57+
template <size_t... Values, char... ParsedChars>
58+
struct SizeListToStrHelper<SizeList<0, Values...>, CharList<ParsedChars...>>
59+
: SizeListToStrHelper<SizeList<Values...>,
60+
CharList<ParsedChars..., '0', ','>> {};
5661
template <char... ParsedChars, char... Chars>
5762
struct SizeListToStrHelper<SizeList<0>, CharList<ParsedChars...>, Chars...>
5863
: CharsToStr<ParsedChars..., Chars...> {};
64+
template <char... ParsedChars>
65+
struct SizeListToStrHelper<SizeList<0>, CharList<ParsedChars...>>
66+
: CharsToStr<ParsedChars..., '0'> {};
67+
template <>
68+
struct SizeListToStrHelper<SizeList<>, CharList<>> : CharsToStr<> {};
5969

6070
// Converts size_t values to a comma-separated string representation.
6171
template <size_t... Sizes>
@@ -82,6 +92,12 @@ struct sub_group_size_key {
8292
std::integral_constant<uint32_t, Size>>;
8393
};
8494

95+
struct device_has_key {
96+
template <aspect... Aspects>
97+
using value_t = property_value<device_has_key,
98+
std::integral_constant<aspect, Aspects>...>;
99+
};
100+
85101
template <size_t Dim0, size_t... Dims>
86102
struct property_value<work_group_size_key, std::integral_constant<size_t, Dim0>,
87103
std::integral_constant<size_t, Dims>...> {
@@ -127,6 +143,13 @@ struct property_value<sub_group_size_key,
127143
static constexpr uint32_t value = Size;
128144
};
129145

146+
template <aspect... Aspects>
147+
struct property_value<device_has_key,
148+
std::integral_constant<aspect, Aspects>...> {
149+
using key_t = device_has_key;
150+
static constexpr std::array<aspect, sizeof...(Aspects)> value{Aspects...};
151+
};
152+
130153
template <size_t Dim0, size_t... Dims>
131154
inline constexpr work_group_size_key::value_t<Dim0, Dims...> work_group_size;
132155

@@ -137,10 +160,14 @@ inline constexpr work_group_size_hint_key::value_t<Dim0, Dims...>
137160
template <uint32_t Size>
138161
inline constexpr sub_group_size_key::value_t<Size> sub_group_size;
139162

163+
template <aspect... Aspects>
164+
inline constexpr device_has_key::value_t<Aspects...> device_has;
165+
140166
template <> struct is_property_key<work_group_size_key> : std::true_type {};
141167
template <>
142168
struct is_property_key<work_group_size_hint_key> : std::true_type {};
143169
template <> struct is_property_key<sub_group_size_key> : std::true_type {};
170+
template <> struct is_property_key<device_has_key> : std::true_type {};
144171

145172
namespace detail {
146173
template <> struct PropertyToKind<work_group_size_key> {
@@ -152,13 +179,17 @@ template <> struct PropertyToKind<work_group_size_hint_key> {
152179
template <> struct PropertyToKind<sub_group_size_key> {
153180
static constexpr PropKind Kind = PropKind::SubGroupSize;
154181
};
182+
template <> struct PropertyToKind<device_has_key> {
183+
static constexpr PropKind Kind = PropKind::DeviceHas;
184+
};
155185

156186
template <>
157187
struct IsCompileTimeProperty<work_group_size_key> : std::true_type {};
158188
template <>
159189
struct IsCompileTimeProperty<work_group_size_hint_key> : std::true_type {};
160190
template <>
161191
struct IsCompileTimeProperty<sub_group_size_key> : std::true_type {};
192+
template <> struct IsCompileTimeProperty<device_has_key> : std::true_type {};
162193

163194
template <size_t Dim0, size_t... Dims>
164195
struct PropertyMetaInfo<work_group_size_key::value_t<Dim0, Dims...>> {
@@ -175,6 +206,12 @@ struct PropertyMetaInfo<sub_group_size_key::value_t<Size>> {
175206
static constexpr const char *name = "sycl-sub-group-size";
176207
static constexpr uint32_t value = Size;
177208
};
209+
template <aspect... Aspects>
210+
struct PropertyMetaInfo<device_has_key::value_t<Aspects...>> {
211+
static constexpr const char *name = "sycl-device-has";
212+
static constexpr const char *value =
213+
SizeListToStr<static_cast<size_t>(Aspects)...>::value;
214+
};
178215

179216
template <typename T, typename = void>
180217
struct HasKernelPropertiesGetMethod : std::false_type {};
@@ -193,3 +230,15 @@ struct HasKernelPropertiesGetMethod<
193230
} // namespace ext
194231
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
195232
} // namespace sycl
233+
234+
#ifdef __SYCL_DEVICE_ONLY__
235+
#define SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(PROP) \
236+
[[__sycl_detail__::add_ir_attributes_function( \
237+
{"sycl-device-has"}, \
238+
sycl::ext::oneapi::experimental::detail::PropertyMetaInfo< \
239+
std::remove_cv_t<std::remove_reference_t<decltype(PROP)>>>::name, \
240+
sycl::ext::oneapi::experimental::detail::PropertyMetaInfo< \
241+
std::remove_cv_t<std::remove_reference_t<decltype(PROP)>>>::value)]]
242+
#else
243+
#define SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(PROP)
244+
#endif

sycl/include/sycl/ext/oneapi/properties/property.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ enum PropKind : uint32_t {
172172
WorkGroupSize = 6,
173173
WorkGroupSizeHint = 7,
174174
SubGroupSize = 8,
175+
DeviceHas = 9,
175176
// PropKindSize must always be the last value.
176-
PropKindSize = 9,
177+
PropKindSize = 10,
177178
};
178179

179180
// This trait must be specialized for all properties and must have a unique

sycl/include/sycl/ext/oneapi/properties/property_utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace oneapi {
2020
namespace experimental {
2121

2222
// Forward declaration
23-
template <typename PropertyT, typename T, typename... Ts> struct property_value;
23+
template <typename PropertyT, typename... Ts> struct property_value;
2424

2525
namespace detail {
2626

sycl/include/sycl/ext/oneapi/properties/property_value.hpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,26 @@ namespace oneapi {
1818
namespace experimental {
1919
namespace detail {
2020

21-
// Base class for property values with a single type value.
22-
struct SingleTypePropertyValueBase {};
23-
24-
// Base class for properties with 0 or more than 1 values.
25-
struct EmptyPropertyValueBase {};
26-
2721
// Base class for property values with a single non-type value
28-
template <typename T> struct SingleNontypePropertyValueBase {
22+
template <typename T, typename = void> struct SingleNontypePropertyValueBase {};
23+
24+
template <typename T>
25+
struct SingleNontypePropertyValueBase<T, std::enable_if_t<HasValue<T>::value>> {
2926
static constexpr auto value = T::value;
3027
};
3128

32-
// Helper class for property values with a single value
29+
// Helper base class for property_value.
30+
template <typename... Ts> struct PropertyValueBase {};
31+
3332
template <typename T>
34-
struct SinglePropertyValue
35-
: public sycl::detail::conditional_t<HasValue<T>::value,
36-
SingleNontypePropertyValueBase<T>,
37-
SingleTypePropertyValueBase> {
33+
struct PropertyValueBase<T> : public detail::SingleNontypePropertyValueBase<T> {
3834
using value_t = T;
3935
};
4036

4137
} // namespace detail
4238

43-
template <typename PropertyT, typename T = void, typename... Ts>
44-
struct property_value
45-
: public sycl::detail::conditional_t<
46-
sizeof...(Ts) == 0 && !std::is_same<T, void>::value,
47-
detail::SinglePropertyValue<T>, detail::EmptyPropertyValueBase> {
39+
template <typename PropertyT, typename... Ts>
40+
struct property_value : public detail::PropertyValueBase<Ts...> {
4841
using key_t = PropertyT;
4942
};
5043

sycl/include/sycl/handler.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,10 +1756,6 @@ class __SYCL_EXPORT handler {
17561756
KernelFunc);
17571757
}
17581758

1759-
// "if constexpr" simplifies implementation/increases readability in comparison
1760-
// with SFINAE-based approach.
1761-
#if __cplusplus >= 201703L
1762-
17631759
/// Defines and invokes a SYCL kernel function for the specified nd_range.
17641760
///
17651761
/// The SYCL kernel function is defined as a lambda function or a named
@@ -1982,7 +1978,6 @@ class __SYCL_EXPORT handler {
19821978
});
19831979
} // end while (NWorkItems > 1)
19841980
}
1985-
#endif // __cplusplus >= 201703L
19861981

19871982
/// Hierarchical kernel invocation method of a kernel defined as a lambda
19881983
/// encoding the body of each work-group to launch.

sycl/include/sycl/properties/accessor_properties.hpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ template <typename DataT, int Dimensions, access::mode AccessMode,
118118
access::target AccessTarget, access::placeholder IsPlaceholder,
119119
typename PropertyListT>
120120
class accessor;
121-
template <typename DataT, int Dimensions, access::mode AccessMode,
122-
access::target AccessTarget, access::placeholder IsPlaceholder>
123-
class image_accessor;
124121
template <typename DataT, int Dimensions, access::mode AccessMode>
125122
class host_accessor;
126123

@@ -168,19 +165,6 @@ struct is_property_of<ext::intel::property::buffer_location,
168165
IsPlaceholder, PropertyListT>> : std::true_type {
169166
};
170167

171-
template <typename DataT, int Dimensions, access::mode AccessMode,
172-
access::target AccessTarget, access::placeholder IsPlaceholder>
173-
struct is_property_of<
174-
property::noinit,
175-
image_accessor<DataT, Dimensions, AccessMode, AccessTarget, IsPlaceholder>>
176-
: std::true_type {};
177-
template <typename DataT, int Dimensions, access::mode AccessMode,
178-
access::target AccessTarget, access::placeholder IsPlaceholder>
179-
struct is_property_of<
180-
property::no_init,
181-
image_accessor<DataT, Dimensions, AccessMode, AccessTarget, IsPlaceholder>>
182-
: std::true_type {};
183-
184168
template <typename DataT, int Dimensions, access::mode AccessMode>
185169
struct is_property_of<property::noinit,
186170
host_accessor<DataT, Dimensions, AccessMode>>

sycl/include/sycl/reduction.hpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ template <typename T> struct AreAllButLastReductions<T> {
4949
static constexpr bool value = !IsReduction<T>::value;
5050
};
5151
} // namespace detail
52-
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
53-
} // namespace sycl
54-
55-
#if __cplusplus >= 201703L
56-
// Entire feature is dependent on C++17. We still have to make the trait above
57-
// available as queue shortcuts use them unconditionally, including on
58-
// non-reduction path.
59-
namespace sycl {
60-
__SYCL_INLINE_VER_NAMESPACE(_V1) {
61-
6252

6353
/// Class that is used to represent objects that are passed to user's lambda
6454
/// functions and representing users' reduction variable.
@@ -2477,7 +2467,6 @@ auto reduction(T *Var, const T &Identity, BinaryOperation Combiner,
24772467
InitializeToIdentity);
24782468
}
24792469

2480-
#if __cplusplus >= 201703L
24812470
/// Constructs a reduction object using the reduction variable referenced by
24822471
/// the given sycl::span \p Span, reduction operation \p Combiner, and
24832472
/// optional reduction properties.
@@ -2524,9 +2513,5 @@ auto reduction(span<T, Extent> Span, const T &Identity,
25242513
return detail::make_reduction<BinaryOperation, 1, Extent>(
25252514
Span.data(), Identity, Combiner, InitializeToIdentity);
25262515
}
2527-
#endif
2528-
25292516
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
25302517
} // namespace sycl
2531-
2532-
#endif // __cplusplus >= 201703L

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5632,7 +5632,10 @@ static pi_result EventCreate(pi_context Context, pi_queue Queue,
56325632
pi_result piEventCreate(pi_context Context, pi_event *RetEvent) {
56335633
pi_result Result = EventCreate(Context, nullptr, true, RetEvent);
56345634
(*RetEvent)->RefCountExternal++;
5635-
return Result;
5635+
if (Result != PI_SUCCESS)
5636+
return Result;
5637+
ZE_CALL(zeEventHostSignal, ((*RetEvent)->ZeEvent));
5638+
return PI_SUCCESS;
56365639
}
56375640

56385641
pi_result piEventGetInfo(pi_event Event, pi_event_info ParamName,
@@ -8812,10 +8815,29 @@ pi_result _pi_buffer::getZeHandle(char *&ZeHandle, access_mode_t AccessMode,
88128815
LastDeviceWithValidAllocation = Device;
88138816
return PI_SUCCESS;
88148817
}
8818+
// Reads user setting on how to deal with buffers in contexts where
8819+
// all devices have the same root-device. Returns "true" if the
8820+
// preference is to have allocate on each [sub-]device and migrate
8821+
// normally (copy) to other sub-devices as needed. Returns "false"
8822+
// if the preference is to have single root-device allocations
8823+
// serve the needs of all [sub-]devices, meaning potentially more
8824+
// cross-tile traffic.
8825+
//
8826+
static const bool SingleRootDeviceBufferMigration = [] {
8827+
const char *EnvStr =
8828+
std::getenv("SYCL_PI_LEVEL_ZERO_SINGLE_ROOT_DEVICE_BUFFER_MIGRATION");
8829+
if (EnvStr)
8830+
return (std::stoi(EnvStr) != 0);
8831+
// The default is to migrate normally, which may not always be the
8832+
// best option (depends on buffer access patterns), but is an
8833+
// overall win on the set of the available benchmarks.
8834+
return true;
8835+
}();
88158836

88168837
// Peform actual device allocation as needed.
88178838
if (!Allocation.ZeHandle) {
8818-
if (Context->SingleRootDevice && Context->SingleRootDevice != Device) {
8839+
if (!SingleRootDeviceBufferMigration && Context->SingleRootDevice &&
8840+
Context->SingleRootDevice != Device) {
88198841
// If all devices in the context are sub-devices of the same device
88208842
// then we reuse root-device allocation by all sub-devices in the
88218843
// context.

0 commit comments

Comments
 (0)