DPC++ Runtime
Runtime libraries for oneAPI DPC++
backend_traits_opencl.hpp
Go to the documentation of this file.
1
//===---- backend_traits_opencl.hpp - Backend traits for OpenCL --*- C++-*-===//
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
// This file defines the specializations of the sycl::detail::interop,
10
// sycl::detail::BackendInput, sycl::detail::BackendReturn and
11
// sycl::detail::InteropFeatureSupportMap class templates for the OpenCL
12
// backend.
13
//
14
//===----------------------------------------------------------------------===//
15
16
#pragma once
17
18
#include <
sycl/backend_types.hpp
>
// for backend
19
#include <
sycl/context.hpp
>
// for context
20
#include <
sycl/detail/backend_traits.hpp
>
// for BackendInput, BackendReturn
21
#include <
sycl/detail/cl.h
>
// for _cl_event, cl_event, cl_de...
22
#include <
sycl/detail/ur.hpp
>
// for assertion and ur handles
23
#include <
sycl/device.hpp
>
// for device
24
#include <
sycl/event.hpp
>
// for event
25
#include <
sycl/handler.hpp
>
// for buffer
26
#include <
sycl/kernel.hpp
>
// for kernel
27
#include <
sycl/kernel_bundle.hpp
>
// for kernel_bundle
28
#include <
sycl/kernel_bundle_enums.hpp
>
// for bundle_state
29
#include <
sycl/platform.hpp
>
// for platform
30
#include <
sycl/queue.hpp
>
// for queue
31
32
#include <vector>
// for vector
33
34
namespace
sycl
{
35
inline
namespace
_V1 {
36
namespace
detail {
37
38
// TODO the interops for context, device, event, platform and program
39
// may be removed after removing the deprecated 'get_native()' methods
40
// from the corresponding classes.
41
template
<>
struct
interop
<
backend
::
opencl
,
context
> {
42
using
type
= cl_context;
43
};
44
45
template
<>
struct
interop
<
backend
::
opencl
,
device
> {
46
using
type
= cl_device_id;
47
};
48
49
template
<>
struct
interop
<
backend
::
opencl
,
queue
> {
50
using
type
= cl_command_queue;
51
};
52
53
template
<>
struct
interop
<
backend
::
opencl
,
platform
> {
54
using
type
= cl_platform_id;
55
};
56
57
template
<
typename
DataT,
int
Dimensions,
typename
AllocatorT>
58
struct
BackendInput
<
backend
::
opencl
,
buffer
<DataT, Dimensions, AllocatorT>> {
59
using
type
= cl_mem;
60
};
61
62
template
<
typename
DataT,
int
Dimensions,
typename
AllocatorT>
63
struct
BackendReturn
<
backend
::
opencl
,
buffer
<DataT, Dimensions, AllocatorT>> {
64
using
type
= std::vector<cl_mem>;
65
};
66
67
template
<>
struct
BackendInput
<
backend
::
opencl
,
context
> {
68
using
type
= cl_context;
69
};
70
71
template
<>
struct
BackendReturn
<
backend
::
opencl
,
context
> {
72
using
type
= cl_context;
73
};
74
75
template
<>
struct
BackendInput
<
backend
::
opencl
,
device
> {
76
using
type
= cl_device_id;
77
};
78
79
template
<>
struct
BackendReturn
<
backend
::
opencl
,
device
> {
80
using
type
= cl_device_id;
81
};
82
83
template
<>
struct
interop
<
backend
::
opencl
,
event
> {
84
using
type
= std::vector<cl_event>;
85
using
value_type
= cl_event;
86
};
87
template
<>
struct
BackendInput
<
backend
::
opencl
,
event
> {
88
using
type
= std::vector<cl_event>;
89
using
value_type
= cl_event;
90
};
91
template
<>
struct
BackendReturn
<
backend
::
opencl
,
event
> {
92
using
type
= std::vector<cl_event>;
93
using
value_type
= cl_event;
94
};
95
96
template
<>
struct
BackendInput
<
backend
::
opencl
,
queue
> {
97
using
type
= cl_command_queue;
98
};
99
100
template
<>
struct
BackendReturn
<
backend
::
opencl
,
queue
> {
101
using
type
= cl_command_queue;
102
};
103
104
template
<>
struct
BackendInput
<
backend
::
opencl
,
platform
> {
105
using
type
= cl_platform_id;
106
};
107
108
template
<>
struct
BackendReturn
<
backend
::
opencl
,
platform
> {
109
using
type
= cl_platform_id;
110
};
111
112
template
<bundle_state State>
113
struct
BackendInput
<
backend
::
opencl
,
kernel_bundle
<State>> {
114
using
type
= cl_program;
115
};
116
117
template
<bundle_state State>
118
struct
BackendReturn
<
backend
::
opencl
,
kernel_bundle
<State>> {
119
using
type
= std::vector<cl_program>;
120
};
121
122
template
<>
struct
BackendInput
<
backend
::
opencl
,
kernel
> {
123
using
type
= cl_kernel;
124
};
125
126
template
<>
struct
BackendReturn
<
backend
::
opencl
,
kernel
> {
127
using
type
= cl_kernel;
128
};
129
130
template
<>
struct
InteropFeatureSupportMap
<
backend
::
opencl
> {
131
static
constexpr
bool
MakePlatform
=
true
;
132
static
constexpr
bool
MakeDevice
=
true
;
133
static
constexpr
bool
MakeContext
=
true
;
134
static
constexpr
bool
MakeQueue
=
true
;
135
static
constexpr
bool
MakeEvent
=
true
;
136
static
constexpr
bool
MakeBuffer
=
true
;
137
static
constexpr
bool
MakeKernel
=
true
;
138
static
constexpr
bool
MakeKernelBundle
=
true
;
139
static
constexpr
bool
MakeImage
=
false
;
140
};
141
142
namespace
ur {
143
// Cast for std::vector<cl_event>, according to the spec, make_event
144
// should create one(?) event from a vector of cl_event
145
template
<
class
To>
inline
To
cast
(std::vector<cl_event> value) {
146
assert(value.size() == 1 &&
147
"Temporary workaround requires that the "
148
"size of the input vector for make_event be equal to one."
);
149
return
cast<To>(value[0]);
150
}
151
152
// These conversions should use UR interop API.
153
template
<>
154
inline
ur_program_handle_t
155
cast
(cl_program) =
delete
;
// Use urProgramCreateWithNativeHandle
156
157
template
<>
158
inline
ur_device_handle_t
159
cast
(cl_device_id) =
delete
;
// Use urDeviceCreateWithNativeHandle
160
}
// namespace ur
161
}
// namespace detail
162
}
// namespace _V1
163
}
// namespace sycl
backend_traits.hpp
backend_types.hpp
cl.h
sycl::_V1::buffer
Defines a shared array that can be used by kernels in queues.
Definition:
buffer.hpp:173
sycl::_V1::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition:
context.hpp:50
sycl::_V1::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition:
device.hpp:64
sycl::_V1::event
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition:
event.hpp:44
sycl::_V1::kernel_bundle
The kernel_bundle class represents collection of device images in a particular state.
Definition:
kernel_bundle.hpp:241
sycl::_V1::kernel
Provides an abstraction of a SYCL kernel.
Definition:
kernel.hpp:71
sycl::_V1::platform
Encapsulates a SYCL platform on which kernels may be executed.
Definition:
platform.hpp:99
sycl::_V1::queue
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition:
queue.hpp:110
context.hpp
event.hpp
handler.hpp
kernel_bundle.hpp
kernel_bundle_enums.hpp
sycl::_V1::detail::ur::cast
To cast(std::vector< cl_event > value)
Definition:
backend_traits_opencl.hpp:145
sycl::_V1::backend
backend
Definition:
backend_types.hpp:18
sycl::_V1::backend::opencl
@ opencl
sycl
Definition:
access.hpp:18
platform.hpp
queue.hpp
sycl::_V1::detail::BackendInput< backend::opencl, buffer< DataT, Dimensions, AllocatorT > >::type
cl_mem type
Definition:
backend_traits_opencl.hpp:59
sycl::_V1::detail::BackendInput< backend::opencl, context >::type
cl_context type
Definition:
backend_traits_opencl.hpp:68
sycl::_V1::detail::BackendInput< backend::opencl, device >::type
cl_device_id type
Definition:
backend_traits_opencl.hpp:76
sycl::_V1::detail::BackendInput< backend::opencl, event >::value_type
cl_event value_type
Definition:
backend_traits_opencl.hpp:89
sycl::_V1::detail::BackendInput< backend::opencl, event >::type
std::vector< cl_event > type
Definition:
backend_traits_opencl.hpp:88
sycl::_V1::detail::BackendInput< backend::opencl, kernel >::type
cl_kernel type
Definition:
backend_traits_opencl.hpp:123
sycl::_V1::detail::BackendInput< backend::opencl, kernel_bundle< State > >::type
cl_program type
Definition:
backend_traits_opencl.hpp:114
sycl::_V1::detail::BackendInput< backend::opencl, platform >::type
cl_platform_id type
Definition:
backend_traits_opencl.hpp:105
sycl::_V1::detail::BackendInput< backend::opencl, queue >::type
cl_command_queue type
Definition:
backend_traits_opencl.hpp:97
sycl::_V1::detail::BackendInput
Definition:
backend_traits.hpp:19
sycl::_V1::detail::BackendReturn< backend::opencl, buffer< DataT, Dimensions, AllocatorT > >::type
std::vector< cl_mem > type
Definition:
backend_traits_opencl.hpp:64
sycl::_V1::detail::BackendReturn< backend::opencl, context >::type
cl_context type
Definition:
backend_traits_opencl.hpp:72
sycl::_V1::detail::BackendReturn< backend::opencl, device >::type
cl_device_id type
Definition:
backend_traits_opencl.hpp:80
sycl::_V1::detail::BackendReturn< backend::opencl, event >::type
std::vector< cl_event > type
Definition:
backend_traits_opencl.hpp:92
sycl::_V1::detail::BackendReturn< backend::opencl, event >::value_type
cl_event value_type
Definition:
backend_traits_opencl.hpp:93
sycl::_V1::detail::BackendReturn< backend::opencl, kernel >::type
cl_kernel type
Definition:
backend_traits_opencl.hpp:127
sycl::_V1::detail::BackendReturn< backend::opencl, kernel_bundle< State > >::type
std::vector< cl_program > type
Definition:
backend_traits_opencl.hpp:119
sycl::_V1::detail::BackendReturn< backend::opencl, platform >::type
cl_platform_id type
Definition:
backend_traits_opencl.hpp:109
sycl::_V1::detail::BackendReturn< backend::opencl, queue >::type
cl_command_queue type
Definition:
backend_traits_opencl.hpp:101
sycl::_V1::detail::BackendReturn
Definition:
backend_traits.hpp:21
sycl::_V1::detail::InteropFeatureSupportMap
Definition:
backend_traits.hpp:23
sycl::_V1::detail::InteropFeatureSupportMap::MakeEvent
static constexpr bool MakeEvent
Definition:
backend_traits.hpp:28
sycl::_V1::detail::InteropFeatureSupportMap::MakeBuffer
static constexpr bool MakeBuffer
Definition:
backend_traits.hpp:29
sycl::_V1::detail::InteropFeatureSupportMap::MakePlatform
static constexpr bool MakePlatform
Definition:
backend_traits.hpp:24
sycl::_V1::detail::InteropFeatureSupportMap::MakeKernel
static constexpr bool MakeKernel
Definition:
backend_traits.hpp:30
sycl::_V1::detail::InteropFeatureSupportMap::MakeContext
static constexpr bool MakeContext
Definition:
backend_traits.hpp:26
sycl::_V1::detail::InteropFeatureSupportMap::MakeQueue
static constexpr bool MakeQueue
Definition:
backend_traits.hpp:27
sycl::_V1::detail::InteropFeatureSupportMap::MakeDevice
static constexpr bool MakeDevice
Definition:
backend_traits.hpp:25
sycl::_V1::detail::InteropFeatureSupportMap::MakeKernelBundle
static constexpr bool MakeKernelBundle
Definition:
backend_traits.hpp:31
sycl::_V1::detail::InteropFeatureSupportMap::MakeImage
static constexpr bool MakeImage
Definition:
backend_traits.hpp:32
sycl::_V1::detail::interop< backend::opencl, context >::type
cl_context type
Definition:
backend_traits_opencl.hpp:42
sycl::_V1::detail::interop< backend::opencl, device >::type
cl_device_id type
Definition:
backend_traits_opencl.hpp:46
sycl::_V1::detail::interop< backend::opencl, event >::type
std::vector< cl_event > type
Definition:
backend_traits_opencl.hpp:84
sycl::_V1::detail::interop< backend::opencl, event >::value_type
cl_event value_type
Definition:
backend_traits_opencl.hpp:85
sycl::_V1::detail::interop< backend::opencl, platform >::type
cl_platform_id type
Definition:
backend_traits_opencl.hpp:54
sycl::_V1::detail::interop< backend::opencl, queue >::type
cl_command_queue type
Definition:
backend_traits_opencl.hpp:50
sycl::_V1::detail::interop
Definition:
backend_traits.hpp:17
device.hpp
kernel.hpp
ur.hpp
C++ utilities for Unified Runtime integration.
include
sycl
detail
backend_traits_opencl.hpp
Generated by
1.9.1