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 <CL/sycl/accessor.hpp>
18 #include <CL/sycl/context.hpp>
20 #include <CL/sycl/device.hpp>
21 #include <CL/sycl/event.hpp>
23 #include <CL/sycl/queue.hpp>
24 
25 typedef int CUdevice;
26 typedef struct CUctx_st *CUcontext;
27 typedef struct CUstream_st *CUstream;
28 typedef struct CUevent_st *CUevent;
29 typedef struct CUmod_st *CUmodule;
30 
31 // As defined in the CUDA 10.1 header file. This requires CUDA version > 3.2
32 #if defined(_WIN64) || defined(__LP64__)
33 typedef unsigned long long CUdeviceptr;
34 #else
35 typedef unsigned int CUdeviceptr;
36 #endif
37 
39 namespace sycl {
40 namespace detail {
41 
42 // TODO the interops for context, device, event, platform and program
43 // may be removed after removing the deprecated 'get_native()' methods
44 // from the corresponding classes. The interop<backend, queue> specialization
45 // is also used in the get_queue() method of the deprecated class
46 // interop_handler and also can be removed after API cleanup.
47 template <> struct interop<backend::ext_oneapi_cuda, context> {
48  using type = CUcontext;
49 };
50 
51 template <> struct interop<backend::ext_oneapi_cuda, device> {
52  using type = CUdevice;
53 };
54 
55 template <> struct interop<backend::ext_oneapi_cuda, event> {
56  using type = CUevent;
57 };
58 
59 template <> struct interop<backend::ext_oneapi_cuda, queue> {
60  using type = CUstream;
61 };
62 
63 #ifdef __SYCL_INTERNAL_API
64 template <> struct interop<backend::ext_oneapi_cuda, program> {
65  using type = CUmodule;
66 };
67 #endif
68 
69 // TODO the interops for accessor is used in the already deprecated class
70 // interop_handler and can be removed after API cleanup.
71 template <typename DataT, int Dimensions, access::mode AccessMode>
73  accessor<DataT, Dimensions, AccessMode, access::target::device,
74  access::placeholder::false_t>> {
75  using type = CUdeviceptr;
76 };
77 
78 template <typename DataT, int Dimensions, access::mode AccessMode>
79 struct interop<
81  accessor<DataT, Dimensions, AccessMode, access::target::constant_buffer,
82  access::placeholder::false_t>> {
83  using type = CUdeviceptr;
84 };
85 
86 template <typename DataT, int Dimensions, typename AllocatorT>
88  buffer<DataT, Dimensions, AllocatorT>> {
89  using type = CUdeviceptr;
90 };
91 
92 template <typename DataT, int Dimensions, typename AllocatorT>
94  buffer<DataT, Dimensions, AllocatorT>> {
95  using type = CUdeviceptr;
96 };
97 
99  using type = CUcontext;
100 };
101 
103  using type = CUcontext;
104 };
105 
107  using type = CUdevice;
108 };
109 
111  using type = CUdevice;
112 };
113 
114 template <> struct BackendInput<backend::ext_oneapi_cuda, event> {
115  using type = CUevent;
116 };
117 
119  using type = CUevent;
120 };
121 
122 template <> struct BackendInput<backend::ext_oneapi_cuda, queue> {
123  using type = CUstream;
124 };
125 
127  using type = CUstream;
128 };
129 
130 #ifdef __SYCL_INTERNAL_API
131 template <> struct BackendInput<backend::ext_oneapi_cuda, program> {
132  using type = CUmodule;
133 };
134 
135 template <> struct BackendReturn<backend::ext_oneapi_cuda, program> {
136  using type = CUmodule;
137 };
138 #endif
139 
140 } // namespace detail
141 } // namespace sycl
142 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::detail::interop< backend::ext_oneapi_cuda, context >::type
CUcontext type
Definition: backend_traits_cuda.hpp:48
cl::sycl::backend
backend
Definition: backend_types.hpp:21
CUcontext
struct CUctx_st * CUcontext
Definition: backend_traits_cuda.hpp:26
CUstream
struct CUstream_st * CUstream
Definition: backend_traits_cuda.hpp:27
cl::sycl::event
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:31
cl::sycl::detail::BackendInput< backend::ext_oneapi_cuda, buffer< DataT, Dimensions, AllocatorT > >::type
CUdeviceptr type
Definition: backend_traits_cuda.hpp:89
device.hpp
cl::sycl::detail::interop< backend::ext_oneapi_cuda, accessor< DataT, Dimensions, AccessMode, access::target::constant_buffer, access::placeholder::false_t > >::type
CUdeviceptr type
Definition: backend_traits_cuda.hpp:83
cl::sycl::detail::BackendReturn< backend::ext_oneapi_cuda, buffer< DataT, Dimensions, AllocatorT > >::type
CUdeviceptr type
Definition: backend_traits_cuda.hpp:95
cl::sycl::detail::interop< backend::ext_oneapi_cuda, accessor< DataT, Dimensions, AccessMode, access::target::device, access::placeholder::false_t > >::type
CUdeviceptr type
Definition: backend_traits_cuda.hpp:75
context.hpp
event.hpp
sycl
Definition: invoke_simd.hpp:68
CUdeviceptr
unsigned int CUdeviceptr
Definition: backend_traits_cuda.hpp:35
cl::sycl::queue
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:103
cl::sycl::buffer
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:58
cl::sycl::detail::interop< backend::ext_oneapi_cuda, device >::type
CUdevice type
Definition: backend_traits_cuda.hpp:52
backend_traits.hpp
cl::sycl::detail::BackendReturn< backend::ext_oneapi_cuda, device >::type
CUdevice type
Definition: backend_traits_cuda.hpp:111
cl::sycl::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:35
cl::sycl::detail::BackendInput< backend::ext_oneapi_cuda, queue >::type
CUstream type
Definition: backend_traits_cuda.hpp:123
kernel_bundle.hpp
cl::sycl::detail::interop< backend::ext_oneapi_cuda, queue >::type
CUstream type
Definition: backend_traits_cuda.hpp:60
cl::sycl::detail::BackendInput< backend::ext_oneapi_cuda, event >::type
CUevent type
Definition: backend_traits_cuda.hpp:115
cl::sycl::accessor
Buffer accessor.
Definition: accessor.hpp:223
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::BackendInput< backend::ext_oneapi_cuda, context >::type
CUcontext type
Definition: backend_traits_cuda.hpp:99
queue.hpp
cl::sycl::detail::interop
Definition: backend_traits.hpp:18
cl::sycl::detail::BackendReturn< backend::ext_oneapi_cuda, context >::type
CUcontext type
Definition: backend_traits_cuda.hpp:103
CUmodule
struct CUmod_st * CUmodule
Definition: backend_traits_cuda.hpp:29
accessor.hpp
CUdevice
int CUdevice
Definition: backend_traits_cuda.hpp:25
cl::sycl::backend::ext_oneapi_cuda
@ ext_oneapi_cuda
cl::sycl::detail::BackendReturn< backend::ext_oneapi_cuda, event >::type
CUevent type
Definition: backend_traits_cuda.hpp:119
cl::sycl::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:35
cl::sycl::detail::BackendReturn< backend::ext_oneapi_cuda, queue >::type
CUstream type
Definition: backend_traits_cuda.hpp:127
CUevent
struct CUevent_st * CUevent
Definition: backend_traits_cuda.hpp:28
cl::sycl::detail::BackendInput< backend::ext_oneapi_cuda, device >::type
CUdevice type
Definition: backend_traits_cuda.hpp:107
cl::sycl::detail::interop< backend::ext_oneapi_cuda, event >::type
CUevent type
Definition: backend_traits_cuda.hpp:56
cl::sycl::detail::BackendReturn
Definition: backend_traits.hpp:22
cl::sycl::detail::BackendInput
Definition: backend_traits.hpp:20
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12