36 use,
intrinsic :: iso_c_binding
79 bind(c, name =
'hipMalloc')
80 use,
intrinsic :: iso_c_binding
83 integer(c_size_t),
value :: s
87 bind(c, name =
'hipFree')
88 use,
intrinsic :: iso_c_binding
90 type(c_ptr),
value :: ptr_d
95 integer(c_int) function hipmap(ptr_d, ptr_h, s) &
96 bind(c, name =
'hip_map')
97 use,
intrinsic :: iso_c_binding
100 type(c_ptr),
value :: ptr_h
101 integer(c_size_t),
value :: s
107 bind(c, name =
'hip_map_free')
108 use,
intrinsic :: iso_c_binding
110 type(c_ptr),
value :: ptr_d
116 bind(c, name =
'hip_map_memset')
117 use,
intrinsic :: iso_c_binding
119 type(c_ptr),
value :: ptr_d
120 integer(c_int),
value :: v
121 integer(c_size_t),
value :: s
122 type(c_ptr),
value :: stream
128 integer(c_int) function hipmapmemcpy(ptr_dst, ptr_src, s, dir, stream) &
129 bind(c, name =
'hip_map_memcpy')
130 use,
intrinsic :: iso_c_binding
132 type(c_ptr),
value :: ptr_dst, ptr_src, stream
133 integer(c_size_t),
value :: s
134 integer(c_int),
value :: dir
137 integer(c_int) function hipmemcpy(ptr_dst, ptr_src, s, dir) &
138 bind(c, name =
'hipMemcpy')
139 use,
intrinsic :: iso_c_binding
141 type(c_ptr),
value :: ptr_dst, ptr_src
142 integer(c_size_t),
value :: s
143 integer(c_int),
value :: dir
147 bind(c, name =
'hipMemcpyAsync')
148 use,
intrinsic :: iso_c_binding
150 type(c_ptr),
value :: ptr_dst, ptr_src, stream
151 integer(c_size_t),
value :: s
152 integer(c_int),
value :: dir
156 bind(c, name =
'hipMemsetAsync')
157 use,
intrinsic :: iso_c_binding
159 type(c_ptr),
value :: ptr, stream
160 integer(c_int),
value :: v
161 integer(c_size_t),
value :: s
165 bind(c, name =
'hipDeviceSynchronize')
166 use,
intrinsic :: iso_c_binding
171 bind(c, name =
'hipDeviceReset')
172 use,
intrinsic :: iso_c_binding
177 bind(c, name =
'hip_buffer_free_all')
181 bind(c, name =
'hipDeviceGetName')
182 use,
intrinsic :: iso_c_binding
184 type(c_ptr),
value :: name
185 integer(c_int),
value :: len
186 integer(c_int),
value ::
device
190 bind(c, name =
'hipGetDeviceCount')
191 use,
intrinsic :: iso_c_binding
193 integer(c_int) :: amount
197 bind(c, name =
'hipStreamCreate')
198 use,
intrinsic :: iso_c_binding
200 type(c_ptr) :: stream
204 bind(c, name =
'hipStreamCreateWithFlags')
205 use,
intrinsic :: iso_c_binding
207 type(c_ptr) :: stream
208 integer(c_int),
value :: flags
212 bind(c, name =
'hipStreamCreateWithPriority')
213 use,
intrinsic :: iso_c_binding
215 type(c_ptr) :: stream
216 integer(c_int),
value :: flags, prio
220 bind(c, name =
'hipStreamDestroy')
221 use,
intrinsic :: iso_c_binding
223 type(c_ptr),
value :: steam
227 bind(c, name =
'hipStreamSynchronize')
228 use,
intrinsic :: iso_c_binding
230 type(c_ptr),
value :: stream
234 bind(c, name =
'hipStreamWaitEvent')
235 use,
intrinsic :: iso_c_binding
237 type(c_ptr),
value :: stream, event
238 integer(c_int),
value :: flags
243 bind(c, name =
'hipDeviceGetStreamPriorityRange')
244 use,
intrinsic :: iso_c_binding
246 integer(c_int) :: low_prio, high_prio
250 bind(c, name =
'hipEventCreate')
251 use,
intrinsic :: iso_c_binding
257 bind(c, name =
'hipEventDestroy')
258 use,
intrinsic :: iso_c_binding
260 type(c_ptr),
value :: event
264 bind(c, name =
'hipEventCreateWithFlags')
265 use,
intrinsic :: iso_c_binding
268 integer(c_int),
value :: flags
272 bind(c, name =
'hipEventRecord')
273 use,
intrinsic :: iso_c_binding
275 type(c_ptr),
value :: event, stream
279 bind(c, name =
'hipEventSynchronize')
280 use,
intrinsic :: iso_c_binding
282 type(c_ptr),
value :: event
288 subroutine hip_init(glb_cmd_queue, aux_cmd_queue, &
289 STRM_HIGH_PRIO, STRM_LOW_PRIO)
290 type(c_ptr),
intent(inout) :: glb_cmd_queue
291 type(c_ptr),
intent(inout) :: aux_cmd_queue
292 integer,
intent(inout) :: STRM_HIGH_PRIO
293 integer,
intent(inout) :: STRM_LOW_PRIO
297 call neko_error(
'Error retrieving stream priority range')
312 type(c_ptr),
intent(inout) :: glb_cmd_queue
313 type(c_ptr),
intent(inout) :: aux_cmd_queue
320 call neko_error(
'Error destroying main stream')
324 call neko_error(
'Error destroying aux stream')
341 character(len=*),
intent(inout) :: name
342 character(kind=c_char, len=1024),
target :: c_name
349 end_pos = scan(c_name, c_null_char)
350 if (end_pos .ge. 2)
then
351 name(1:end_pos-1) = c_name(1:end_pos-1)
358 type(c_ptr) :: hip_count_ptr
362 call neko_error(
'Failed to query device count')
Map host memory to the device (zero-copy on unified memory architectures, e.g. MI300A,...
Free a device pointer obtained from hipMap (no-op for pointers aliasing host memory)
Copy between device/host pointers via the mapping layer (kernel-based copy under zero-copy,...
Memset on a device pointer obtained from hipMap (host-side memset for pointers aliasing host memory)
Device abstraction, common interface for various accelerators.
subroutine hip_device_name(name)
@ hipmemcpydevicetodevice
subroutine hip_init(glb_cmd_queue, aux_cmd_queue, strm_high_prio, strm_low_prio)
subroutine hip_finalize(glb_cmd_queue, aux_cmd_queue)
@ hiperrormapbufferobjectfailed
@ hiperrorinvaliddevicepointer
@ hiperrorpeeraccessnotenabled
@ hiperrorinvalidkernelfile
@ hiperrorpeeraccessalreadyenabled
@ hiperrorinvalidresourcehandle
@ hiperrorhostmemorynotregistered
@ hiperrormemoryallocation
@ hiperrorlaunchoutofresources
@ hiperrorinvalidmemcpydirection
@ hiperrorinitializationerror
@ hiperrorhostmemoryalreadyregistered
integer function hip_device_count()
Return the number of available HIP devices.