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 {
34 inline namespace _V1 {
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 = false;
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  static constexpr bool MakeImage = false;
124 };
125 
126 } // namespace detail
127 } // namespace _V1
128 } // namespace sycl
The file contains implementations of accessor class.
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:169
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:51
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:66
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:44
Encapsulates a SYCL platform on which kernels may be executed.
Definition: platform.hpp:109
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:119
struct CUevent_st * CUevent
struct CUmod_st * CUmodule
struct CUstream_st * CUstream
int CUdevice
struct CUctx_st * CUcontext
Definition: access.hpp:18