DPC++ Runtime
Runtime libraries for oneAPI DPC++
backend_traits_cuda.hpp
Go to the documentation of this file.
1 //===------- backend_traits_cuda.hpp - Backend traits for CUDA ---*-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 and sycl::detail::BackendReturn class templates
11 // for the CUDA backend but there is no sycl::detail::InteropFeatureSupportMap
12 // specialization for the CUDA backend.
13 //===----------------------------------------------------------------------===//
14 
15 #pragma once
16 
17 #include <sycl/accessor.hpp>
18 #include <sycl/context.hpp>
20 #include <sycl/device.hpp>
21 #include <sycl/event.hpp>
22 #include <sycl/kernel_bundle.hpp>
23 #include <sycl/queue.hpp>
24 
25 #include <vector>
26 
27 typedef int CUdevice;
28 typedef struct CUctx_st *CUcontext;
29 typedef struct CUstream_st *CUstream;
30 typedef struct CUevent_st *CUevent;
31 typedef struct CUmod_st *CUmodule;
32 
33 namespace sycl {
35 namespace detail {
36 
37 // TODO the interops for context, device, event, platform and program
38 // may be removed after removing the deprecated 'get_native()' methods
39 // from the corresponding classes. The interop<backend, queue> specialization
40 // is also used in the get_queue() method of the deprecated class
41 // interop_handler and also can be removed after API cleanup.
42 template <> struct interop<backend::ext_oneapi_cuda, context> {
43  using type = CUcontext;
44 };
45 
46 template <> struct interop<backend::ext_oneapi_cuda, device> {
47  using type = CUdevice;
48 };
49 
50 template <> struct interop<backend::ext_oneapi_cuda, event> {
51  using type = CUevent;
52 };
53 
54 template <> struct interop<backend::ext_oneapi_cuda, queue> {
55  using type = CUstream;
56 };
57 
58 template <> struct interop<backend::ext_oneapi_cuda, platform> {
59  using type = std::vector<CUdevice>;
60 };
61 
62 template <typename DataT, int Dimensions, typename AllocatorT>
64  buffer<DataT, Dimensions, AllocatorT>> {
65  using type = DataT *;
66 };
67 
68 template <typename DataT, int Dimensions, typename AllocatorT>
70  buffer<DataT, Dimensions, AllocatorT>> {
71  using type = DataT *;
72 };
73 
74 template <> struct BackendInput<backend::ext_oneapi_cuda, context> {
75  using type = CUcontext;
76 };
77 
78 template <> struct BackendReturn<backend::ext_oneapi_cuda, context> {
79  using type = std::vector<CUcontext>;
80 };
81 
82 template <> struct BackendInput<backend::ext_oneapi_cuda, device> {
83  using type = CUdevice;
84 };
85 
86 template <> struct BackendReturn<backend::ext_oneapi_cuda, device> {
87  using type = CUdevice;
88 };
89 
90 template <> struct BackendInput<backend::ext_oneapi_cuda, event> {
91  using type = CUevent;
92 };
93 
94 template <> struct BackendReturn<backend::ext_oneapi_cuda, event> {
95  using type = CUevent;
96 };
97 
98 template <> struct BackendInput<backend::ext_oneapi_cuda, queue> {
99  using type = CUstream;
100 };
101 
102 template <> struct BackendReturn<backend::ext_oneapi_cuda, queue> {
103  using type = CUstream;
104 };
105 
107  using type = std::vector<CUdevice>;
108 };
109 
111  using type = std::vector<CUdevice>;
112 };
113 
115  static constexpr bool MakePlatform = false;
116  static constexpr bool MakeDevice = true;
117  static constexpr bool MakeContext = true;
118  static constexpr bool MakeQueue = true;
119  static constexpr bool MakeEvent = true;
120  static constexpr bool MakeBuffer = false;
121  static constexpr bool MakeKernel = false;
122  static constexpr bool MakeKernelBundle = false;
123 };
124 
125 } // namespace detail
126 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
127 } // namespace sycl
sycl::_V1::detail::BackendInput< backend::ext_oneapi_cuda, device >::type
CUdevice type
Definition: backend_traits_cuda.hpp:101
CUevent
struct CUevent_st * CUevent
Definition: backend_traits_cuda.hpp:28
CUstream
struct CUstream_st * CUstream
Definition: backend_traits_cuda.hpp:27
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_cuda, device >::type
CUdevice type
Definition: backend_traits_cuda.hpp:105
sycl::_V1::backend
backend
Definition: backend_types.hpp:21
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_cuda, buffer< DataT, Dimensions, AllocatorT > >::type
CUdeviceptr type
Definition: backend_traits_cuda.hpp:89
sycl::_V1::detail::BackendInput< backend::ext_oneapi_cuda, queue >::type
CUstream type
Definition: backend_traits_cuda.hpp:117
device.hpp
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:13
sycl::_V1::buffer
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:35
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_cuda, context >::type
CUcontext type
Definition: backend_traits_cuda.hpp:97
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_cuda, platform >::type
std::vector< CUdevice > type
Definition: backend_traits_cuda.hpp:111
context.hpp
event.hpp
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:13
sycl::_V1::event
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:38
sycl::_V1::detail::interop< backend::ext_oneapi_cuda, device >::type
CUdevice type
Definition: backend_traits_cuda.hpp:52
backend_traits.hpp
sycl::_V1::detail::BackendInput
Definition: backend_traits.hpp:20
sycl::_V1::detail::interop< backend::ext_oneapi_cuda, queue >::type
CUstream type
Definition: backend_traits_cuda.hpp:60
sycl::_V1::backend::ext_oneapi_cuda
@ ext_oneapi_cuda
sycl::_V1::detail::InteropFeatureSupportMap
Definition: backend_traits.hpp:24
CUcontext
struct CUctx_st * CUcontext
Definition: backend_traits_cuda.hpp:26
sycl::_V1::detail::interop< backend::ext_oneapi_cuda, platform >::type
std::vector< CUdevice > type
Definition: backend_traits_cuda.hpp:59
sycl::_V1::detail::interop
Definition: backend_traits.hpp:18
kernel_bundle.hpp
sycl::_V1::detail::interop< backend::ext_oneapi_cuda, event >::type
CUevent type
Definition: backend_traits_cuda.hpp:56
CUmodule
struct CUmod_st * CUmodule
Definition: backend_traits_cuda.hpp:29
sycl::_V1::queue
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:86
sycl::_V1::detail::BackendInput< backend::ext_oneapi_cuda, event >::type
CUevent type
Definition: backend_traits_cuda.hpp:109
sycl::_V1::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:47
queue.hpp
sycl::_V1::detail::interop< backend::ext_oneapi_cuda, context >::type
CUcontext type
Definition: backend_traits_cuda.hpp:48
accessor.hpp
sycl::_V1::detail::BackendReturn
Definition: backend_traits.hpp:22
sycl::_V1::platform
Encapsulates a SYCL platform on which kernels may be executed.
Definition: platform.hpp:45
sycl::_V1::detail::BackendInput< backend::ext_oneapi_cuda, platform >::type
std::vector< CUdevice > type
Definition: backend_traits_cuda.hpp:107
sycl::_V1::detail::BackendInput< backend::ext_oneapi_cuda, context >::type
CUcontext type
Definition: backend_traits_cuda.hpp:93
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_cuda, queue >::type
CUstream type
Definition: backend_traits_cuda.hpp:121
CUdevice
int CUdevice
Definition: backend_traits_cuda.hpp:25
sycl::_V1::detail::BackendInput< backend::ext_oneapi_cuda, buffer< DataT, Dimensions, AllocatorT > >::type
CUdeviceptr type
Definition: backend_traits_cuda.hpp:83
sycl::_V1::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:39
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_cuda, event >::type
CUevent type
Definition: backend_traits_cuda.hpp:113