15
15
16
16
#include <stdio.h>
17
17
#include <hip/hip_runtime_api.h>
18
+ #include <hip/hip_version.h>
18
19
19
- #include "opal/mca/btl/base/base.h"
20
-
21
- typedef hipError_t (* hipMalloc_t )(void * * , size_t );
22
- typedef hipError_t (* hipFree_t )(void * );
23
- typedef hipError_t (* hipMemcpy_t )(void * , const void * , size_t , hipMemcpyKind );
24
- typedef hipError_t (* hipMemcpyAsync_t )(void * , const void * , size_t , hipMemcpyKind , hipStream_t );
25
- typedef hipError_t (* hipMemcpy2D_t )(void * , size_t , const void * , size_t , size_t , size_t , hipMemcpyKind );
26
- typedef hipError_t (* hipMemcpy2DAsync_t )(void * , size_t , const void * , size_t , size_t , size_t ,
27
- hipMemcpyKind , hipStream_t );
28
- typedef hipError_t (* hipMemGetAddressRange_t )(hipDeviceptr_t * , size_t * , hipDeviceptr_t );
29
- typedef hipError_t (* hipHostRegister_t )(void * , size_t , unsigned int );
30
- typedef hipError_t (* hipHostUnregister_t )(void * );
31
-
32
- typedef hipError_t (* hipStreamCreate_t )(hipStream_t * );
33
- typedef hipError_t (* hipStreamDestroy_t )(hipStream_t );
34
- typedef hipError_t (* hipStreamSynchronize_t )(hipStream_t );
35
-
36
- typedef const char * (* hipGetErrorString_t )(hipError_t );
37
- typedef hipError_t (* hipPointerGetAttributes_t )(hipPointerAttribute_t * , const void * );
38
-
39
- typedef hipError_t (* hipEventCreateWithFlags_t )(hipEvent_t * , unsigned );
40
- typedef hipError_t (* hipEventDestroy_t )(hipEvent_t );
41
- typedef hipError_t (* hipEventRecord_t )(hipEvent_t , hipStream_t );
42
- typedef hipError_t (* hipEventQuery_t )(hipEvent_t );
43
- typedef hipError_t (* hipEventSynchronize_t )(hipEvent_t );
44
-
45
- typedef hipError_t (* hipIpcGetMemHandle_t )(hipIpcMemHandle_t * , void * );
46
- typedef hipError_t (* hipIpcOpenMemHandle_t )(void * * , hipIpcMemHandle_t , unsigned int );
47
- typedef hipError_t (* hipIpcCloseMemHandle_t )(void * );
48
-
49
- typedef hipError_t (* hipGetDevice_t )(int * );
50
- typedef hipError_t (* hipGetDeviceCount_t )(int * );
51
- typedef hipError_t (* hipDeviceCanAccessPeer_t )(int * , int , int );
52
-
53
- struct opal_accelerator_rocm_hipFunctionTable_s {
54
- hipError_t (* hipMalloc )(void * * pts , size_t size );
55
- hipError_t (* hipFree )(void * ptr );
56
- hipError_t (* hipMemcpy )(void * dst , const void * src , size_t sizeBytes , hipMemcpyKind kind );
57
- hipError_t (* hipMemcpyAsync )(void * dst , const void * src , size_t sizeBytes , hipMemcpyKind kind ,
58
- hipStream_t stream );
59
- hipError_t (* hipMemcpy2D )(void * dst , size_t dpitch , const void * src , size_t spitch ,
60
- size_t width , size_t height , hipMemcpyKind kind );
61
- hipError_t (* hipMemcpy2DAsync )(void * dst , size_t dpitch , const void * src , size_t spitch ,
62
- size_t width , size_t height , hipMemcpyKind kind ,
63
- hipStream_t stream );
64
- hipError_t (* hipMemGetAddressRange )(hipDeviceptr_t * pbase , size_t * psize , hipDeviceptr_t dptr );
65
-
66
- hipError_t (* hipHostRegister )(void * ptr , size_t size , unsigned int flags );
67
- hipError_t (* hipHostUnregister )(void * ptr );
68
-
69
- hipError_t (* hipStreamCreate )(hipStream_t * stream );
70
- hipError_t (* hipStreamDestroy )(hipStream_t stream );
71
- hipError_t (* hipStreamSynchronize )(hipStream_t stream );
72
- const char * (* hipGetErrorString )(hipError_t hipError );
73
- hipError_t (* hipPointerGetAttributes )(hipPointerAttribute_t * attributes , const void * ptr );
74
-
75
- hipError_t (* hipEventCreateWithFlags )(hipEvent_t * event , unsigned int flags );
76
- hipError_t (* hipEventDestroy )(hipEvent_t event );
77
- hipError_t (* hipEventRecord )(hipEvent_t event , hipStream_t stream );
78
- hipError_t (* hipEventQuery )(hipEvent_t event );
79
- hipError_t (* hipEventSynchronize )(hipEvent_t event );
80
-
81
- hipError_t (* hipIpcGetMemHandle )(hipIpcMemHandle_t * handle , void * devPtr );
82
- hipError_t (* hipIpcOpenMemHandle )(void * * devPtr , hipIpcMemHandle_t handle , unsigned int flags );
83
- hipError_t (* hipIpcCloseMemHandle )(void * devPtr );
84
-
85
- hipError_t (* hipGetDevice )(int * dev_id );
86
- hipError_t (* hipGetDeviceCount )(int * count );
87
- hipError_t (* hipDeviceCanAccessPeer )(int * canAccess , int dev1 , int dev2 );
88
- };
89
- typedef struct opal_accelerator_rocm_hipFunctionTable_s opal_accelerator_rocm_hipFunctionTable_t ;
90
-
20
+ #include "opal/mca/accelerator/accelerator.h"
91
21
92
22
typedef struct {
93
23
opal_accelerator_base_component_t super ;
@@ -96,8 +26,6 @@ typedef struct {
96
26
OPAL_DECLSPEC extern opal_accelerator_rocm_component_t mca_accelerator_rocm_component ;
97
27
OPAL_DECLSPEC extern opal_accelerator_base_module_t opal_accelerator_rocm_module ;
98
28
99
- OPAL_DECLSPEC extern opal_accelerator_rocm_hipFunctionTable_t opal_accelerator_hip_funcs ;
100
-
101
29
struct opal_accelerator_rocm_stream_t {
102
30
opal_accelerator_stream_t base ;
103
31
};
@@ -110,8 +38,6 @@ struct opal_accelerator_rocm_event_t {
110
38
typedef struct opal_accelerator_rocm_event_t opal_accelerator_rocm_event_t ;
111
39
OBJ_CLASS_DECLARATION (opal_accelerator_rocm_event_t );
112
40
113
- #define HIP_FUNCS opal_accelerator_hip_funcs
114
-
115
41
OPAL_DECLSPEC extern hipStream_t opal_accelerator_rocm_MemcpyStream ;
116
42
OPAL_DECLSPEC extern int opal_accelerator_rocm_memcpy_async ;
117
43
OPAL_DECLSPEC extern int opal_accelerator_rocm_verbose ;
0 commit comments