Skip to content

Commit 217270c

Browse files
committed
Merge branch 'device_image_backend_content' of https://github.com/lbushi25/llvm into device_image_backend_content
2 parents 0629c6c + 464174d commit 217270c

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

sycl/include/sycl/kernel_bundle.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <utility> // for move
3838
#include <variant> // for hash
3939
#include <vector> // for vector
40+
#include <span> // for span
4041

4142
namespace sycl {
4243
inline namespace _V1 {
@@ -117,6 +118,12 @@ class __SYCL_EXPORT device_image_plain {
117118
protected:
118119
detail::DeviceImageImplPtr impl;
119120

121+
backend get_backend() const;
122+
123+
const std::byte *get_BinaryStart() const;
124+
125+
const std::byte *get_BinaryEnd() const;
126+
120127
template <class Obj>
121128
friend const decltype(Obj::impl) &
122129
detail::getSyclObjImpl(const Obj &SyclObject);
@@ -145,6 +152,26 @@ class device_image : public detail::device_image_plain,
145152
return device_image_plain::has_kernel(KernelID, Dev);
146153
}
147154

155+
backend ext_oneapi_get_backend() const noexcept {
156+
return device_image_plain::get_backend();
157+
}
158+
159+
template <sycl::bundle_state T = State,
160+
typename = std::enable_if_t<T == bundle_state::executable>>
161+
std::vector<std::byte> ext_oneapi_get_backend_content() const {
162+
return std::vector(device_image_plain::get_BinaryStart(),
163+
device_image_plain::get_BinaryEnd());
164+
}
165+
166+
#ifdef __cpp_lib_span
167+
template <sycl::bundle_state T = State,
168+
typename = std::enable_if_t<T == bundle_state::executable>>
169+
std::span<std::byte> ext_oneapi_get_content_backend_view() const {
170+
return std::span(device_image_plain::get_BinaryStart(),
171+
device_image_plain::get_BinaryEnd());
172+
}
173+
#endif
174+
148175
private:
149176
device_image(detail::DeviceImageImplPtr Impl)
150177
: device_image_plain(std::move(Impl)) {}

sycl/source/kernel_bundle.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ ur_native_handle_t device_image_plain::getNative() const {
4545
return impl->getNative();
4646
}
4747

48+
backend device_image_plain::get_backend() const {
49+
return impl->get_context().get_backend();
50+
}
51+
52+
const std::byte *device_image_plain::get_BinaryStart() const {
53+
return reinterpret_cast<const std::byte *>(
54+
impl->get_bin_image_ref()->getRawData().BinaryStart);
55+
}
56+
57+
const std::byte *device_image_plain::get_BinaryEnd() const {
58+
return reinterpret_cast<const std::byte *>(
59+
impl->get_bin_image_ref()->getRawData().BinaryEnd);
60+
}
61+
4862
////////////////////////////
4963
///// kernel_bundle_plain
5064
///////////////////////////

0 commit comments

Comments
 (0)