Skip to content

Commit 1910c7c

Browse files
committed
Merge branch 'sycl' into improve-memset
2 parents 6721497 + 27dab62 commit 1910c7c

File tree

84 files changed

+532
-314
lines changed

Some content is hidden

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

84 files changed

+532
-314
lines changed

libdevice/nativecpu_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "device.h"
1818
#include <cstdint>
1919
#include <sycl/__spirv/spirv_ops.hpp>
20-
#include <sycl/types.hpp>
20+
#include <sycl/vector.hpp>
2121

2222
// including state definition from Native CPU UR adapter
2323
#include "nativecpu_state.hpp"

sycl/include/sycl/aliases.hpp

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

1111
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
12-
#include <sycl/half_type.hpp> // for half
1312

1413
#include <cstdint> // for uint8_t, int16_t, int32_t
1514

sycl/include/sycl/backend.hpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,17 @@
1515
#include <sycl/buffer.hpp> // for buffer_allocator
1616
#include <sycl/context.hpp> // for context, get_na...
1717
#include <sycl/detail/backend_traits.hpp> // for InteropFeatureS...
18-
#include <sycl/detail/cl.h> // for _cl_event
1918
#include <sycl/detail/defines_elementary.hpp> // for __SYCL_DEPRECATED
2019
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
2120
#include <sycl/detail/impl_utils.hpp> // for createSyclObjFr...
2221
#include <sycl/device.hpp> // for device, get_native
2322
#include <sycl/event.hpp> // for event, get_native
2423
#include <sycl/exception.hpp> // for make_error_code
2524
#include <sycl/feature_test.hpp> // for SYCL_BACKEND_OP...
26-
#include <sycl/handler.hpp> // for buffer
2725
#include <sycl/image.hpp> // for image, image_al...
28-
#include <sycl/kernel.hpp> // for kernel, get_native
2926
#include <sycl/kernel_bundle.hpp> // for kernel_bundle
3027
#include <sycl/kernel_bundle_enums.hpp> // for bundle_state
3128
#include <sycl/platform.hpp> // for platform, get_n...
32-
#include <sycl/property_list.hpp> // for property_list
3329
#include <sycl/queue.hpp> // for queue, get_native
3430
#include <ur_api.h> // for ur_native_handle_t
3531

@@ -60,13 +56,12 @@
6056
namespace sycl {
6157
inline namespace _V1 {
6258

59+
class property_list;
60+
6361
namespace detail {
6462
// TODO each backend can have its own custom errc enumeration
6563
// but the details for this are not fully specified yet
6664
enum class backend_errc : unsigned int {};
67-
68-
// Convert from UR backend to SYCL backend enum
69-
backend convertUrBackend(ur_platform_backend_t UrBackend);
7065
} // namespace detail
7166

7267
template <backend Backend> class backend_traits {
@@ -78,14 +73,6 @@ template <backend Backend> class backend_traits {
7873
using return_type = typename detail::BackendReturn<Backend, T>::type;
7974
};
8075

81-
template <backend Backend, typename SyclType>
82-
using backend_input_t =
83-
typename backend_traits<Backend>::template input_type<SyclType>;
84-
85-
template <backend Backend, typename SyclType>
86-
using backend_return_t =
87-
typename backend_traits<Backend>::template return_type<SyclType>;
88-
8976
namespace detail {
9077
template <backend Backend, typename DataT, int Dimensions, typename AllocatorT>
9178
struct BufferInterop {

sycl/include/sycl/builtins_esimd.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <sycl/detail/common.hpp>
1212
#include <sycl/detail/generic_type_traits.hpp>
1313
#include <sycl/ext/intel/esimd/detail/math_intrin.hpp>
14-
#include <sycl/types.hpp>
14+
#include <sycl/vector.hpp>
1515

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

sycl/include/sycl/builtins_utils_vec.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
#include <sycl/builtins_utils_scalar.hpp>
1414

1515
#include <sycl/detail/type_traits.hpp>
16+
#include <sycl/detail/vector_convert.hpp>
1617
#include <sycl/marray.hpp> // for marray
17-
#include <sycl/types.hpp> // for vec
18+
#include <sycl/vector.hpp> // for vec
1819

1920
namespace sycl {
2021
inline namespace _V1 {

sycl/include/sycl/detail/backend_traits.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88

99
#pragma once
1010

11-
#include <sycl/backend_types.hpp>
12-
1311
namespace sycl {
1412
inline namespace _V1 {
13+
enum class backend : char;
1514
namespace detail {
1615

1716
template <backend Backend, typename SYCLObjectT> struct interop;

sycl/include/sycl/detail/device_filter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#pragma once
1010

11-
#include <sycl/backend_types.hpp>
1211
#include <sycl/detail/defines.hpp>
1312
#include <sycl/info/info_desc.hpp>
1413

@@ -18,6 +17,7 @@
1817

1918
namespace sycl {
2019
inline namespace _V1 {
20+
enum class backend : char;
2121
namespace detail {
2222

2323
// ---------------------------------------

sycl/include/sycl/detail/image_accessor_util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <sycl/image.hpp> // for image_channel_type
2424
#include <sycl/range.hpp> // for range
2525
#include <sycl/sampler.hpp> // for addressing_mode, coor...
26-
#include <sycl/types.hpp> // for vec, operator*, round...
26+
#include <sycl/vector.hpp> // for vec, operator*, round...
2727

2828
#include <cstdint> // for int32_t, uint16_t
2929
#include <stddef.h> // for size_t

sycl/include/sycl/detail/optional.hpp

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
//==-------- optional.hpp - limited variant of std::optional -------- C++ --==//
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 <optional>
12+
#include <type_traits>
13+
14+
namespace sycl {
15+
inline namespace _V1 {
16+
namespace detail {
17+
18+
// ABI-stable implementation of optional to avoid reliance on potentially
19+
// differing implementations of std::optional when crossing the library
20+
// boundary.
21+
template <typename T> class optional {
22+
public:
23+
constexpr optional() noexcept {}
24+
constexpr optional(std::nullopt_t) noexcept : optional() {}
25+
26+
template <typename U>
27+
constexpr optional(const optional<U> &Other)
28+
: ContainsValue{Other.ContainsValue} {
29+
new (Storage) T(Other.Value);
30+
}
31+
template <typename U>
32+
constexpr optional(optional<U> &&Other)
33+
: ContainsValue{std::move(Other.ContainsValue)} {
34+
new (Storage) T(std::move(Other.Value));
35+
}
36+
37+
constexpr optional(T &&Value) : ContainsValue{true} {
38+
new (Storage) T(std::move(Value));
39+
}
40+
41+
constexpr optional(const T &Value) : ContainsValue{true} {
42+
new (Storage) T(Value);
43+
}
44+
45+
template <typename U>
46+
constexpr optional(const std::optional<U> &Other) : ContainsValue{Other} {
47+
if (Other)
48+
new (Storage) T(*Other);
49+
}
50+
51+
~optional() {
52+
if (has_value())
53+
reinterpret_cast<T *>(Storage)->~T();
54+
}
55+
56+
optional &operator=(std::nullopt_t) noexcept {
57+
if (has_value())
58+
reinterpret_cast<T *>(Storage)->~T();
59+
ContainsValue = false;
60+
return *this;
61+
}
62+
63+
template <typename U> optional &operator=(const optional<U> &Other) {
64+
if (has_value())
65+
reinterpret_cast<T *>(Storage)->~T();
66+
ContainsValue = Other;
67+
new (Storage) T(Other.Value);
68+
return *this;
69+
}
70+
template <typename U> optional &operator=(optional<U> &&Other) noexcept {
71+
if (has_value())
72+
reinterpret_cast<T *>(Storage)->~T();
73+
ContainsValue = Other;
74+
new (Storage) T(std::move(Other.Value));
75+
return *this;
76+
}
77+
78+
optional &operator=(T &&Value) {
79+
if (has_value())
80+
reinterpret_cast<T *>(Storage)->~T();
81+
ContainsValue = true;
82+
new (Storage) T(std::move(Value));
83+
return *this;
84+
}
85+
86+
optional &operator=(const T &Value) {
87+
if (has_value())
88+
reinterpret_cast<T *>(Storage)->~T();
89+
ContainsValue = true;
90+
new (Storage) T(Value);
91+
return *this;
92+
}
93+
94+
template <typename U> optional &operator=(const std::optional<U> &Other) {
95+
if (has_value())
96+
reinterpret_cast<T *>(Storage)->~T();
97+
ContainsValue = Other;
98+
if (Other)
99+
new (Storage) T(*Other);
100+
return *this;
101+
}
102+
103+
constexpr bool has_value() const noexcept { return ContainsValue; }
104+
constexpr explicit operator bool() const noexcept { return has_value(); }
105+
106+
constexpr T &value() & {
107+
if (!has_value())
108+
throw std::bad_optional_access{};
109+
return *reinterpret_cast<T *>(Storage);
110+
}
111+
constexpr const T &value() const & {
112+
if (!has_value())
113+
throw std::bad_optional_access{};
114+
return *reinterpret_cast<const T *>(Storage);
115+
}
116+
constexpr T &&value() && {
117+
if (!has_value())
118+
throw std::bad_optional_access{};
119+
return std::move(*reinterpret_cast<T *>(Storage));
120+
}
121+
constexpr const T &&value() const && {
122+
if (!has_value())
123+
throw std::bad_optional_access{};
124+
return std::move(*reinterpret_cast<const T *>(Storage));
125+
}
126+
127+
template <class U> constexpr T value_or(U &&DefaultVal) {
128+
return has_value() ? value() : static_cast<T>(std::forward<U>(DefaultVal));
129+
}
130+
template <class U> constexpr T value_or(U &&DefaultVal) const {
131+
return has_value() ? std::move(value())
132+
: static_cast<T>(std::forward<U>(DefaultVal));
133+
}
134+
135+
constexpr T &operator*() & { return value(); }
136+
constexpr const T &operator*() const & { return value(); }
137+
constexpr T &&operator*() && { return value(); }
138+
constexpr const T &&operator*() const && { return value(); }
139+
140+
private:
141+
alignas(alignof(T)) char Storage[sizeof(T)] = {0};
142+
bool ContainsValue = false;
143+
};
144+
145+
} // namespace detail
146+
} // namespace _V1
147+
} // namespace sycl

sycl/include/sycl/detail/ur.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#pragma once
1616

17-
#include <sycl/backend_types.hpp>
1817
#include <sycl/detail/export.hpp>
1918
#include <sycl/detail/os_util.hpp>
2019
#include <ur_api.h>
@@ -42,6 +41,7 @@ struct trace_event_data_t;
4241
namespace sycl {
4342
inline namespace _V1 {
4443

44+
enum class backend : char;
4545
class context;
4646

4747
namespace detail {

sycl/include/sycl/detail/util.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
#include <cstring>
1717
#include <mutex>
18+
#include <string>
19+
#include <type_traits>
20+
#include <utility>
1821
#include <vector>
1922

2023
namespace sycl {
@@ -83,6 +86,40 @@ template <> struct ABINeutralT<std::vector<std::string>> {
8386
};
8487

8588
template <typename T> using ABINeutralT_t = typename ABINeutralT<T>::type;
89+
90+
template <typename ParamT> auto convert_to_abi_neutral(ParamT &&Info) {
91+
using ParamNoRef = std::remove_reference_t<ParamT>;
92+
if constexpr (std::is_same_v<ParamNoRef, std::string>) {
93+
return detail::string{Info};
94+
} else if constexpr (std::is_same_v<ParamNoRef, std::vector<std::string>>) {
95+
std::vector<detail::string> Res;
96+
Res.reserve(Info.size());
97+
for (std::string &Str : Info) {
98+
Res.push_back(detail::string{Str});
99+
}
100+
return Res;
101+
} else {
102+
return std::forward<ParamT>(Info);
103+
}
104+
}
105+
106+
template <typename ParamT> auto convert_from_abi_neutral(ParamT &&Info) {
107+
using ParamNoRef = std::remove_reference_t<ParamT>;
108+
if constexpr (std::is_same_v<ParamNoRef, detail::string>) {
109+
return Info.c_str();
110+
} else if constexpr (std::is_same_v<ParamNoRef,
111+
std::vector<detail::string>>) {
112+
std::vector<std::string> Res;
113+
Res.reserve(Info.size());
114+
for (detail::string &Str : Info) {
115+
Res.push_back(Str.c_str());
116+
}
117+
return Res;
118+
} else {
119+
return std::forward<ParamT>(Info);
120+
}
121+
}
122+
86123
} // namespace detail
87124
} // namespace _V1
88125
} // namespace sycl

sycl/include/sycl/device.hpp

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

99
#pragma once
1010

11-
#include <sycl/aspects.hpp>
1211
#include <sycl/backend_types.hpp>
1312
#include <sycl/detail/defines_elementary.hpp>
1413
#include <sycl/detail/export.hpp>
@@ -21,9 +20,12 @@
2120
#include <sycl/ext/oneapi/experimental/device_architecture.hpp>
2221
#include <sycl/info/info_desc.hpp>
2322
#include <sycl/kernel_bundle_enums.hpp>
24-
#include <sycl/platform.hpp>
2523
#include <ur_api.h>
2624

25+
#ifdef __SYCL_INTERNAL_API
26+
#include <sycl/detail/cl.h>
27+
#endif
28+
2729
#include <cstddef>
2830
#include <memory>
2931
#include <string>
@@ -35,7 +37,7 @@
3537
namespace sycl {
3638
inline namespace _V1 {
3739
// Forward declarations
38-
class device_selector;
40+
class platform;
3941
template <backend BackendName, class SyclObjectT>
4042
auto get_native(const SyclObjectT &Obj)
4143
-> backend_return_t<BackendName, SyclObjectT>;

sycl/include/sycl/ext/intel/esimd/detail/memory_intrin.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <sycl/ext/intel/esimd/common.hpp>
2525
#include <sycl/ext/intel/esimd/detail/types.hpp>
2626
#include <sycl/ext/intel/esimd/detail/util.hpp>
27-
#include <sycl/types.hpp>
27+
#include <sycl/vector.hpp>
2828

2929
#include <cstdint>
3030

sycl/include/sycl/ext/intel/fpga_device_selector.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <sycl/device.hpp>
1212
#include <sycl/device_selector.hpp>
13+
#include <sycl/platform.hpp>
1314

1415
#include <string>
1516
#include <string_view>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#pragma once
1010

11-
#include <sycl/backend.hpp>
11+
#include <sycl/backend_types.hpp>
1212
#include <sycl/detail/backend_traits_hip.hpp>
1313

1414
namespace sycl {

0 commit comments

Comments
 (0)