|
| 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> |
| 19 | +#include <CL/sycl/detail/backend_traits.hpp> |
| 20 | +#include <CL/sycl/device.hpp> |
| 21 | +#include <CL/sycl/event.hpp> |
| 22 | +#include <CL/sycl/kernel_bundle.hpp> |
| 23 | +#include <CL/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 | +__SYCL_INLINE_NAMESPACE(cl) { |
| 34 | +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 | +#ifdef __SYCL_INTERNAL_API |
| 63 | +template <> struct interop<backend::ext_oneapi_cuda, program> { |
| 64 | + using type = CUmodule; |
| 65 | +}; |
| 66 | +#endif |
| 67 | + |
| 68 | +template <typename DataT, int Dimensions, typename AllocatorT> |
| 69 | +struct BackendInput<backend::ext_oneapi_cuda, |
| 70 | + buffer<DataT, Dimensions, AllocatorT>> { |
| 71 | + using type = DataT *; |
| 72 | +}; |
| 73 | + |
| 74 | +template <typename DataT, int Dimensions, typename AllocatorT> |
| 75 | +struct BackendReturn<backend::ext_oneapi_cuda, |
| 76 | + buffer<DataT, Dimensions, AllocatorT>> { |
| 77 | + using type = DataT *; |
| 78 | +}; |
| 79 | + |
| 80 | +template <> struct BackendInput<backend::ext_oneapi_cuda, context> { |
| 81 | + using type = CUcontext; |
| 82 | +}; |
| 83 | + |
| 84 | +template <> struct BackendReturn<backend::ext_oneapi_cuda, context> { |
| 85 | + using type = std::vector<CUcontext>; |
| 86 | +}; |
| 87 | + |
| 88 | +template <> struct BackendInput<backend::ext_oneapi_cuda, device> { |
| 89 | + using type = CUdevice; |
| 90 | +}; |
| 91 | + |
| 92 | +template <> struct BackendReturn<backend::ext_oneapi_cuda, device> { |
| 93 | + using type = CUdevice; |
| 94 | +}; |
| 95 | + |
| 96 | +template <> struct BackendInput<backend::ext_oneapi_cuda, event> { |
| 97 | + using type = CUevent; |
| 98 | +}; |
| 99 | + |
| 100 | +template <> struct BackendReturn<backend::ext_oneapi_cuda, event> { |
| 101 | + using type = CUevent; |
| 102 | +}; |
| 103 | + |
| 104 | +template <> struct BackendInput<backend::ext_oneapi_cuda, queue> { |
| 105 | + using type = CUstream; |
| 106 | +}; |
| 107 | + |
| 108 | +template <> struct BackendReturn<backend::ext_oneapi_cuda, queue> { |
| 109 | + using type = CUstream; |
| 110 | +}; |
| 111 | + |
| 112 | +template <> struct BackendInput<backend::ext_oneapi_cuda, platform> { |
| 113 | + using type = std::vector<CUdevice>; |
| 114 | +}; |
| 115 | + |
| 116 | +template <> struct BackendReturn<backend::ext_oneapi_cuda, platform> { |
| 117 | + using type = std::vector<CUdevice>; |
| 118 | +}; |
| 119 | + |
| 120 | +#ifdef __SYCL_INTERNAL_API |
| 121 | +template <> struct BackendInput<backend::ext_oneapi_cuda, program> { |
| 122 | + using type = CUmodule; |
| 123 | +}; |
| 124 | + |
| 125 | +template <> struct BackendReturn<backend::ext_oneapi_cuda, program> { |
| 126 | + using type = CUmodule; |
| 127 | +}; |
| 128 | +#endif |
| 129 | + |
| 130 | +template <> struct InteropFeatureSupportMap<backend::ext_oneapi_cuda> { |
| 131 | + static constexpr bool MakePlatform = false; |
| 132 | + static constexpr bool MakeDevice = true; |
| 133 | + static constexpr bool MakeContext = true; |
| 134 | + static constexpr bool MakeQueue = false; |
| 135 | + static constexpr bool MakeEvent = false; |
| 136 | + static constexpr bool MakeBuffer = false; |
| 137 | + static constexpr bool MakeKernel = false; |
| 138 | + static constexpr bool MakeKernelBundle = false; |
| 139 | +}; |
| 140 | + |
| 141 | +} // namespace detail |
| 142 | +} // namespace sycl |
| 143 | +} // __SYCL_INLINE_NAMESPACE(cl) |
0 commit comments