1 ! OpenACC Runtime Library Definitions
. -*- mode
: fortran
-*-
3 ! Copyright (C
) 2014-2022 Free Software Foundation
, Inc
.
5 ! Contributed by Tobias Burnus
<burnus@net
-b
.de
>
8 ! This file is part of the GNU Offloading
and Multi Processing Library
11 ! Libgomp is free software
; you can redistribute it
and/or modify it
12 ! under the terms of the GNU General Public License as published by
13 ! the Free Software Foundation
; either version
3, or (at your option
)
16 ! Libgomp is distributed in the hope that it will be useful
, but WITHOUT ANY
17 ! WARRANTY
; without even the implied warranty of MERCHANTABILITY
or FITNESS
18 ! FOR A PARTICULAR PURPOSE
. See the GNU General Public License
for
21 ! Under Section
7 of GPL version
3, you are granted additional
22 ! permissions described in the GCC Runtime Library Exception
, version
23 ! 3.1, as published by the Free Software Foundation
.
25 ! You should have received a copy of the GNU General Public License
and
26 ! a copy of the GCC Runtime Library Exception along with
this program
;
27 ! see the files COPYING3
and COPYING
.RUNTIME respectively
. If
not, see
28 ! <http
://www.gnu.org/licenses/>.
30 ! NOTE
: Due to the use of
dimension (..), the code only works when compiled
31 ! with
-std
=f2008ts
/gnu
/legacy but
not with other standard settings
.
32 ! Alternatively
, the user can use the module version
, which permits
33 ! compilation with
-std
=f95
.
35 ! Keep in sync with openacc
.f90
and config
/accel
/openacc
.f90
.
37 integer
, parameter :: acc_device_kind
= 4
39 ! Keep in sync with include
/gomp
-constants
.h
.
40 integer (acc_device_kind
), parameter :: acc_device_current
= -1
41 integer (acc_device_kind
), parameter :: acc_device_none
= 0
42 integer (acc_device_kind
), parameter :: acc_device_default
= 1
43 integer (acc_device_kind
), parameter :: acc_device_host
= 2
44 ! integer (acc_device_kind
), parameter :: acc_device_host_nonshm
= 3
46 integer (acc_device_kind
), parameter :: acc_device_not_host
= 4
47 integer (acc_device_kind
), parameter :: acc_device_nvidia
= 5
48 integer (acc_device_kind
), parameter :: acc_device_radeon
= 8
50 integer
, parameter :: acc_device_property_kind
= 4
51 ! OpenACC
2.6/2.7/3.0 used acc_device_property
; in a spec update the
52 ! missing
'_kind' was added
for consistency
. For backward compatibility
, keep
:
53 integer
, parameter :: acc_device_property
&
54 & = acc_device_property_kind
56 integer (acc_device_property_kind
), parameter :: &
57 & acc_property_memory
= 1
58 integer (acc_device_property_kind
), parameter :: &
59 & acc_property_free_memory
= 2
60 integer (acc_device_property_kind
), parameter :: &
61 & acc_property_name
= int(Z
'10001')
62 integer (acc_device_property_kind
), parameter :: &
63 & acc_property_vendor
= int(Z
'10002')
64 integer (acc_device_property_kind
), parameter :: &
65 & acc_property_driver
= int(Z
'10003')
67 integer
, parameter :: acc_handle_kind
= 4
69 ! Keep in sync with include
/gomp
-constants
.h
.
70 integer (acc_handle_kind
), parameter :: acc_async_noval
= -1
71 integer (acc_handle_kind
), parameter :: acc_async_sync
= -2
73 integer
, parameter :: openacc_version
= 201711
75 interface acc_get_num_devices
76 function
acc_get_num_devices_h (devicetype
)
77 import acc_device_kind
78 integer acc_get_num_devices_h
79 integer (acc_device_kind
) devicetype
83 interface acc_set_device_type
84 subroutine
acc_set_device_type_h (devicetype
)
85 import acc_device_kind
86 integer (acc_device_kind
) devicetype
90 interface acc_get_device_type
91 function
acc_get_device_type_h ()
92 import acc_device_kind
93 integer (acc_device_kind
) acc_get_device_type_h
97 interface acc_set_device_num
98 subroutine
acc_set_device_num_h (devicenum
, devicetype
)
99 import acc_device_kind
101 integer (acc_device_kind
) devicetype
105 interface acc_get_device_num
106 function
acc_get_device_num_h (devicetype
)
107 import acc_device_kind
108 integer acc_get_device_num_h
109 integer (acc_device_kind
) devicetype
113 interface acc_get_property
114 function
acc_get_property_h (devicenum
, devicetype
, &
116 use iso_c_binding
, only
: c_size_t
117 import acc_device_kind
, acc_device_property_kind
118 implicit
none (type
, external
)
119 integer (c_size_t
) :: acc_get_property_h
120 integer
, value :: devicenum
121 integer (acc_device_kind
), value :: devicetype
122 integer (acc_device_property_kind
), value :: property
126 interface acc_get_property_string
127 subroutine
acc_get_property_string_h (devicenum
, devicetype
, &
129 import acc_device_kind
, acc_device_property_kind
130 implicit
none (type
, external
)
131 integer
, value :: devicenum
132 integer (acc_device_kind
), value :: devicetype
133 integer (acc_device_property_kind
), value :: property
134 character (*) :: string
138 interface acc_async_test
139 function
acc_async_test_h (arg
)
140 logical acc_async_test_h
145 interface acc_async_test_all
146 function
acc_async_test_all_h ()
147 logical acc_async_test_all_h
152 subroutine
acc_wait_h (arg
)
157 ! acc_async_wait is an OpenACC
1.0 compatibility name
for acc_wait
.
158 interface acc_async_wait
159 procedure :: acc_wait_h
162 interface acc_wait_async
163 subroutine
acc_wait_async_h (arg
, async
)
168 interface acc_wait_all
169 subroutine
acc_wait_all_h ()
173 ! acc_async_wait_all is an OpenACC
1.0 compatibility name
for
175 interface acc_async_wait_all
176 procedure :: acc_wait_all_h
179 interface acc_wait_all_async
180 subroutine
acc_wait_all_async_h (async
)
186 subroutine
acc_init_h (devicetype
)
187 import acc_device_kind
188 integer (acc_device_kind
) devicetype
192 interface acc_shutdown
193 subroutine
acc_shutdown_h (devicetype
)
194 import acc_device_kind
195 integer (acc_device_kind
) devicetype
199 interface acc_on_device
200 function
acc_on_device_h (devicetype
)
201 import acc_device_kind
202 logical acc_on_device_h
203 integer (acc_device_kind
) devicetype
207 ! acc_malloc
: Only available in C
/C
++
208 ! acc_free
: Only available in C
/C
++
211 subroutine
acc_copyin_32_h (a
, len
)
212 use iso_c_binding
, only
: c_int32_t
213 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
214 type (*), dimension (*) :: a
215 integer (c_int32_t
) len
218 subroutine
acc_copyin_64_h (a
, len
)
219 use iso_c_binding
, only
: c_int64_t
220 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
221 type (*), dimension (*) :: a
222 integer (c_int64_t
) len
225 subroutine
acc_copyin_array_h (a
)
226 type (*), dimension (..), contiguous :: a
230 interface acc_present_or_copyin
231 subroutine
acc_present_or_copyin_32_h (a
, len
)
232 use iso_c_binding
, only
: c_int32_t
233 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
234 type (*), dimension (*) :: a
235 integer (c_int32_t
) len
238 subroutine
acc_present_or_copyin_64_h (a
, len
)
239 use iso_c_binding
, only
: c_int64_t
240 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
241 type (*), dimension (*) :: a
242 integer (c_int64_t
) len
245 subroutine
acc_present_or_copyin_array_h (a
)
246 type (*), dimension (..), contiguous :: a
250 interface acc_pcopyin
251 procedure :: acc_present_or_copyin_32_h
252 procedure :: acc_present_or_copyin_64_h
253 procedure :: acc_present_or_copyin_array_h
257 subroutine
acc_create_32_h (a
, len
)
258 use iso_c_binding
, only
: c_int32_t
259 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
260 type (*), dimension (*) :: a
261 integer (c_int32_t
) len
264 subroutine
acc_create_64_h (a
, len
)
265 use iso_c_binding
, only
: c_int64_t
266 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
267 type (*), dimension (*) :: a
268 integer (c_int64_t
) len
271 subroutine
acc_create_array_h (a
)
272 type (*), dimension (..), contiguous :: a
276 interface acc_present_or_create
277 subroutine
acc_present_or_create_32_h (a
, len
)
278 use iso_c_binding
, only
: c_int32_t
279 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
280 type (*), dimension (*) :: a
281 integer (c_int32_t
) len
284 subroutine
acc_present_or_create_64_h (a
, len
)
285 use iso_c_binding
, only
: c_int64_t
286 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
287 type (*), dimension (*) :: a
288 integer (c_int64_t
) len
291 subroutine
acc_present_or_create_array_h (a
)
292 type (*), dimension (..), contiguous :: a
296 interface acc_pcreate
297 procedure :: acc_present_or_create_32_h
298 procedure :: acc_present_or_create_64_h
299 procedure :: acc_present_or_create_array_h
302 interface acc_copyout
303 subroutine
acc_copyout_32_h (a
, len
)
304 use iso_c_binding
, only
: c_int32_t
305 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
306 type (*), dimension (*) :: a
307 integer (c_int32_t
) len
310 subroutine
acc_copyout_64_h (a
, len
)
311 use iso_c_binding
, only
: c_int64_t
312 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
313 type (*), dimension (*) :: a
314 integer (c_int64_t
) len
317 subroutine
acc_copyout_array_h (a
)
318 type (*), dimension (..), contiguous :: a
322 interface acc_copyout_finalize
323 subroutine
acc_copyout_finalize_32_h (a
, len
)
324 use iso_c_binding
, only
: c_int32_t
325 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
326 type (*), dimension (*) :: a
327 integer (c_int32_t
) len
330 subroutine
acc_copyout_finalize_64_h (a
, len
)
331 use iso_c_binding
, only
: c_int64_t
332 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
333 type (*), dimension (*) :: a
334 integer (c_int64_t
) len
337 subroutine
acc_copyout_finalize_array_h (a
)
338 type (*), dimension (..), contiguous :: a
343 subroutine
acc_delete_32_h (a
, len
)
344 use iso_c_binding
, only
: c_int32_t
345 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
346 type (*), dimension (*) :: a
347 integer (c_int32_t
) len
350 subroutine
acc_delete_64_h (a
, len
)
351 use iso_c_binding
, only
: c_int64_t
352 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
353 type (*), dimension (*) :: a
354 integer (c_int64_t
) len
357 subroutine
acc_delete_array_h (a
)
358 type (*), dimension (..), contiguous :: a
362 interface acc_delete_finalize
363 subroutine
acc_delete_finalize_32_h (a
, len
)
364 use iso_c_binding
, only
: c_int32_t
365 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
366 type (*), dimension (*) :: a
367 integer (c_int32_t
) len
370 subroutine
acc_delete_finalize_64_h (a
, len
)
371 use iso_c_binding
, only
: c_int64_t
372 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
373 type (*), dimension (*) :: a
374 integer (c_int64_t
) len
377 subroutine
acc_delete_finalize_array_h (a
)
378 type (*), dimension (..), contiguous :: a
382 interface acc_update_device
383 subroutine
acc_update_device_32_h (a
, len
)
384 use iso_c_binding
, only
: c_int32_t
385 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
386 type (*), dimension (*) :: a
387 integer (c_int32_t
) len
390 subroutine
acc_update_device_64_h (a
, len
)
391 use iso_c_binding
, only
: c_int64_t
392 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
393 type (*), dimension (*) :: a
394 integer (c_int64_t
) len
397 subroutine
acc_update_device_array_h (a
)
398 type (*), dimension (..), contiguous :: a
402 interface acc_update_self
403 subroutine
acc_update_self_32_h (a
, len
)
404 use iso_c_binding
, only
: c_int32_t
405 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
406 type (*), dimension (*) :: a
407 integer (c_int32_t
) len
410 subroutine
acc_update_self_64_h (a
, len
)
411 use iso_c_binding
, only
: c_int64_t
412 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
413 type (*), dimension (*) :: a
414 integer (c_int64_t
) len
417 subroutine
acc_update_self_array_h (a
)
418 type (*), dimension (..), contiguous :: a
422 ! acc_map_data
: Only available in C
/C
++
423 ! acc_unmap_data
: Only available in C
/C
++
424 ! acc_deviceptr
: Only available in C
/C
++
425 ! acc_hostptr
: Only available in C
/C
++
427 interface acc_is_present
428 function
acc_is_present_32_h (a
, len
)
429 use iso_c_binding
, only
: c_int32_t
430 logical acc_is_present_32_h
431 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
432 type (*), dimension (*) :: a
433 integer (c_int32_t
) len
436 function
acc_is_present_64_h (a
, len
)
437 use iso_c_binding
, only
: c_int64_t
438 logical acc_is_present_64_h
439 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
440 type (*), dimension (*) :: a
441 integer (c_int64_t
) len
444 function
acc_is_present_array_h (a
)
445 logical acc_is_present_array_h
446 type (*), dimension (..), contiguous :: a
450 ! acc_memcpy_to_device
: Only available in C
/C
++
451 ! acc_memcpy_from_device
: Only available in C
/C
++
453 interface acc_copyin_async
454 subroutine
acc_copyin_async_32_h (a
, len
, async
)
455 use iso_c_binding
, only
: c_int32_t
456 import acc_handle_kind
457 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
458 type (*), dimension (*) :: a
459 integer (c_int32_t
) len
460 integer (acc_handle_kind
) async
463 subroutine
acc_copyin_async_64_h (a
, len
, async
)
464 use iso_c_binding
, only
: c_int64_t
465 import acc_handle_kind
466 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
467 type (*), dimension (*) :: a
468 integer (c_int64_t
) len
469 integer (acc_handle_kind
) async
472 subroutine
acc_copyin_async_array_h (a
, async_
)
473 import acc_handle_kind
474 type (*), dimension (..), contiguous :: a
475 integer (acc_handle_kind
) async_
479 interface acc_create_async
480 subroutine
acc_create_async_32_h (a
, len
, async
)
481 use iso_c_binding
, only
: c_int32_t
482 import acc_handle_kind
483 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
484 type (*), dimension (*) :: a
485 integer (c_int32_t
) len
486 integer (acc_handle_kind
) async
489 subroutine
acc_create_async_64_h (a
, len
, async
)
490 use iso_c_binding
, only
: c_int64_t
491 import acc_handle_kind
492 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
493 type (*), dimension (*) :: a
494 integer (c_int64_t
) len
495 integer (acc_handle_kind
) async
498 subroutine
acc_create_async_array_h (a
, async_
)
499 import acc_handle_kind
500 type (*), dimension (..), contiguous :: a
501 integer (acc_handle_kind
) async_
505 interface acc_copyout_async
506 subroutine
acc_copyout_async_32_h (a
, len
, async
)
507 use iso_c_binding
, only
: c_int32_t
508 import acc_handle_kind
509 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
510 type (*), dimension (*) :: a
511 integer (c_int32_t
) len
512 integer (acc_handle_kind
) async
515 subroutine
acc_copyout_async_64_h (a
, len
, async
)
516 use iso_c_binding
, only
: c_int64_t
517 import acc_handle_kind
518 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
519 type (*), dimension (*) :: a
520 integer (c_int64_t
) len
521 integer (acc_handle_kind
) async
524 subroutine
acc_copyout_async_array_h (a
, async_
)
525 import acc_handle_kind
526 type (*), dimension (..), contiguous :: a
527 integer (acc_handle_kind
) async_
531 interface acc_delete_async
532 subroutine
acc_delete_async_32_h (a
, len
, async
)
533 use iso_c_binding
, only
: c_int32_t
534 import acc_handle_kind
535 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
536 type (*), dimension (*) :: a
537 integer (c_int32_t
) len
538 integer (acc_handle_kind
) async
541 subroutine
acc_delete_async_64_h (a
, len
, async
)
542 use iso_c_binding
, only
: c_int64_t
543 import acc_handle_kind
544 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
545 type (*), dimension (*) :: a
546 integer (c_int64_t
) len
547 integer (acc_handle_kind
) async
550 subroutine
acc_delete_async_array_h (a
, async_
)
551 import acc_handle_kind
552 type (*), dimension (..), contiguous :: a
553 integer (acc_handle_kind
) async_
557 interface acc_update_device_async
558 subroutine
acc_update_device_async_32_h (a
, len
, async
)
559 use iso_c_binding
, only
: c_int32_t
560 import acc_handle_kind
561 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
562 type (*), dimension (*) :: a
563 integer (c_int32_t
) len
564 integer (acc_handle_kind
) async
567 subroutine
acc_update_device_async_64_h (a
, len
, async
)
568 use iso_c_binding
, only
: c_int64_t
569 import acc_handle_kind
570 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
571 type (*), dimension (*) :: a
572 integer (c_int64_t
) len
573 integer (acc_handle_kind
) async
576 subroutine
acc_update_device_async_array_h (a
, async_
)
577 import acc_handle_kind
578 type (*), dimension (..), contiguous :: a
579 integer (acc_handle_kind
) async_
583 interface acc_update_self_async
584 subroutine
acc_update_self_async_32_h (a
, len
, async
)
585 use iso_c_binding
, only
: c_int32_t
586 import acc_handle_kind
587 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
588 type (*), dimension (*) :: a
589 integer (c_int32_t
) len
590 integer (acc_handle_kind
) async
593 subroutine
acc_update_self_async_64_h (a
, len
, async
)
594 use iso_c_binding
, only
: c_int64_t
595 import acc_handle_kind
596 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
597 type (*), dimension (*) :: a
598 integer (c_int64_t
) len
599 integer (acc_handle_kind
) async
602 subroutine
acc_update_self_async_array_h (a
, async_
)
603 import acc_handle_kind
604 type (*), dimension (..), contiguous :: a
605 integer (acc_handle_kind
) async_