36 use,
intrinsic :: iso_c_binding
42 type(c_ptr),
bind(c) :: glb_cmd_queue = c_null_ptr
90 integer (c_int) function hipmalloc(ptr_d, s) &
91 bind(c, name=
'hipMalloc')
92 use,
intrinsic :: iso_c_binding
95 integer(c_size_t),
value :: s
96 end function hipmalloc
100 integer (c_int) function hipfree(ptr_d) &
101 bind(c, name=
'hipFree')
102 use,
intrinsic :: iso_c_binding
104 type(c_ptr),
value :: ptr_d
109 integer (c_int) function hipmemcpy(ptr_dst, ptr_src, s, dir) &
110 bind(c, name=
'hipMemcpy')
111 use,
intrinsic :: iso_c_binding
113 type(c_ptr),
value :: ptr_dst, ptr_src
114 integer(c_size_t),
value :: s
115 integer(c_int),
value :: dir
116 end function hipmemcpy
120 integer (c_int) function hipmemcpyasync(ptr_dst, ptr_src, s, dir, stream) &
121 bind(c, name=
'hipMemcpyAsync')
122 use,
intrinsic :: iso_c_binding
124 type(c_ptr),
value :: ptr_dst, ptr_src, stream
125 integer(c_size_t),
value :: s
126 integer(c_int),
value :: dir
127 end function hipmemcpyasync
131 integer (c_int) function hipdevicesynchronize() &
132 bind(c, name=
'hipDeviceSynchronize')
133 use,
intrinsic :: iso_c_binding
135 end function hipdevicesynchronize
139 integer (c_int) function hipdevicegetname(name, len, device) &
140 bind(c, name=
'hipDeviceGetName')
141 use,
intrinsic :: iso_c_binding
143 type(c_ptr),
value :: name
144 integer(c_int),
value :: len
145 integer(c_int),
value ::
device
146 end function hipdevicegetname
150 integer (c_int) function hipstreamcreate(stream) &
151 bind(c, name=
'hipStreamCreate')
152 use,
intrinsic :: iso_c_binding
154 type(c_ptr) :: stream
155 end function hipstreamcreate
159 integer (c_int) function hipstreamcreatewithflags(stream, flags) &
160 bind(c, name=
'hipStreamCreateWithFlags')
161 use,
intrinsic :: iso_c_binding
163 type(c_ptr) :: stream
164 integer(c_int),
value :: flags
165 end function hipstreamcreatewithflags
169 integer (c_int) function hipstreamcreatewithpriority(stream, flags, prio) &
170 bind(c, name=
'hipStreamCreateWithPriority')
171 use,
intrinsic :: iso_c_binding
173 type(c_ptr) :: stream
174 integer(c_int),
value :: flags, prio
175 end function hipstreamcreatewithpriority
179 integer (c_int) function hipstreamdestroy(steam) &
180 bind(c, name=
'hipStreamDestroy')
181 use,
intrinsic :: iso_c_binding
183 type(c_ptr),
value :: steam
184 end function hipstreamdestroy
188 integer (c_int) function hipstreamsynchronize(stream) &
189 bind(c, name=
'hipStreamSynchronize')
190 use,
intrinsic :: iso_c_binding
192 type(c_ptr),
value :: stream
193 end function hipstreamsynchronize
197 integer (c_int) function hipstreamwaitevent(stream, event, flags) &
198 bind(c, name=
'hipStreamWaitEvent')
199 use,
intrinsic :: iso_c_binding
201 type(c_ptr),
value :: stream, event
202 integer(c_int),
value :: flags
203 end function hipstreamwaitevent
207 integer (c_int) function hipdevicegetstreampriorityrange(low_prio, high_prio) &
208 bind(c, name=
'hipDeviceGetStreamPriorityRange')
209 use,
intrinsic :: iso_c_binding
211 integer(c_int) :: low_prio, high_prio
212 end function hipdevicegetstreampriorityrange
216 integer (c_int) function hipeventcreate(event) &
217 bind(c, name=
'hipEventCreate')
218 use,
intrinsic :: iso_c_binding
221 end function hipeventcreate
225 integer (c_int) function hipeventdestroy(event) &
226 bind(c, name=
'hipEventDestroy')
227 use,
intrinsic :: iso_c_binding
229 type(c_ptr),
value :: event
230 end function hipeventdestroy
234 integer (c_int) function hipeventcreatewithflags(event, flags) &
235 bind(c, name=
'hipEventCreateWithFlags')
236 use,
intrinsic :: iso_c_binding
239 integer(c_int),
value :: flags
240 end function hipeventcreatewithflags
244 integer (c_int) function hipeventrecord(event, stream) &
245 bind(c, name=
'hipEventRecord')
246 use,
intrinsic :: iso_c_binding
248 type(c_ptr),
value :: event, stream
249 end function hipeventrecord
253 integer (c_int) function hipeventsynchronize(event) &
254 bind(c, name=
'hipEventSynchronize')
255 use,
intrinsic :: iso_c_binding
257 type(c_ptr),
value :: event
258 end function hipeventsynchronize
267 call neko_error(
'Error retrieving stream priority range')
270 if (hipstreamcreatewithpriority(glb_cmd_queue, 1,
strm_high_prio) &
282 if (hipstreamdestroy(glb_cmd_queue) .ne.
hipsuccess)
then
283 call neko_error(
'Error destroying main stream')
287 call neko_error(
'Error destroying aux stream')
292 character(len=*),
intent(inout) :: name
293 character(kind=c_char, len=1024),
target :: c_name
296 if (hipdevicegetname(c_loc(c_name), 1024, 0) .ne.
hipsuccess)
then
300 end_pos = scan(c_name, c_null_char)
301 if(end_pos .ge. 2)
then
302 name(1:end_pos-1) = c_name(1:end_pos-1)
Device abstraction, common interface for various accelerators.
type(c_ptr), bind(C) aux_cmd_queue
Aux HIP command queue.
integer strm_low_prio
Low priority stream setting.
subroutine hip_device_name(name)
@ hipmemcpydevicetodevice
integer strm_high_prio
High priority stream setting.
@ hiperrormapbufferobjectfailed
@ hiperrorinvaliddevicepointer
@ hiperrorpeeraccessnotenabled
@ hiperrorinvalidkernelfile
@ hiperrorpeeraccessalreadyenabled
@ hiperrorinvalidresourcehandle
@ hiperrorhostmemorynotregistered
@ hiperrormemoryallocation
@ hiperrorlaunchoutofresources
@ hiperrorinvalidmemcpydirection
@ hiperrorinitializationerror
@ hiperrorhostmemoryalreadyregistered