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
199 bind(c, name =
'hip_device_mp_count')
200 use,
intrinsic :: iso_c_binding
207 bind(c, name =
'hip_device_total_mem')
208 use,
intrinsic :: iso_c_binding
213 bind(c, name =
'hipStreamCreate')
214 use,
intrinsic :: iso_c_binding
216 type(c_ptr) :: stream
220 bind(c, name =
'hipStreamCreateWithFlags')
221 use,
intrinsic :: iso_c_binding
223 type(c_ptr) :: stream
224 integer(c_int),
value :: flags
228 bind(c, name =
'hipStreamCreateWithPriority')
229 use,
intrinsic :: iso_c_binding
231 type(c_ptr) :: stream
232 integer(c_int),
value :: flags, prio
236 bind(c, name =
'hipStreamDestroy')
237 use,
intrinsic :: iso_c_binding
239 type(c_ptr),
value :: steam
243 bind(c, name =
'hipStreamSynchronize')
244 use,
intrinsic :: iso_c_binding
246 type(c_ptr),
value :: stream
250 bind(c, name =
'hipStreamWaitEvent')
251 use,
intrinsic :: iso_c_binding
253 type(c_ptr),
value :: stream, event
254 integer(c_int),
value :: flags
259 bind(c, name =
'hipDeviceGetStreamPriorityRange')
260 use,
intrinsic :: iso_c_binding
262 integer(c_int) :: low_prio, high_prio
266 bind(c, name =
'hipEventCreate')
267 use,
intrinsic :: iso_c_binding
273 bind(c, name =
'hipEventDestroy')
274 use,
intrinsic :: iso_c_binding
276 type(c_ptr),
value :: event
280 bind(c, name =
'hipEventCreateWithFlags')
281 use,
intrinsic :: iso_c_binding
284 integer(c_int),
value :: flags
288 bind(c, name =
'hipEventRecord')
289 use,
intrinsic :: iso_c_binding
291 type(c_ptr),
value :: event, stream
295 bind(c, name =
'hipEventSynchronize')
296 use,
intrinsic :: iso_c_binding
298 type(c_ptr),
value :: event
304 subroutine hip_init(glb_cmd_queue, aux_cmd_queue, &
305 STRM_HIGH_PRIO, STRM_LOW_PRIO)
306 type(c_ptr),
intent(inout) :: glb_cmd_queue
307 type(c_ptr),
intent(inout) :: aux_cmd_queue
308 integer,
intent(inout) :: STRM_HIGH_PRIO
309 integer,
intent(inout) :: STRM_LOW_PRIO
313 call neko_error(
'Error retrieving stream priority range')
328 type(c_ptr),
intent(inout) :: glb_cmd_queue
329 type(c_ptr),
intent(inout) :: aux_cmd_queue
336 call neko_error(
'Error destroying main stream')
340 call neko_error(
'Error destroying aux stream')
357 character(len=*),
intent(inout) :: name
358 character(kind=c_char, len=1024),
target :: c_name
365 end_pos = scan(c_name, c_null_char)
366 if (end_pos .ge. 2)
then
367 name(1:end_pos-1) = c_name(1:end_pos-1)
374 type(c_ptr) :: hip_count_ptr
378 call neko_error(
'Failed to query device count')
Number of compute units of the current device (0 if unknown), see device/hip/props....
Total memory of the current device in bytes (0 if unknown), see device/hip/props.hip.
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.