openacc_lib.h 18.2 KB
Newer Older
1 2
!  OpenACC Runtime Library Definitions.			-*- mode: fortran -*-

3
!  Copyright (C) 2014-2019 Free Software Foundation, Inc.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

!  Contributed by Tobias Burnus <burnus@net-b.de>
!              and Mentor Embedded.

!  This file is part of the GNU Offloading and Multi Processing Library
!  (libgomp).

!  Libgomp is free software; you can redistribute it and/or modify it
!  under the terms of the GNU General Public License as published by
!  the Free Software Foundation; either version 3, or (at your option)
!  any later version.

!  Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
!  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
!  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
!  more details.

!  Under Section 7 of GPL version 3, you are granted additional
!  permissions described in the GCC Runtime Library Exception, version
!  3.1, as published by the Free Software Foundation.

!  You should have received a copy of the GNU General Public License and
!  a copy of the GCC Runtime Library Exception along with this program;
!  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
!  <http://www.gnu.org/licenses/>.

! NOTE: Due to the use of dimension (..), the code only works when compiled
! with -std=f2008ts/gnu/legacy but not with other standard settings.
! Alternatively, the user can use the module version, which permits
! compilation with -std=f95.

      integer, parameter :: acc_device_kind = 4

!     Keep in sync with include/gomp-constants.h.
      integer (acc_device_kind), parameter :: acc_device_none = 0
      integer (acc_device_kind), parameter :: acc_device_default = 1
      integer (acc_device_kind), parameter :: acc_device_host = 2
41 42
!     integer (acc_device_kind), parameter :: acc_device_host_nonshm = 3
!     removed.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
      integer (acc_device_kind), parameter :: acc_device_not_host = 4
      integer (acc_device_kind), parameter :: acc_device_nvidia = 5

      integer, parameter :: acc_handle_kind = 4

!     Keep in sync with include/gomp-constants.h.
      integer (acc_handle_kind), parameter :: acc_async_noval = -1
      integer (acc_handle_kind), parameter :: acc_async_sync = -2

      integer, parameter :: openacc_version = 201306

      interface acc_get_num_devices
        function acc_get_num_devices_h (d)
          import acc_device_kind
          integer acc_get_num_devices_h
          integer (acc_device_kind) d
        end function
      end interface

      interface acc_set_device_type
        subroutine acc_set_device_type_h (d)
          import acc_device_kind
          integer (acc_device_kind) d
        end subroutine
      end interface

      interface acc_get_device_type
        function acc_get_device_type_h ()
          import acc_device_kind
          integer (acc_device_kind) acc_get_device_type_h
        end function
      end interface

      interface acc_set_device_num
        subroutine acc_set_device_num_h (n, d)
          import acc_device_kind
          integer n
          integer (acc_device_kind) d
        end subroutine
      end interface

      interface acc_get_device_num
        function acc_get_device_num_h (d)
          import acc_device_kind
          integer acc_get_device_num_h
          integer (acc_device_kind) d
        end function
      end interface

      interface acc_async_test
        function acc_async_test_h (a)
          logical acc_async_test_h
          integer a
        end function
      end interface

      interface acc_async_test_all
        function acc_async_test_all_h ()
          logical acc_async_test_all_h
        end function
      end interface

      interface acc_wait
        subroutine acc_wait_h (a)
          integer a
        end subroutine
      end interface

111 112 113 114 115
!     acc_async_wait is an OpenACC 1.0 compatibility name for acc_wait.
      interface acc_async_wait
        procedure :: acc_wait_h
      end interface

116 117 118 119 120 121 122 123 124 125 126
      interface acc_wait_async
        subroutine acc_wait_async_h (a1, a2)
          integer a1, a2
        end subroutine
      end interface

      interface acc_wait_all
        subroutine acc_wait_all_h ()
        end subroutine
      end interface

127 128 129 130 131 132
!     acc_async_wait_all is an OpenACC 1.0 compatibility name for
!     acc_wait_all.
      interface acc_async_wait_all
        procedure :: acc_wait_all_h
      end interface

133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
      interface acc_wait_all_async
        subroutine acc_wait_all_async_h (a)
          integer a
        end subroutine
      end interface

      interface acc_init
        subroutine acc_init_h (devicetype)
          import acc_device_kind
          integer (acc_device_kind) devicetype
        end subroutine
      end interface

      interface acc_shutdown
        subroutine acc_shutdown_h (devicetype)
          import acc_device_kind
          integer (acc_device_kind) devicetype
        end subroutine
      end interface

      interface acc_on_device
        function acc_on_device_h (devicetype)
          import acc_device_kind
          logical acc_on_device_h
          integer (acc_device_kind) devicetype
        end function
      end interface

      ! acc_malloc: Only available in C/C++
      ! acc_free: Only available in C/C++

      interface acc_copyin
        subroutine acc_copyin_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end subroutine

        subroutine acc_copyin_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end subroutine

        subroutine acc_copyin_array_h (a)
          type (*), dimension (..), contiguous :: a
          end subroutine
      end interface

      interface acc_present_or_copyin
        subroutine acc_present_or_copyin_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end subroutine

        subroutine acc_present_or_copyin_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end subroutine

        subroutine acc_present_or_copyin_array_h (a)
          type (*), dimension (..), contiguous :: a
          end subroutine
      end interface

      interface acc_pcopyin
205 206 207
        procedure :: acc_present_or_copyin_32_h
        procedure :: acc_present_or_copyin_64_h
        procedure :: acc_present_or_copyin_array_h
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
      end interface

      interface acc_create
        subroutine acc_create_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end subroutine

        subroutine acc_create_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end subroutine

        subroutine acc_create_array_h (a)
          type (*), dimension (..), contiguous :: a
          end subroutine
      end interface

      interface acc_present_or_create
        subroutine acc_present_or_create_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end subroutine

        subroutine acc_present_or_create_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end subroutine

        subroutine acc_present_or_create_array_h (a)
          type (*), dimension (..), contiguous :: a
          end subroutine
      end interface

      interface acc_pcreate
251 252 253
        procedure :: acc_present_or_create_32_h
        procedure :: acc_present_or_create_64_h
        procedure :: acc_present_or_create_array_h
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
      end interface

      interface acc_copyout
        subroutine acc_copyout_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end subroutine

        subroutine acc_copyout_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end subroutine

        subroutine acc_copyout_array_h (a)
          type (*), dimension (..), contiguous :: a
        end subroutine
      end interface

276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
      interface acc_copyout_finalize
        subroutine acc_copyout_finalize_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end subroutine

        subroutine acc_copyout_finalize_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end subroutine

        subroutine acc_copyout_finalize_array_h (a)
          type (*), dimension (..), contiguous :: a
        end subroutine
      end interface

296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
      interface acc_delete
        subroutine acc_delete_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end subroutine

        subroutine acc_delete_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end subroutine

        subroutine acc_delete_array_h (a)
          type (*), dimension (..), contiguous :: a
        end subroutine
      end interface

316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
      interface acc_delete_finalize
        subroutine acc_delete_finalize_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end subroutine

        subroutine acc_delete_finalize_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end subroutine

        subroutine acc_delete_finalize_array_h (a)
          type (*), dimension (..), contiguous :: a
        end subroutine
      end interface

336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
      interface acc_update_device
        subroutine acc_update_device_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end subroutine

        subroutine acc_update_device_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end subroutine

        subroutine acc_update_device_array_h (a)
          type (*), dimension (..), contiguous :: a
        end subroutine
      end interface

      interface acc_update_self
        subroutine acc_update_self_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end subroutine

        subroutine acc_update_self_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end subroutine

        subroutine acc_update_self_array_h (a)
          type (*), dimension (..), contiguous :: a
        end subroutine
      end interface

      ! acc_map_data: Only available in C/C++
      ! acc_unmap_data: Only available in C/C++
      ! acc_deviceptr: Only available in C/C++
379
      ! acc_hostptr: Only available in C/C++
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405

      interface acc_is_present
        function acc_is_present_32_h (a, len)
          use iso_c_binding, only: c_int32_t
          logical acc_is_present_32_h
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
        end function

        function acc_is_present_64_h (a, len)
          use iso_c_binding, only: c_int64_t
          logical acc_is_present_64_h
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
        end function

        function acc_is_present_array_h (a)
          logical acc_is_present_array_h
          type (*), dimension (..), contiguous :: a
        end function
      end interface

      ! acc_memcpy_to_device: Only available in C/C++
      ! acc_memcpy_from_device: Only available in C/C++
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561

      interface acc_copyin_async
        subroutine acc_copyin_async_32_h (a, len, async)
          use iso_c_binding, only: c_int32_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_copyin_async_64_h (a, len, async)
          use iso_c_binding, only: c_int64_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_copyin_async_array_h (a, async_)
          import acc_handle_kind
          type (*), dimension (..), contiguous :: a
          integer (acc_handle_kind) async_
        end subroutine
      end interface

      interface acc_create_async
        subroutine acc_create_async_32_h (a, len, async)
          use iso_c_binding, only: c_int32_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_create_async_64_h (a, len, async)
          use iso_c_binding, only: c_int64_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_create_async_array_h (a, async_)
          import acc_handle_kind
          type (*), dimension (..), contiguous :: a
          integer (acc_handle_kind) async_
        end subroutine
      end interface

      interface acc_copyout_async
        subroutine acc_copyout_async_32_h (a, len, async)
          use iso_c_binding, only: c_int32_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_copyout_async_64_h (a, len, async)
          use iso_c_binding, only: c_int64_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_copyout_async_array_h (a, async_)
          import acc_handle_kind
          type (*), dimension (..), contiguous :: a
          integer (acc_handle_kind) async_
        end subroutine
      end interface

      interface acc_delete_async
        subroutine acc_delete_async_32_h (a, len, async)
          use iso_c_binding, only: c_int32_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_delete_async_64_h (a, len, async)
          use iso_c_binding, only: c_int64_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_delete_async_array_h (a, async_)
          import acc_handle_kind
          type (*), dimension (..), contiguous :: a
          integer (acc_handle_kind) async_
        end subroutine
      end interface

      interface acc_update_device_async
        subroutine acc_update_device_async_32_h (a, len, async)
          use iso_c_binding, only: c_int32_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_update_device_async_64_h (a, len, async)
          use iso_c_binding, only: c_int64_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_update_device_async_array_h (a, async_)
          import acc_handle_kind
          type (*), dimension (..), contiguous :: a
          integer (acc_handle_kind) async_
        end subroutine
      end interface

      interface acc_update_self_async
        subroutine acc_update_self_async_32_h (a, len, async)
          use iso_c_binding, only: c_int32_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int32_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_update_self_async_64_h (a, len, async)
          use iso_c_binding, only: c_int64_t
          import acc_handle_kind
          !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
          type (*), dimension (*) :: a
          integer (c_int64_t) len
          integer (acc_handle_kind) async
        end subroutine

        subroutine acc_update_self_async_array_h (a, async_)
          import acc_handle_kind
          type (*), dimension (..), contiguous :: a
          integer (acc_handle_kind) async_
        end subroutine
      end interface