DPC++ Runtime
Runtime libraries for oneAPI DPC++
backend_traits_hip.hpp
Go to the documentation of this file.
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 <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 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 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 // TODO the interops for accessor is used in the already deprecated class
58 // interop_handler and can be removed after API cleanup.
59 template <typename DataT, int Dimensions, access::mode AccessMode>
61  accessor<DataT, Dimensions, AccessMode, access::target::device,
62  access::placeholder::false_t>> {
63  using type = HIPdeviceptr;
64 };
65 
66 template <typename DataT, int Dimensions, access::mode AccessMode>
67 struct interop<
69  accessor<DataT, Dimensions, AccessMode, access::target::constant_buffer,
70  access::placeholder::false_t>> {
71  using type = HIPdeviceptr;
72 };
73 
74 template <typename DataT, int Dimensions, typename AllocatorT>
76  buffer<DataT, Dimensions, AllocatorT>> {
77  using type = HIPdeviceptr;
78 };
79 
80 template <typename DataT, int Dimensions, typename AllocatorT>
82  buffer<DataT, Dimensions, AllocatorT>> {
83  using type = HIPdeviceptr;
84 };
85 
86 template <> struct BackendInput<backend::ext_oneapi_hip, context> {
87  using type = HIPcontext;
88 };
89 
91  using type = HIPcontext;
92 };
93 
94 template <> struct BackendInput<backend::ext_oneapi_hip, device> {
95  using type = HIPdevice;
96 };
97 
98 template <> struct BackendReturn<backend::ext_oneapi_hip, device> {
99  using type = HIPdevice;
100 };
101 
102 template <> struct BackendInput<backend::ext_oneapi_hip, event> {
103  using type = HIPevent;
104 };
105 
106 template <> struct BackendReturn<backend::ext_oneapi_hip, event> {
107  using type = HIPevent;
108 };
109 
110 template <> struct BackendInput<backend::ext_oneapi_hip, queue> {
111  using type = HIPstream;
112 };
113 
114 template <> struct BackendReturn<backend::ext_oneapi_hip, queue> {
115  using type = HIPstream;
116 };
117 
118 } // namespace detail
119 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
120 } // namespace sycl
The file contains implementations of accessor class.
struct ihipEvent_t * HIPevent
struct ihipModule_t * HIPmodule
struct ihipStream_t * HIPstream
void * HIPdeviceptr
struct ihipCtx_t * HIPcontext
int HIPdevice
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:137
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:39
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:47
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:38
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:86
#define __SYCL_INLINE_VER_NAMESPACE(X)
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14