DPC++ Runtime
Runtime libraries for oneAPI DPC++
kernel.cpp
Go to the documentation of this file.
1 //==--------------- kernel.cpp --- SYCL kernel -----------------------------==//
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 
11 #include <detail/kernel_impl.hpp>
12 #include <sycl/detail/export.hpp>
13 #include <sycl/detail/pi.h>
14 #include <sycl/kernel.hpp>
15 #include <sycl/program.hpp>
16 
17 namespace sycl {
19 
20 kernel::kernel(cl_kernel ClKernel, const context &SyclContext)
21  : impl(std::make_shared<detail::kernel_impl>(
22  detail::pi::cast<detail::RT::PiKernel>(ClKernel),
23  detail::getSyclObjImpl(SyclContext), nullptr)) {}
24 
25 cl_kernel kernel::get() const { return impl->get(); }
26 
27 bool kernel::is_host() const { return impl->is_host(); }
28 
29 context kernel::get_context() const {
30  return impl->get_info<info::kernel::context>();
31 }
32 
33 backend kernel::get_backend() const noexcept { return getImplBackend(impl); }
34 
35 kernel_bundle<sycl::bundle_state::executable>
36 kernel::get_kernel_bundle() const {
37  return detail::createSyclObjFromImpl<
38  kernel_bundle<sycl::bundle_state::executable>>(impl->get_kernel_bundle());
39 }
40 
41 program kernel::get_program() const {
42  return impl->get_info<info::kernel::program>();
43 }
44 
45 template <typename Param>
46 typename detail::is_kernel_info_desc<Param>::return_type
47 kernel::get_info() const {
48  return impl->get_info<Param>();
49 }
50 
51 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
52  template __SYCL_EXPORT ReturnT kernel::get_info<info::kernel::Desc>() const;
53 
54 #include <sycl/info/kernel_traits.def>
55 
56 #undef __SYCL_PARAM_TRAITS_SPEC
57 
58 template <typename Param>
59 typename detail::is_kernel_device_specific_info_desc<Param>::return_type
60 kernel::get_info(const device &Dev) const {
61  return impl->get_info<Param>(Dev);
62 }
63 
64 template <typename Param>
65 typename detail::is_kernel_device_specific_info_desc<
66  Param>::with_input_return_type
67 kernel::get_info(const device &Device, const range<3> &WGSize) const {
68  return impl->get_info<Param>(Device, WGSize);
69 }
70 
71 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
72  template __SYCL_EXPORT ReturnT kernel::get_info<info::DescType::Desc>( \
73  const device &) const;
74 #define __SYCL_PARAM_TRAITS_SPEC_WITH_INPUT(DescType, Desc, ReturnT, InputT, \
75  PiCode) \
76  template __SYCL_EXPORT ReturnT kernel::get_info<info::DescType::Desc>( \
77  const device &, const InputT &) const;
78 
79 #include <sycl/info/kernel_device_specific_traits.def>
80 
81 #undef __SYCL_PARAM_TRAITS_SPEC
82 #undef __SYCL_PARAM_TRAITS_SPEC_WITH_INPUT
83 
84 kernel::kernel(std::shared_ptr<detail::kernel_impl> Impl) : impl(Impl) {}
85 
86 pi_native_handle kernel::getNative() const { return impl->getNative(); }
87 
88 pi_native_handle kernel::getNativeImpl() const { return impl->getNative(); }
89 
90 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
91 } // namespace sycl
pi.h
sycl::__SYCL_INLINE_VER_NAMESPACE
__SYCL_INLINE_VER_NAMESPACE(_V1)
Definition: access.hpp:14
sycl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cast
To cast(From value)
Definition: pi_opencl.cpp:41
export.hpp
std::get
constexpr tuple_element< I, tuple< Types... > >::type & get(sycl::detail::tuple< Types... > &Arg) noexcept
Definition: tuple.hpp:199
program.hpp
kernel.hpp
Device
@ Device
Definition: usm_allocator.hpp:14
pi_native_handle
uintptr_t pi_native_handle
Definition: pi.h:100
std
Definition: accessor.hpp:2617
kernel_bundle_impl.hpp
backend_impl.hpp
kernel_impl.hpp