DPC++ Runtime
Runtime libraries for oneAPI DPC++
kernel.hpp
Go to the documentation of this file.
1
//==--------------- kernel.hpp --- 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
9
#pragma once
10
11
#include <
CL/sycl/detail/common.hpp
>
12
#include <
CL/sycl/detail/export.hpp
>
13
#include <
CL/sycl/detail/pi.h
>
14
#include <
CL/sycl/info/info_desc.hpp
>
15
#include <
CL/sycl/kernel_bundle_enums.hpp
>
16
#include <
CL/sycl/stl.hpp
>
17
18
#include <memory>
19
20
__SYCL_INLINE_NAMESPACE
(
cl
) {
21
namespace
sycl
{
22
// Forward declaration
23
#ifdef __SYCL_INTERNAL_API
24
class
program;
25
#endif
26
class
context
;
27
template
<backend Backend>
class
backend_traits;
28
template
<bundle_state State>
class
kernel_bundle
;
29
30
namespace
detail {
31
class
kernel_impl
;
32
35
class
auto_name
{};
36
40
template
<
typename
Name,
typename
Type>
struct
get_kernel_name_t
{
41
using
name
= Name;
42
static_assert(
43
!std::is_same<Name, auto_name>::value,
44
"No kernel name provided without -fsycl-unnamed-lambda enabled!"
);
45
};
46
47
#ifdef __SYCL_UNNAMED_LAMBDA__
48
template
<
typename
Type>
struct
get_kernel_name_t
<detail::
auto_name
, Type> {
54
using
name = Type;
55
};
56
#endif // __SYCL_UNNAMED_LAMBDA__
57
58
}
// namespace detail
59
67
class
__SYCL_EXPORT
kernel
{
68
public
:
76
#ifdef __SYCL_INTERNAL_API
77
kernel
(cl_kernel ClKernel,
const
context
&SyclContext);
78
#endif
79
80
kernel
(
const
kernel
&RHS) =
default
;
81
82
kernel
(
kernel
&&RHS) =
default
;
83
84
kernel
&operator=(
const
kernel
&RHS) =
default
;
85
86
kernel
&operator=(
kernel
&&RHS) =
default
;
87
88
bool
operator==
(
const
kernel
&RHS)
const
{
return
impl == RHS.impl; }
89
90
bool
operator!=
(
const
kernel
&RHS)
const
{
return
!
operator==
(RHS); }
91
99
#ifdef __SYCL_INTERNAL_API
100
cl_kernel
get
()
const
;
101
#endif
102
106
bool
is_host()
const
;
107
114
context
get_context()
const
;
115
119
backend
get_backend() const noexcept;
120
124
kernel_bundle
<
bundle_state
::executable>
get_kernel_bundle
() const;
125
132
#ifdef __SYCL_INTERNAL_API
133
program get_program()
const
;
134
#endif
135
140
template
<info::kernel param>
141
typename
info::param_traits<info::kernel, param>::return_type
142
get_info()
const
;
143
149
template
<info::kernel_device_specific param>
150
typename
info::param_traits<info::kernel_device_specific, param>::return_type
151
get_info(
const
device
&Device)
const
;
152
159
template
<info::kernel_device_specific param>
160
typename
info::param_traits<info::kernel_device_specific, param>::return_type
161
get_info(
const
device
&Device,
162
typename
info::param_traits
<
info::kernel_device_specific
,
163
param>::input_type Value)
const
;
164
170
template
<info::kernel_work_group param>
171
__SYCL2020_DEPRECATED
(
"get_work_group_info() is deprecated, use SYCL 2020 "
172
"kernel_device_specific queries instead"
)
173
typename info::param_traits<info::kernel_work_group, param>::return_type
174
get_work_group_info(const
device
&Device) const;
175
181
template <info::
kernel_sub_group
param>
182
// clang-format off
183
__SYCL_DEPRECATED
("Use get_info with info::
kernel_device_specific
instead
.")
184
typename info::param_traits<info::
kernel_sub_group
, param>::return_type
185
get_sub_group_info(const
device
&Device) const;
186
// clang-format on
187
194
template <info::
kernel_sub_group
param>
195
// clang-format off
196
__SYCL_DEPRECATED
("Use get_info with info::
kernel_device_specific
instead
.")
197
typename info::param_traits<info::
kernel_sub_group
, param>::return_type
198
get_sub_group_info(const
device
&Device,
199
typename info::param_traits<info::
kernel_sub_group
,
200
param>::input_type Value) const;
201
// clang-format on
202
203
template <
backend
Backend>
204
__SYCL_DEPRECATED
("Use SYCL 2020
sycl
::
get_native
free
function")
205
backend_return_t
<Backend,
kernel
>
get_native
()
const
{
206
return
detail::pi::cast<backend_return_t<Backend, kernel>>(getNative());
207
}
208
209
private
:
211
kernel
(std::shared_ptr<detail::kernel_impl> Impl);
212
213
pi_native_handle
getNative()
const
;
214
215
__SYCL_DEPRECATED
(
"Use getNative() member function"
)
216
pi_native_handle
getNativeImpl() const;
217
218
std
::shared_ptr<detail::
kernel_impl
> impl;
219
220
template <class Obj>
221
friend decltype(Obj::impl) detail::
getSyclObjImpl
(const Obj &SyclObject);
222
template <class T>
223
friend T detail::
createSyclObjFromImpl
(decltype(T::impl) ImplObj);
224
};
225
}
// namespace sycl
226
}
// __SYCL_INLINE_NAMESPACE(cl)
227
228
namespace
std
{
229
template
<>
struct
hash<
cl
::sycl::kernel> {
230
size_t
operator()
(
const
cl::sycl::kernel
&Kernel)
const
{
231
return
hash<std::shared_ptr<cl::sycl::detail::kernel_impl>>()(
232
cl::sycl::detail::getSyclObjImpl
(Kernel));
233
}
234
};
235
}
// namespace std
cl::sycl::backend
backend
Definition:
backend_types.hpp:21
cl::sycl::kernel::operator!=
bool operator!=(const kernel &RHS) const
Definition:
kernel.hpp:90
pi.h
cl::sycl::kernel_bundle
The kernel_bundle class represents collection of device images in a particular state.
Definition:
kernel.hpp:28
cl::sycl::backend_return_t
typename backend_traits< Backend >::template return_type< SyclType > backend_return_t
Definition:
backend.hpp:68
cl::sycl::info::param_traits
Definition:
info_desc.hpp:310
__SYCL2020_DEPRECATED
#define __SYCL2020_DEPRECATED(message)
Definition:
defines_elementary.hpp:56
cl::sycl::get_native
auto get_native(const SyclObjectT &Obj) -> backend_return_t< BackendName, SyclObjectT >
Definition:
backend.hpp:119
stl.hpp
cl::sycl::detail::createSyclObjFromImpl
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
Definition:
common.hpp:221
__SYCL_DEPRECATED
#define __SYCL_DEPRECATED(message)
Definition:
defines_elementary.hpp:47
std::hash< cl::sycl::kernel >::operator()
size_t operator()(const cl::sycl::kernel &Kernel) const
Definition:
kernel.hpp:230
sycl
Definition:
invoke_simd.hpp:68
cl::sycl::detail::kernel_impl
Definition:
kernel_impl.hpp:34
operator==
bool operator==(const Slab &Lhs, const Slab &Rhs)
Definition:
usm_allocator.cpp:568
cl::sycl::bundle_state
bundle_state
Definition:
kernel_bundle_enums.hpp:14
export.hpp
cl::sycl::kernel::operator==
bool operator==(const kernel &RHS) const
Definition:
kernel.hpp:88
cl::sycl::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition:
device.hpp:35
kernel_bundle_enums.hpp
cl
We provide new interfaces for matrix muliply in this patch:
Definition:
access.hpp:13
cl::sycl::get_kernel_bundle
kernel_bundle< State > get_kernel_bundle(const context &Ctx, const std::vector< device > &Devs)
A kernel bundle in state State which contains all of the kernels in the application which are compati...
Definition:
kernel_bundle.hpp:401
pi_native_handle
uintptr_t pi_native_handle
Definition:
pi.h:76
std::get
constexpr tuple_element< I, tuple< Types... > >::type & get(cl::sycl::detail::tuple< Types... > &Arg) noexcept
Definition:
tuple.hpp:199
cl::sycl::info::kernel_sub_group
kernel_sub_group
Definition:
info_desc.hpp:258
cl::sycl::detail::usm::free
void free(void *Ptr, const context &Ctxt, const code_location &CL)
Definition:
usm_impl.cpp:181
cl::sycl::detail::get_kernel_name_t
Helper struct to get a kernel name type based on given Name and Type types: if Name is undefined (is ...
Definition:
kernel.hpp:40
cl::sycl::detail::auto_name
This class is the default KernelName template parameter type for kernel invocation APIs such as singl...
Definition:
kernel.hpp:35
cl::sycl::detail::getSyclObjImpl
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition:
common.hpp:204
std
Definition:
accessor.hpp:2616
cl::sycl::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition:
context.hpp:35
info_desc.hpp
common.hpp
cl::sycl::instead
std::uint8_t instead
Definition:
aliases.hpp:68
cl::sycl::info::context
context
Definition:
info_desc.hpp:42
cl::sycl::detail::get_kernel_name_t::name
Name name
Definition:
kernel.hpp:41
cl::sycl::kernel
Provides an abstraction of a SYCL kernel.
Definition:
kernel.hpp:67
cl::sycl::info::kernel_device_specific
kernel_device_specific
Definition:
info_desc.hpp:265
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition:
defines_elementary.hpp:12
include
CL
sycl
kernel.hpp
Generated by
1.8.17