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/context.hpp>
19 #include <sycl/device.hpp>
20 #include <sycl/event.hpp>
21 #include <sycl/kernel_bundle.hpp>
22 #include <sycl/queue.hpp>
23 
24 typedef int CUdevice;
25 typedef struct CUctx_st *CUcontext;
26 typedef struct CUstream_st *CUstream;
27 typedef struct CUevent_st *CUevent;
28 typedef struct CUmod_st *CUmodule;
29 
30 // As defined in the CUDA 10.1 header file. This requires CUDA version > 3.2
31 #if defined(_WIN64) || defined(__LP64__)
32 typedef unsigned long long CUdeviceptr;
33 #else
34 typedef unsigned int CUdeviceptr;
35 #endif
36 
37 namespace sycl {
38 inline namespace _V1 {
39 namespace detail {
40 
41 // TODO the interops for context, device, event, platform and program
42 // may be removed after removing the deprecated 'get_native()' methods
43 // from the corresponding classes.
44 template <> struct interop<backend::ext_oneapi_cuda, context> {
45  using type = CUcontext;
46 };
47 
48 template <> struct interop<backend::ext_oneapi_cuda, device> {
49  using type = CUdevice;
50 };
51 
52 template <> struct interop<backend::ext_oneapi_cuda, event> {
53  using type = CUevent;
54 };
55 
56 template <> struct interop<backend::ext_oneapi_cuda, queue> {
57  using type = CUstream;
58 };
59 
60 template <typename DataT, int Dimensions, typename AllocatorT>
62  buffer<DataT, Dimensions, AllocatorT>> {
63  using type = CUdeviceptr;
64 };
65 
66 template <typename DataT, int Dimensions, typename AllocatorT>
68  buffer<DataT, Dimensions, AllocatorT>> {
69  using type = CUdeviceptr;
70 };
71 
73  using type = CUcontext;
74 };
75 
77  using type = CUcontext;
78 };
79 
80 template <> struct BackendInput<backend::ext_oneapi_cuda, device> {
81  using type = CUdevice;
82 };
83 
85  using type = CUdevice;
86 };
87 
88 template <> struct BackendInput<backend::ext_oneapi_cuda, event> {
89  using type = CUevent;
90 };
91 
92 template <> struct BackendReturn<backend::ext_oneapi_cuda, event> {
93  using type = CUevent;
94 };
95 
96 template <> struct BackendInput<backend::ext_oneapi_cuda, queue> {
97  using type = CUstream;
98 };
99 
101  using type = CUstream;
102 };
103 
104 } // namespace detail
105 } // namespace _V1
106 } // namespace sycl
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:168
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:64
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:44
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:111
unsigned int CUdeviceptr
struct CUevent_st * CUevent
struct CUmod_st * CUmodule
struct CUstream_st * CUstream
int CUdevice
struct CUctx_st * CUcontext
Definition: access.hpp:18