DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
device_binary_image.hpp
Go to the documentation of this file.
1 //==----- device_binary_image.hpp --- SYCL device binary image abstraction -==//
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 #pragma once
9 
11 #include <CL/sycl/detail/pi.hpp>
12 
13 #include <memory>
14 
16 namespace sycl {
17 namespace detail {
18 
19 // SYCL RT wrapper over PI binary image.
21 public:
23  : pi::DeviceBinaryImage(), ModuleHandle(ModuleHandle) {}
25  : pi::DeviceBinaryImage(Bin), ModuleHandle(ModuleHandle) {}
26  // Explicitly delete copy constructor/operator= to avoid unintentional copies
27  RTDeviceBinaryImage(const RTDeviceBinaryImage &) = delete;
28  RTDeviceBinaryImage &operator=(const RTDeviceBinaryImage &) = delete;
29  // Explicitly retain move constructors to facilitate potential moves across
30  // collections
32  RTDeviceBinaryImage &operator=(RTDeviceBinaryImage &&) = default;
33 
34  OSModuleHandle getOSModuleHandle() const { return ModuleHandle; }
35 
36  ~RTDeviceBinaryImage() override {}
37 
38  bool supportsSpecConstants() const {
39  return getFormat() == PI_DEVICE_BINARY_TYPE_SPIRV;
40  }
41 
42  const pi_device_binary_struct &getRawData() const { return *get(); }
43 
44  void print() const override {
46  std::cerr << " OSModuleHandle=" << ModuleHandle << "\n";
47  }
48 
49 protected:
51 };
52 
53 // Dynamically allocated device binary image, which de-allocates its binary
54 // data in destructor.
56 public:
57  DynRTDeviceBinaryImage(std::unique_ptr<char[]> &&DataPtr, size_t DataSize,
58  OSModuleHandle M);
59  ~DynRTDeviceBinaryImage() override;
60 
61  void print() const override {
63  std::cerr << " DYNAMICALLY CREATED\n";
64  }
65 
66 protected:
67  std::unique_ptr<char[]> Data;
68 };
69 
70 } // namespace detail
71 } // namespace sycl
72 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::detail::pi::print
std::enable_if<!std::is_pointer< T >::value, void >::type print(T val)
Definition: plugin_printers.hpp:24
cl::sycl::detail::RTDeviceBinaryImage::ModuleHandle
OSModuleHandle ModuleHandle
Definition: device_binary_image.hpp:50
cl::sycl::detail::RTDeviceBinaryImage::supportsSpecConstants
bool supportsSpecConstants() const
Definition: device_binary_image.hpp:38
PI_DEVICE_BINARY_TYPE_SPIRV
static constexpr pi_device_binary_type PI_DEVICE_BINARY_TYPE_SPIRV
Definition: pi.h:674
cl::sycl::detail::RTDeviceBinaryImage
Definition: device_binary_image.hpp:20
cl::sycl::detail::RTDeviceBinaryImage::print
void print() const override
Definition: device_binary_image.hpp:44
cl::sycl::detail::RTDeviceBinaryImage::RTDeviceBinaryImage
RTDeviceBinaryImage(pi_device_binary Bin, OSModuleHandle ModuleHandle)
Definition: device_binary_image.hpp:24
cl::sycl::detail::DynRTDeviceBinaryImage
Definition: device_binary_image.hpp:55
os_util.hpp
cl::sycl::detail::RTDeviceBinaryImage::getOSModuleHandle
OSModuleHandle getOSModuleHandle() const
Definition: device_binary_image.hpp:34
cl::sycl::detail::RTDeviceBinaryImage::getRawData
const pi_device_binary_struct & getRawData() const
Definition: device_binary_image.hpp:42
pi.hpp
cl::sycl::detail::DynRTDeviceBinaryImage::print
void print() const override
Definition: device_binary_image.hpp:61
pi_device_binary_struct
This struct is a record of the device binary information.
Definition: pi.h:743
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::DynRTDeviceBinaryImage::Data
std::unique_ptr< char[]> Data
Definition: device_binary_image.hpp:67
cl::sycl::detail::pi::DeviceBinaryImage
Definition: pi.hpp:245
std::get
constexpr tuple_element< I, tuple< Types... > >::type & get(cl::sycl::detail::tuple< Types... > &Arg) noexcept
Definition: tuple.hpp:199
cl::sycl::detail::OSModuleHandle
intptr_t OSModuleHandle
Uniquely identifies an operating system module (executable or a dynamic library)
Definition: os_util.hpp:48
cl::sycl::detail::RTDeviceBinaryImage::RTDeviceBinaryImage
RTDeviceBinaryImage(OSModuleHandle ModuleHandle)
Definition: device_binary_image.hpp:22
cl::sycl::detail::RTDeviceBinaryImage::~RTDeviceBinaryImage
~RTDeviceBinaryImage() override
Definition: device_binary_image.hpp:36
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12