1 ! OpenACC Runtime Library Definitions. -*- mode: fortran -*- 2 3 ! Copyright (C) 2014-2020 Free Software Foundation, Inc. 4 5 ! Contributed by Tobias Burnus <burnus@net-b.de> 6 ! and Mentor Embedded. 7 8 ! This file is part of the GNU Offloading and Multi Processing Library 9 ! (libgomp). 10 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) 14 ! any later version. 15 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 19 ! more details. 20 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. 24 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/>. 29 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. 34 35 ! Keep in sync with openacc.f90 and config/accel/openacc.f90. 36 37 integer, parameter :: acc_device_kind = 4 38 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 45 ! removed. 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 49 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 55 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') 66 67 integer, parameter :: acc_handle_kind = 4 68 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 72 73 integer, parameter :: openacc_version = 201711 74 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 80 end function 81 end interface 82 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 87 end subroutine 88 end interface 89 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 94 end function 95 end interface 96 97 interface acc_set_device_num 98 subroutine acc_set_device_num_h (devicenum, devicetype) 99 import acc_device_kind 100 integer devicenum 101 integer (acc_device_kind) devicetype 102 end subroutine 103 end interface 104 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 110 end function 111 end interface 112 113 interface acc_get_property 114 function acc_get_property_h (devicenum, devicetype, & 115 & property) 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 123 end function 124 end interface 125 126 interface acc_get_property_string 127 subroutine acc_get_property_string_h (devicenum, devicetype, & 128 & property, string) 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 135 end subroutine 136 end interface 137 138 interface acc_async_test 139 function acc_async_test_h (arg) 140 logical acc_async_test_h 141 integer arg 142 end function 143 end interface 144 145 interface acc_async_test_all 146 function acc_async_test_all_h () 147 logical acc_async_test_all_h 148 end function 149 end interface 150 151 interface acc_wait 152 subroutine acc_wait_h (arg) 153 integer arg 154 end subroutine 155 end interface 156 157 ! acc_async_wait is an OpenACC 1.0 compatibility name for acc_wait. 158 interface acc_async_wait 159 procedure :: acc_wait_h 160 end interface 161 162 interface acc_wait_async 163 subroutine acc_wait_async_h (arg, async) 164 integer arg, async 165 end subroutine 166 end interface 167 168 interface acc_wait_all 169 subroutine acc_wait_all_h () 170 end subroutine 171 end interface 172 173 ! acc_async_wait_all is an OpenACC 1.0 compatibility name for 174 ! acc_wait_all. 175 interface acc_async_wait_all 176 procedure :: acc_wait_all_h 177 end interface 178 179 interface acc_wait_all_async 180 subroutine acc_wait_all_async_h (async) 181 integer async 182 end subroutine 183 end interface 184 185 interface acc_init 186 subroutine acc_init_h (devicetype) 187 import acc_device_kind 188 integer (acc_device_kind) devicetype 189 end subroutine 190 end interface 191 192 interface acc_shutdown 193 subroutine acc_shutdown_h (devicetype) 194 import acc_device_kind 195 integer (acc_device_kind) devicetype 196 end subroutine 197 end interface 198 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 204 end function 205 end interface 206 207 ! acc_malloc: Only available in C/C++ 208 ! acc_free: Only available in C/C++ 209 210 interface acc_copyin 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 216 end subroutine 217 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 223 end subroutine 224 225 subroutine acc_copyin_array_h (a) 226 type (*), dimension (..), contiguous :: a 227 end subroutine 228 end interface 229 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 236 end subroutine 237 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 243 end subroutine 244 245 subroutine acc_present_or_copyin_array_h (a) 246 type (*), dimension (..), contiguous :: a 247 end subroutine 248 end interface 249 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 254 end interface 255 256 interface acc_create 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 262 end subroutine 263 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 269 end subroutine 270 271 subroutine acc_create_array_h (a) 272 type (*), dimension (..), contiguous :: a 273 end subroutine 274 end interface 275 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 282 end subroutine 283 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 289 end subroutine 290 291 subroutine acc_present_or_create_array_h (a) 292 type (*), dimension (..), contiguous :: a 293 end subroutine 294 end interface 295 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 300 end interface 301 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 308 end subroutine 309 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 315 end subroutine 316 317 subroutine acc_copyout_array_h (a) 318 type (*), dimension (..), contiguous :: a 319 end subroutine 320 end interface 321 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 328 end subroutine 329 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 335 end subroutine 336 337 subroutine acc_copyout_finalize_array_h (a) 338 type (*), dimension (..), contiguous :: a 339 end subroutine 340 end interface 341 342 interface acc_delete 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 348 end subroutine 349 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 355 end subroutine 356 357 subroutine acc_delete_array_h (a) 358 type (*), dimension (..), contiguous :: a 359 end subroutine 360 end interface 361 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 368 end subroutine 369 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 375 end subroutine 376 377 subroutine acc_delete_finalize_array_h (a) 378 type (*), dimension (..), contiguous :: a 379 end subroutine 380 end interface 381 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 388 end subroutine 389 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 395 end subroutine 396 397 subroutine acc_update_device_array_h (a) 398 type (*), dimension (..), contiguous :: a 399 end subroutine 400 end interface 401 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 408 end subroutine 409 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 415 end subroutine 416 417 subroutine acc_update_self_array_h (a) 418 type (*), dimension (..), contiguous :: a 419 end subroutine 420 end interface 421 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++ 426 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 434 end function 435 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 442 end function 443 444 function acc_is_present_array_h (a) 445 logical acc_is_present_array_h 446 type (*), dimension (..), contiguous :: a 447 end function 448 end interface 449 450 ! acc_memcpy_to_device: Only available in C/C++ 451 ! acc_memcpy_from_device: Only available in C/C++ 452 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 461 end subroutine 462 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 470 end subroutine 471 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_ 476 end subroutine 477 end interface 478 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 487 end subroutine 488 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 496 end subroutine 497 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_ 502 end subroutine 503 end interface 504 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 513 end subroutine 514 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 522 end subroutine 523 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_ 528 end subroutine 529 end interface 530 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 539 end subroutine 540 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 548 end subroutine 549 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_ 554 end subroutine 555 end interface 556 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 565 end subroutine 566 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 574 end subroutine 575 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_ 580 end subroutine 581 end interface 582 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 591 end subroutine 592 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 600 end subroutine 601 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_ 606 end subroutine 607 end interface 608