DPC++ Runtime
Runtime libraries for oneAPI DPC++
context.hpp
Go to the documentation of this file.
1
//==---------------- context.hpp - SYCL context ----------------------------==//
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 <
sycl/detail/backend_traits.hpp
>
12
#include <
sycl/detail/cl.h
>
13
#include <
sycl/detail/common.hpp
>
14
#include <
sycl/detail/export.hpp
>
15
#include <
sycl/detail/info_desc_helpers.hpp
>
16
#include <
sycl/detail/owner_less_base.hpp
>
17
#include <
sycl/detail/stl_type_traits.hpp
>
18
#include <
sycl/exception_list.hpp
>
19
#include <
sycl/ext/oneapi/weak_object_base.hpp
>
20
#include <
sycl/info/info_desc.hpp
>
21
#include <
sycl/property_list.hpp
>
22
#include <
sycl/stl.hpp
>
23
24
// 4.6.2 Context class
25
26
namespace
sycl
{
27
__SYCL_INLINE_VER_NAMESPACE
(_V1) {
28
// Forward declarations
29
class
device
;
30
class
platform
;
31
namespace
detail {
32
class
context_impl;
33
}
34
template
<backend Backend,
class
SyclT>
35
auto
get_native
(
const
SyclT &Obj) -> backend_return_t<Backend, SyclT>;
36
41
class
__SYCL_EXPORT
context
:
public
detail::OwnerLessBase
<context> {
42
public
:
51
explicit
context
(
const
property_list
&PropList = {});
52
64
explicit
context
(
const
async_handler
&AsyncHandler,
65
const
property_list
&PropList = {});
66
76
explicit
context
(
const
device
&Device,
const
property_list
&PropList = {});
77
90
explicit
context
(
const
device
&Device,
async_handler
AsyncHandler,
91
const
property_list
&PropList = {});
92
102
explicit
context
(
const
platform
&Platform,
103
const
property_list
&PropList = {});
104
117
explicit
context
(
const
platform
&Platform,
async_handler
AsyncHandler,
118
const
property_list
&PropList = {});
119
130
explicit
context
(
const
std::vector<device> &DeviceList,
131
const
property_list
&PropList = {});
132
146
explicit
context
(
const
std::vector<device> &DeviceList,
147
async_handler
AsyncHandler,
148
const
property_list
&PropList = {});
149
158
#ifdef __SYCL_INTERNAL_API
159
context
(cl_context ClContext,
async_handler
AsyncHandler = {});
160
#endif
161
165
template
<
typename
Param>
166
typename
detail::is_context_info_desc<Param>::return_type
get_info()
const
;
167
168
context
(
const
context
&rhs) =
default
;
169
170
context
(
context
&&rhs) =
default
;
171
172
context
&
operator=
(
const
context
&rhs) =
default
;
173
174
context
&
operator=
(
context
&&rhs) =
default
;
175
176
bool
operator==
(
const
context
&rhs)
const
{
return
impl == rhs.impl; }
177
178
bool
operator!=
(
const
context
&rhs)
const
{
return
!(*
this
== rhs); }
179
183
template
<
typename
propertyT>
bool
has_property
() const noexcept;
184
191
template <typename propertyT> propertyT
get_property
() const;
192
198
#ifdef __SYCL_INTERNAL_API
199
cl_context
get
()
const
;
200
#endif
201
205
__SYCL2020_DEPRECATED
(
206
"is_host() is deprecated as the host device is no longer supported."
)
207
bool is_host() const;
208
212
backend
get_backend() const noexcept;
213
217
platform
get_platform() const;
218
222
std
::vector<
device
> get_devices() const;
223
224
private:
226
context
(
std
::shared_ptr<detail::context_impl> Impl);
227
228
pi_native_handle
getNative() const;
229
230
std
::shared_ptr<detail::context_impl> impl;
231
232
template <
backend
Backend, class SyclT>
233
friend auto
get_native
(const SyclT &Obj) ->
backend_return_t
<Backend, SyclT>;
234
235
template <class Obj>
236
friend decltype(Obj::impl) detail::
getSyclObjImpl
(const Obj &SyclObject);
237
238
template <class
T
>
239
friend
240
typename detail::
add_pointer_t
<typename decltype(
T
::impl)::element_type>
241
detail::
getRawSyclObjImpl
(const
T
&SyclObject);
242
243
template <class
T
>
244
friend
T
detail::
createSyclObjFromImpl
(decltype(
T
::impl) ImplObj);
245
};
246
247
}
// __SYCL_INLINE_VER_NAMESPACE(_V1)
248
}
// namespace sycl
249
250
namespace
std
{
251
template
<>
struct
hash<
sycl
::context> {
252
size_t
operator()
(
const
sycl::context &Context)
const
{
253
return
hash<std::shared_ptr<sycl::detail::context_impl>>()(
254
sycl::detail::getSyclObjImpl
(Context));
255
}
256
};
257
}
// namespace std
sycl::_V1::property_list
Objects of the property_list class are containers for the SYCL properties.
Definition:
property_list.hpp:24
sycl::_V1::__SYCL2020_DEPRECATED
signed char __SYCL2020_DEPRECATED
Definition:
aliases.hpp:96
property_list.hpp
sycl::_V1::errc::platform
@ platform
sycl::_V1::backend
backend
Definition:
backend_types.hpp:21
T
stl.hpp
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition:
defines_elementary.hpp:11
std::hash< sycl::context >::operator()
size_t operator()(const sycl::context &Context) const
Definition:
context.hpp:252
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition:
access.hpp:14
sycl::_V1::detail::getRawSyclObjImpl
detail::add_pointer_t< typename decltype(T::impl)::element_type > getRawSyclObjImpl(const T &SyclObject)
Definition:
common.hpp:310
backend_traits.hpp
sycl::_V1::get_native
auto get_native(const SyclT &Obj) -> backend_return_t< Backend, SyclT >
owner_less_base.hpp
stl_type_traits.hpp
export.hpp
sycl::_V1::ext::oneapi::experimental::has_property
static constexpr bool has_property()
Definition:
annotated_arg.hpp:162
std::get
constexpr tuple_element< I, tuple< Types... > >::type & get(sycl::detail::tuple< Types... > &Arg) noexcept
Definition:
tuple.hpp:199
cl.h
sycl::_V1::ext::oneapi::experimental::operator=
annotated_arg & operator=(annotated_arg &)=default
sycl::_V1::detail::OwnerLessBase
Definition:
owner_less_base.hpp:21
common.hpp
sycl::_V1::backend_return_t
typename backend_traits< Backend >::template return_type< SyclType > backend_return_t
Definition:
backend.hpp:72
sycl::_V1::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition:
device.hpp:49
sycl::_V1::detail::createSyclObjFromImpl
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
Definition:
common.hpp:318
sycl::_V1::access::target::device
@ device
sycl::_V1::ext::oneapi::experimental::get_property
static constexpr auto get_property()
Definition:
annotated_arg.hpp:166
pi_native_handle
uintptr_t pi_native_handle
Definition:
pi.h:133
sycl::_V1::detail::is_context_info_desc
Definition:
info_desc_helpers.hpp:20
std
Definition:
accessor.hpp:3230
info_desc_helpers.hpp
sycl::_V1::async_handler
std::function< void(sycl::exception_list)> async_handler
Definition:
exception_list.hpp:54
sycl::_V1::context::operator!=
bool operator!=(const context &rhs) const
Definition:
context.hpp:178
exception_list.hpp
sycl::_V1::context::operator==
bool operator==(const context &rhs) const
Definition:
context.hpp:176
info_desc.hpp
sycl::_V1::platform
Encapsulates a SYCL platform on which kernels may be executed.
Definition:
platform.hpp:45
sycl::_V1::detail::add_pointer_t
typename std::add_pointer< T >::type add_pointer_t
Definition:
stl_type_traits.hpp:37
weak_object_base.hpp
sycl::_V1::detail::getSyclObjImpl
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition:
common.hpp:300
sycl::_V1::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition:
context.hpp:41
include
sycl
context.hpp
Generated by
1.8.17