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 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 
38 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 // TODO the interops for accessor is used in the already deprecated class
64 // interop_handler and can be removed after API cleanup.
65 template <typename DataT, int Dimensions, access::mode AccessMode>
67  accessor<DataT, Dimensions, AccessMode, access::target::device,
68  access::placeholder::false_t>> {
69  using type = CUdeviceptr;
70 };
71 
72 template <typename DataT, int Dimensions, access::mode AccessMode>
73 struct interop<
75  accessor<DataT, Dimensions, AccessMode, access::target::constant_buffer,
76  access::placeholder::false_t>> {
77  using type = CUdeviceptr;
78 };
79 
80 template <typename DataT, int Dimensions, typename AllocatorT>
82  buffer<DataT, Dimensions, AllocatorT>> {
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 
93  using type = CUcontext;
94 };
95 
97  using type = CUcontext;
98 };
99 
101  using type = CUdevice;
102 };
103 
105  using type = CUdevice;
106 };
107 
108 template <> struct BackendInput<backend::ext_oneapi_cuda, event> {
109  using type = CUevent;
110 };
111 
113  using type = CUevent;
114 };
115 
116 template <> struct BackendInput<backend::ext_oneapi_cuda, queue> {
117  using type = CUstream;
118 };
119 
121  using type = CUstream;
122 };
123 
124 } // namespace detail
125 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
126 } // namespace sycl
The file contains implementations of accessor class.
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:146
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:41
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:49
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:40
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:88
unsigned int CUdeviceptr
struct CUevent_st * CUevent
struct CUmod_st * CUmodule
struct CUstream_st * CUstream
int CUdevice
struct CUctx_st * CUcontext
#define __SYCL_INLINE_VER_NAMESPACE(X)
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14