|
| 1 | +//===------- backend_traits_hip.hpp - Backend traits for HIP ---*-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 HIP backend but there is no sycl::detail::InteropFeatureSupportMap |
| 12 | +// specialization for the HIP 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 | +typedef int HIPdevice; |
| 26 | +typedef struct ihipCtx_t *HIPcontext; |
| 27 | +typedef struct ihipStream_t *HIPstream; |
| 28 | +typedef struct ihipEvent_t *HIPevent; |
| 29 | +typedef struct ihipModule_t *HIPmodule; |
| 30 | +typedef void *HIPdeviceptr; |
| 31 | + |
| 32 | +__SYCL_INLINE_NAMESPACE(cl) { |
| 33 | +namespace sycl { |
| 34 | +namespace detail { |
| 35 | + |
| 36 | +// TODO the interops for context, device, event, platform and program |
| 37 | +// may be removed after removing the deprecated 'get_native()' methods |
| 38 | +// from the corresponding classes. The interop<backend, queue> specialization |
| 39 | +// is also used in the get_queue() method of the deprecated class |
| 40 | +// interop_handler and also can be removed after API cleanup. |
| 41 | +template <> struct interop<backend::ext_oneapi_hip, context> { |
| 42 | + using type = HIPcontext; |
| 43 | +}; |
| 44 | + |
| 45 | +template <> struct interop<backend::ext_oneapi_hip, device> { |
| 46 | + using type = HIPdevice; |
| 47 | +}; |
| 48 | + |
| 49 | +template <> struct interop<backend::ext_oneapi_hip, event> { |
| 50 | + using type = HIPevent; |
| 51 | +}; |
| 52 | + |
| 53 | +template <> struct interop<backend::ext_oneapi_hip, queue> { |
| 54 | + using type = HIPstream; |
| 55 | +}; |
| 56 | + |
| 57 | +#ifdef __SYCL_INTERNAL_API |
| 58 | +template <> struct interop<backend::ext_oneapi_hip, program> { |
| 59 | + using type = HIPmodule; |
| 60 | +}; |
| 61 | +#endif |
| 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> |
| 66 | +struct interop<backend::ext_oneapi_hip, |
| 67 | + accessor<DataT, Dimensions, AccessMode, access::target::device, |
| 68 | + access::placeholder::false_t>> { |
| 69 | + using type = HIPdeviceptr; |
| 70 | +}; |
| 71 | + |
| 72 | +template <typename DataT, int Dimensions, access::mode AccessMode> |
| 73 | +struct interop< |
| 74 | + backend::ext_oneapi_hip, |
| 75 | + accessor<DataT, Dimensions, AccessMode, access::target::constant_buffer, |
| 76 | + access::placeholder::false_t>> { |
| 77 | + using type = HIPdeviceptr; |
| 78 | +}; |
| 79 | + |
| 80 | +template <typename DataT, int Dimensions, typename AllocatorT> |
| 81 | +struct BackendInput<backend::ext_oneapi_hip, |
| 82 | + buffer<DataT, Dimensions, AllocatorT>> { |
| 83 | + using type = HIPdeviceptr; |
| 84 | +}; |
| 85 | + |
| 86 | +template <typename DataT, int Dimensions, typename AllocatorT> |
| 87 | +struct BackendReturn<backend::ext_oneapi_hip, |
| 88 | + buffer<DataT, Dimensions, AllocatorT>> { |
| 89 | + using type = HIPdeviceptr; |
| 90 | +}; |
| 91 | + |
| 92 | +template <> struct BackendInput<backend::ext_oneapi_hip, context> { |
| 93 | + using type = HIPcontext; |
| 94 | +}; |
| 95 | + |
| 96 | +template <> struct BackendReturn<backend::ext_oneapi_hip, context> { |
| 97 | + using type = HIPcontext; |
| 98 | +}; |
| 99 | + |
| 100 | +template <> struct BackendInput<backend::ext_oneapi_hip, device> { |
| 101 | + using type = HIPdevice; |
| 102 | +}; |
| 103 | + |
| 104 | +template <> struct BackendReturn<backend::ext_oneapi_hip, device> { |
| 105 | + using type = HIPdevice; |
| 106 | +}; |
| 107 | + |
| 108 | +template <> struct BackendInput<backend::ext_oneapi_hip, event> { |
| 109 | + using type = HIPevent; |
| 110 | +}; |
| 111 | + |
| 112 | +template <> struct BackendReturn<backend::ext_oneapi_hip, event> { |
| 113 | + using type = HIPevent; |
| 114 | +}; |
| 115 | + |
| 116 | +template <> struct BackendInput<backend::ext_oneapi_hip, queue> { |
| 117 | + using type = HIPstream; |
| 118 | +}; |
| 119 | + |
| 120 | +template <> struct BackendReturn<backend::ext_oneapi_hip, queue> { |
| 121 | + using type = HIPstream; |
| 122 | +}; |
| 123 | + |
| 124 | +#ifdef __SYCL_INTERNAL_API |
| 125 | +template <> struct BackendInput<backend::ext_oneapi_hip, program> { |
| 126 | + using type = HIPmodule; |
| 127 | +}; |
| 128 | + |
| 129 | +template <> struct BackendReturn<backend::ext_oneapi_hip, program> { |
| 130 | + using type = HIPmodule; |
| 131 | +}; |
| 132 | +#endif |
| 133 | + |
| 134 | +} // namespace detail |
| 135 | +} // namespace sycl |
| 136 | +} // __SYCL_INLINE_NAMESPACE(cl) |
0 commit comments