36 use,
intrinsic :: iso_c_binding
72 integer (c_int) function cudamalloc(ptr_d, s) &
73 bind(c, name=
'cudaMalloc')
74 use,
intrinsic :: iso_c_binding
77 integer(c_size_t),
value :: s
78 end function cudamalloc
82 integer (c_int) function cudafree(ptr_d) &
83 bind(c, name=
'cudaFree')
84 use,
intrinsic :: iso_c_binding
86 type(c_ptr),
value :: ptr_d
91 integer (c_int) function cudamemcpy(ptr_dst, ptr_src, s, dir) &
92 bind(c, name=
'cudaMemcpy')
93 use,
intrinsic :: iso_c_binding
95 type(c_ptr),
value :: ptr_dst, ptr_src
96 integer(c_size_t),
value :: s
97 integer(c_int),
value :: dir
98 end function cudamemcpy
102 integer (c_int) function cudamemcpyasync(ptr_dst, ptr_src, s, dir, stream) &
103 bind(c, name=
'cudaMemcpyAsync')
104 use,
intrinsic :: iso_c_binding
106 type(c_ptr),
value :: ptr_dst, ptr_src, stream
107 integer(c_size_t),
value :: s
108 integer(c_int),
value :: dir
109 end function cudamemcpyasync
113 integer (c_int) function cudadevicesynchronize() &
114 bind(c, name=
'cudaDeviceSynchronize')
115 use,
intrinsic :: iso_c_binding
117 end function cudadevicesynchronize
121 integer (c_int) function cudagetdeviceproperties(prop, device) &
122 bind(c, name=
'cudaGetDeviceProperties')
123 use,
intrinsic :: iso_c_binding
125 type(c_ptr),
value :: prop
126 integer(c_int),
value ::
device
127 end function cudagetdeviceproperties
131 integer (c_int) function cudastreamcreate(stream) &
132 bind(c, name=
'cudaStreamCreate')
133 use,
intrinsic :: iso_c_binding
135 type(c_ptr) :: stream
136 end function cudastreamcreate
140 integer (c_int) function cudastreamcreatewithflags(stream, flags) &
141 bind(c, name=
'cudaStreamCreateWithFlags')
142 use,
intrinsic :: iso_c_binding
144 type(c_ptr) :: stream
145 integer(c_int),
value :: flags
146 end function cudastreamcreatewithflags
150 integer (c_int) function cudastreamcreatewithpriority(stream, flags, prio) &
151 bind(c, name=
'cudaStreamCreateWithPriority')
152 use,
intrinsic :: iso_c_binding
154 type(c_ptr) :: stream
155 integer(c_int),
value :: flags, prio
156 end function cudastreamcreatewithpriority
160 integer (c_int) function cudastreamdestroy(steam) &
161 bind(c, name=
'cudaStreamDestroy')
162 use,
intrinsic :: iso_c_binding
164 type(c_ptr),
value :: steam
165 end function cudastreamdestroy
169 integer (c_int) function cudastreamsynchronize(stream) &
170 bind(c, name=
'cudaStreamSynchronize')
171 use,
intrinsic :: iso_c_binding
173 type(c_ptr),
value :: stream
174 end function cudastreamsynchronize
178 integer (c_int) function cudastreamwaitevent(stream, event, flags) &
179 bind(c, name=
'cudaStreamWaitEvent')
180 use,
intrinsic :: iso_c_binding
182 type(c_ptr),
value :: stream, event
183 integer(c_int),
value :: flags
184 end function cudastreamwaitevent
188 integer (c_int) function cudadevicegetstreampriorityrange(low_prio, high_prio) &
189 bind(c, name=
'cudaDeviceGetStreamPriorityRange')
190 use,
intrinsic :: iso_c_binding
192 integer(c_int) :: low_prio, high_prio
193 end function cudadevicegetstreampriorityrange
197 integer (c_int) function cudaprofilerstart() &
198 bind(c, name=
'cudaProfilerStart')
199 use,
intrinsic :: iso_c_binding
201 end function cudaprofilerstart
205 integer (c_int) function cudaprofilerstop() &
206 bind(c, name=
'cudaProfilerStop')
207 use,
intrinsic :: iso_c_binding
209 end function cudaprofilerstop
213 integer (c_int) function cudaeventcreate(event) &
214 bind(c, name=
'cudaEventCreate')
215 use,
intrinsic :: iso_c_binding
218 end function cudaeventcreate
222 integer (c_int) function cudaeventdestroy(event) &
223 bind(c, name=
'cudaEventDestroy')
224 use,
intrinsic :: iso_c_binding
226 type(c_ptr),
value :: event
227 end function cudaeventdestroy
231 integer (c_int) function cudaeventcreatewithflags(event, flags) &
232 bind(c, name=
'cudaEventCreateWithFlags')
233 use,
intrinsic :: iso_c_binding
236 integer(c_int),
value :: flags
237 end function cudaeventcreatewithflags
241 integer (c_int) function cudaeventrecord(event, stream) &
242 bind(c, name=
'cudaEventRecord')
243 use,
intrinsic :: iso_c_binding
245 type(c_ptr),
value :: event, stream
246 end function cudaeventrecord
250 integer (c_int) function cudaeventsynchronize(event) &
251 bind(c, name=
'cudaEventSynchronize')
252 use,
intrinsic :: iso_c_binding
254 type(c_ptr),
value :: event
255 end function cudaeventsynchronize
259 integer (c_int) function cudagetdevice(device) &
260 bind(c, name=
'cudaGetDevice')
261 use,
intrinsic :: iso_c_binding
264 end function cudagetdevice
268 integer (c_int) function cudasetdevice(device) &
269 bind(c, name=
'cudaSetDevice')
270 use,
intrinsic :: iso_c_binding
272 integer(c_int),
value ::
device
273 end function cudasetdevice
279 integer(c_int) :: device_id
280 integer :: nthrds = 1
289 if (nthrds .gt. 1)
then
290 if (cudagetdevice(device_id) .ne.
cudasuccess)
then
295 if (cudasetdevice(device_id) .ne.
cudasuccess)
then
303 call neko_error(
'Error retrieving stream priority range')
319 call neko_error(
'Error destroying main stream')
323 call neko_error(
'Error destroying aux stream')
328 character(len=*),
intent(inout) :: name
329 character(kind=c_char, len=8192),
target :: prop
341 if (cudagetdeviceproperties(c_loc(prop), 0) .ne.
cudasuccess)
then
345 end_pos = scan(prop(1:256), c_null_char)
346 if(end_pos .ge. 2)
then
347 name(1:end_pos-1) = prop(1:end_pos-1)
subroutine cuda_device_name(name)
type(c_ptr), bind(C) aux_cmd_queue
Aux HIP command queue.
@ cudamemcpydevicetodevice
@ cudaerrorinitializationerror
@ cudaerrormemoryallocation
type(c_ptr), bind(C) glb_cmd_queue
Global HIP command queue.
integer strm_low_prio
Low priority stream setting.
integer strm_high_prio
High priority stream setting.
Device abstraction, common interface for various accelerators.