1 ! OpenACC Runtime Library Definitions
. -*- mode
: fortran
-*-
3 ! Copyright (C
) 2014-2024 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
208 type(c_ptr
) function
acc_malloc(bytes
) bind(C
)
209 use iso_c_binding
, only
: c_ptr
, c_size_t
210 integer(c_size_t
), value :: bytes
215 subroutine
acc_free(data_dev
) bind(C
)
216 use iso_c_binding
, only
: c_ptr
217 type(c_ptr
), value :: data_dev
222 subroutine
acc_copyin_32_h (a
, len
)
223 use iso_c_binding
, only
: c_int32_t
224 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
225 type (*), dimension (*) :: a
226 integer (c_int32_t
) len
229 subroutine
acc_copyin_64_h (a
, len
)
230 use iso_c_binding
, only
: c_int64_t
231 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
232 type (*), dimension (*) :: a
233 integer (c_int64_t
) len
236 subroutine
acc_copyin_array_h (a
)
237 type (*), dimension (..), contiguous :: a
241 interface acc_present_or_copyin
242 subroutine
acc_present_or_copyin_32_h (a
, len
)
243 use iso_c_binding
, only
: c_int32_t
244 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
245 type (*), dimension (*) :: a
246 integer (c_int32_t
) len
249 subroutine
acc_present_or_copyin_64_h (a
, len
)
250 use iso_c_binding
, only
: c_int64_t
251 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
252 type (*), dimension (*) :: a
253 integer (c_int64_t
) len
256 subroutine
acc_present_or_copyin_array_h (a
)
257 type (*), dimension (..), contiguous :: a
261 interface acc_pcopyin
262 procedure :: acc_present_or_copyin_32_h
263 procedure :: acc_present_or_copyin_64_h
264 procedure :: acc_present_or_copyin_array_h
268 subroutine
acc_create_32_h (a
, len
)
269 use iso_c_binding
, only
: c_int32_t
270 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
271 type (*), dimension (*) :: a
272 integer (c_int32_t
) len
275 subroutine
acc_create_64_h (a
, len
)
276 use iso_c_binding
, only
: c_int64_t
277 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
278 type (*), dimension (*) :: a
279 integer (c_int64_t
) len
282 subroutine
acc_create_array_h (a
)
283 type (*), dimension (..), contiguous :: a
287 interface acc_present_or_create
288 subroutine
acc_present_or_create_32_h (a
, len
)
289 use iso_c_binding
, only
: c_int32_t
290 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
291 type (*), dimension (*) :: a
292 integer (c_int32_t
) len
295 subroutine
acc_present_or_create_64_h (a
, len
)
296 use iso_c_binding
, only
: c_int64_t
297 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
298 type (*), dimension (*) :: a
299 integer (c_int64_t
) len
302 subroutine
acc_present_or_create_array_h (a
)
303 type (*), dimension (..), contiguous :: a
307 interface acc_pcreate
308 procedure :: acc_present_or_create_32_h
309 procedure :: acc_present_or_create_64_h
310 procedure :: acc_present_or_create_array_h
313 interface acc_copyout
314 subroutine
acc_copyout_32_h (a
, len
)
315 use iso_c_binding
, only
: c_int32_t
316 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
317 type (*), dimension (*) :: a
318 integer (c_int32_t
) len
321 subroutine
acc_copyout_64_h (a
, len
)
322 use iso_c_binding
, only
: c_int64_t
323 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
324 type (*), dimension (*) :: a
325 integer (c_int64_t
) len
328 subroutine
acc_copyout_array_h (a
)
329 type (*), dimension (..), contiguous :: a
333 interface acc_copyout_finalize
334 subroutine
acc_copyout_finalize_32_h (a
, len
)
335 use iso_c_binding
, only
: c_int32_t
336 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
337 type (*), dimension (*) :: a
338 integer (c_int32_t
) len
341 subroutine
acc_copyout_finalize_64_h (a
, len
)
342 use iso_c_binding
, only
: c_int64_t
343 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
344 type (*), dimension (*) :: a
345 integer (c_int64_t
) len
348 subroutine
acc_copyout_finalize_array_h (a
)
349 type (*), dimension (..), contiguous :: a
354 subroutine
acc_delete_32_h (a
, len
)
355 use iso_c_binding
, only
: c_int32_t
356 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
357 type (*), dimension (*) :: a
358 integer (c_int32_t
) len
361 subroutine
acc_delete_64_h (a
, len
)
362 use iso_c_binding
, only
: c_int64_t
363 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
364 type (*), dimension (*) :: a
365 integer (c_int64_t
) len
368 subroutine
acc_delete_array_h (a
)
369 type (*), dimension (..), contiguous :: a
373 interface acc_delete_finalize
374 subroutine
acc_delete_finalize_32_h (a
, len
)
375 use iso_c_binding
, only
: c_int32_t
376 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
377 type (*), dimension (*) :: a
378 integer (c_int32_t
) len
381 subroutine
acc_delete_finalize_64_h (a
, len
)
382 use iso_c_binding
, only
: c_int64_t
383 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
384 type (*), dimension (*) :: a
385 integer (c_int64_t
) len
388 subroutine
acc_delete_finalize_array_h (a
)
389 type (*), dimension (..), contiguous :: a
393 interface acc_update_device
394 subroutine
acc_update_device_32_h (a
, len
)
395 use iso_c_binding
, only
: c_int32_t
396 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
397 type (*), dimension (*) :: a
398 integer (c_int32_t
) len
401 subroutine
acc_update_device_64_h (a
, len
)
402 use iso_c_binding
, only
: c_int64_t
403 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
404 type (*), dimension (*) :: a
405 integer (c_int64_t
) len
408 subroutine
acc_update_device_array_h (a
)
409 type (*), dimension (..), contiguous :: a
413 interface acc_update_self
414 subroutine
acc_update_self_32_h (a
, len
)
415 use iso_c_binding
, only
: c_int32_t
416 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
417 type (*), dimension (*) :: a
418 integer (c_int32_t
) len
421 subroutine
acc_update_self_64_h (a
, len
)
422 use iso_c_binding
, only
: c_int64_t
423 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
424 type (*), dimension (*) :: a
425 integer (c_int64_t
) len
428 subroutine
acc_update_self_array_h (a
)
429 type (*), dimension (..), contiguous :: a
434 subroutine
acc_map_data(data_arg
, data_dev
, bytes
) bind(C
)
435 use iso_c_binding
, only
: c_ptr
, c_size_t
436 type(*), dimension(*) :: data_arg
437 type(c_ptr
), value :: data_dev
438 integer(c_size_t
), value :: bytes
443 subroutine
acc_unmap_data(data_arg
) bind(C
)
444 type(*), dimension(*) :: data_arg
449 type(c_ptr
) function
acc_deviceptr(data_arg
) bind(C
)
450 use iso_c_binding
, only
: c_ptr
451 type(*), dimension(*) :: data_arg
456 type(c_ptr
) function
acc_hostptr(data_dev
) bind(C
)
457 use iso_c_binding
, only
: c_ptr
458 type(c_ptr
), value :: data_dev
462 interface acc_is_present
463 function
acc_is_present_32_h (a
, len
)
464 use iso_c_binding
, only
: c_int32_t
465 logical acc_is_present_32_h
466 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
467 type (*), dimension (*) :: a
468 integer (c_int32_t
) len
471 function
acc_is_present_64_h (a
, len
)
472 use iso_c_binding
, only
: c_int64_t
473 logical acc_is_present_64_h
474 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
475 type (*), dimension (*) :: a
476 integer (c_int64_t
) len
479 function
acc_is_present_array_h (a
)
480 logical acc_is_present_array_h
481 type (*), dimension (..), contiguous :: a
486 subroutine
acc_memcpy_to_device(data_dev_dest
, data_host_src
, &
488 use iso_c_binding
, only
: c_ptr
, c_size_t
489 type(c_ptr
), value :: data_dev_dest
490 type(*),dimension(*) :: data_host_src
491 integer(c_size_t
), value :: bytes
496 subroutine
acc_memcpy_to_device_async(data_dev_dest
, &
497 & data_host_src
, bytes
, &
499 use iso_c_binding
, only
: c_ptr
, c_size_t
500 import :: acc_handle_kind
501 type(c_ptr
), value :: data_dev_dest
502 type(*),dimension(*) :: data_host_src
503 integer(c_size_t
), value :: bytes
504 integer(acc_handle_kind
), value :: async_arg
509 subroutine
acc_memcpy_from_device(data_host_dest
, &
510 & data_dev_src
, bytes
) bind(C
)
511 use iso_c_binding
, only
: c_ptr
, c_size_t
512 type(*),dimension(*) :: data_host_dest
513 type(c_ptr
), value :: data_dev_src
514 integer(c_size_t
), value :: bytes
519 subroutine
acc_memcpy_from_device_async(data_host_dest
, &
520 & data_dev_src
, bytes
, &
522 use iso_c_binding
, only
: c_ptr
, c_size_t
523 import :: acc_handle_kind
524 type(*),dimension(*) :: data_host_dest
525 type(c_ptr
), value :: data_dev_src
526 integer(c_size_t
), value :: bytes
527 integer(acc_handle_kind
), value :: async_arg
531 interface acc_copyin_async
532 subroutine
acc_copyin_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_copyin_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_copyin_async_array_h (a
, async_
)
551 import acc_handle_kind
552 type (*), dimension (..), contiguous :: a
553 integer (acc_handle_kind
) async_
557 interface acc_create_async
558 subroutine
acc_create_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_create_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_create_async_array_h (a
, async_
)
577 import acc_handle_kind
578 type (*), dimension (..), contiguous :: a
579 integer (acc_handle_kind
) async_
583 interface acc_copyout_async
584 subroutine
acc_copyout_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_copyout_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_copyout_async_array_h (a
, async_
)
603 import acc_handle_kind
604 type (*), dimension (..), contiguous :: a
605 integer (acc_handle_kind
) async_
609 interface acc_delete_async
610 subroutine
acc_delete_async_32_h (a
, len
, async
)
611 use iso_c_binding
, only
: c_int32_t
612 import acc_handle_kind
613 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
614 type (*), dimension (*) :: a
615 integer (c_int32_t
) len
616 integer (acc_handle_kind
) async
619 subroutine
acc_delete_async_64_h (a
, len
, async
)
620 use iso_c_binding
, only
: c_int64_t
621 import acc_handle_kind
622 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
623 type (*), dimension (*) :: a
624 integer (c_int64_t
) len
625 integer (acc_handle_kind
) async
628 subroutine
acc_delete_async_array_h (a
, async_
)
629 import acc_handle_kind
630 type (*), dimension (..), contiguous :: a
631 integer (acc_handle_kind
) async_
635 interface acc_update_device_async
636 subroutine
acc_update_device_async_32_h (a
, len
, async
)
637 use iso_c_binding
, only
: c_int32_t
638 import acc_handle_kind
639 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
640 type (*), dimension (*) :: a
641 integer (c_int32_t
) len
642 integer (acc_handle_kind
) async
645 subroutine
acc_update_device_async_64_h (a
, len
, async
)
646 use iso_c_binding
, only
: c_int64_t
647 import acc_handle_kind
648 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
649 type (*), dimension (*) :: a
650 integer (c_int64_t
) len
651 integer (acc_handle_kind
) async
654 subroutine
acc_update_device_async_array_h (a
, async_
)
655 import acc_handle_kind
656 type (*), dimension (..), contiguous :: a
657 integer (acc_handle_kind
) async_
661 interface acc_update_self_async
662 subroutine
acc_update_self_async_32_h (a
, len
, async
)
663 use iso_c_binding
, only
: c_int32_t
664 import acc_handle_kind
665 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
666 type (*), dimension (*) :: a
667 integer (c_int32_t
) len
668 integer (acc_handle_kind
) async
671 subroutine
acc_update_self_async_64_h (a
, len
, async
)
672 use iso_c_binding
, only
: c_int64_t
673 import acc_handle_kind
674 !GCC$ ATTRIBUTES
NO_ARG_CHECK :: a
675 type (*), dimension (*) :: a
676 integer (c_int64_t
) len
677 integer (acc_handle_kind
) async
680 subroutine
acc_update_self_async_array_h (a
, async_
)
681 import acc_handle_kind
682 type (*), dimension (..), contiguous :: a
683 integer (acc_handle_kind
) async_