1 ! OpenACC Runtime Library Definitions. -*- mode: fortran -*- 2 3 ! Copyright (C) 2014-2019 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 integer, parameter :: acc_device_kind = 4 36 37 ! Keep in sync with include/gomp-constants.h. 38 integer (acc_device_kind), parameter :: acc_device_none = 0 39 integer (acc_device_kind), parameter :: acc_device_default = 1 40 integer (acc_device_kind), parameter :: acc_device_host = 2 41 ! integer (acc_device_kind), parameter :: acc_device_host_nonshm = 3 42 ! removed. 43 integer (acc_device_kind), parameter :: acc_device_not_host = 4 44 integer (acc_device_kind), parameter :: acc_device_nvidia = 5 45 46 integer, parameter :: acc_handle_kind = 4 47 48 ! Keep in sync with include/gomp-constants.h. 49 integer (acc_handle_kind), parameter :: acc_async_noval = -1 50 integer (acc_handle_kind), parameter :: acc_async_sync = -2 51 52 integer, parameter :: openacc_version = 201306 53 54 interface acc_get_num_devices 55 function acc_get_num_devices_h (d) 56 import acc_device_kind 57 integer acc_get_num_devices_h 58 integer (acc_device_kind) d 59 end function 60 end interface 61 62 interface acc_set_device_type 63 subroutine acc_set_device_type_h (d) 64 import acc_device_kind 65 integer (acc_device_kind) d 66 end subroutine 67 end interface 68 69 interface acc_get_device_type 70 function acc_get_device_type_h () 71 import acc_device_kind 72 integer (acc_device_kind) acc_get_device_type_h 73 end function 74 end interface 75 76 interface acc_set_device_num 77 subroutine acc_set_device_num_h (n, d) 78 import acc_device_kind 79 integer n 80 integer (acc_device_kind) d 81 end subroutine 82 end interface 83 84 interface acc_get_device_num 85 function acc_get_device_num_h (d) 86 import acc_device_kind 87 integer acc_get_device_num_h 88 integer (acc_device_kind) d 89 end function 90 end interface 91 92 interface acc_async_test 93 function acc_async_test_h (a) 94 logical acc_async_test_h 95 integer a 96 end function 97 end interface 98 99 interface acc_async_test_all 100 function acc_async_test_all_h () 101 logical acc_async_test_all_h 102 end function 103 end interface 104 105 interface acc_wait 106 subroutine acc_wait_h (a) 107 integer a 108 end subroutine 109 end interface 110 111 ! acc_async_wait is an OpenACC 1.0 compatibility name for acc_wait. 112 interface acc_async_wait 113 procedure :: acc_wait_h 114 end interface 115 116 interface acc_wait_async 117 subroutine acc_wait_async_h (a1, a2) 118 integer a1, a2 119 end subroutine 120 end interface 121 122 interface acc_wait_all 123 subroutine acc_wait_all_h () 124 end subroutine 125 end interface 126 127 ! acc_async_wait_all is an OpenACC 1.0 compatibility name for 128 ! acc_wait_all. 129 interface acc_async_wait_all 130 procedure :: acc_wait_all_h 131 end interface 132 133 interface acc_wait_all_async 134 subroutine acc_wait_all_async_h (a) 135 integer a 136 end subroutine 137 end interface 138 139 interface acc_init 140 subroutine acc_init_h (devicetype) 141 import acc_device_kind 142 integer (acc_device_kind) devicetype 143 end subroutine 144 end interface 145 146 interface acc_shutdown 147 subroutine acc_shutdown_h (devicetype) 148 import acc_device_kind 149 integer (acc_device_kind) devicetype 150 end subroutine 151 end interface 152 153 interface acc_on_device 154 function acc_on_device_h (devicetype) 155 import acc_device_kind 156 logical acc_on_device_h 157 integer (acc_device_kind) devicetype 158 end function 159 end interface 160 161 ! acc_malloc: Only available in C/C++ 162 ! acc_free: Only available in C/C++ 163 164 interface acc_copyin 165 subroutine acc_copyin_32_h (a, len) 166 use iso_c_binding, only: c_int32_t 167 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 168 type (*), dimension (*) :: a 169 integer (c_int32_t) len 170 end subroutine 171 172 subroutine acc_copyin_64_h (a, len) 173 use iso_c_binding, only: c_int64_t 174 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 175 type (*), dimension (*) :: a 176 integer (c_int64_t) len 177 end subroutine 178 179 subroutine acc_copyin_array_h (a) 180 type (*), dimension (..), contiguous :: a 181 end subroutine 182 end interface 183 184 interface acc_present_or_copyin 185 subroutine acc_present_or_copyin_32_h (a, len) 186 use iso_c_binding, only: c_int32_t 187 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 188 type (*), dimension (*) :: a 189 integer (c_int32_t) len 190 end subroutine 191 192 subroutine acc_present_or_copyin_64_h (a, len) 193 use iso_c_binding, only: c_int64_t 194 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 195 type (*), dimension (*) :: a 196 integer (c_int64_t) len 197 end subroutine 198 199 subroutine acc_present_or_copyin_array_h (a) 200 type (*), dimension (..), contiguous :: a 201 end subroutine 202 end interface 203 204 interface acc_pcopyin 205 procedure :: acc_present_or_copyin_32_h 206 procedure :: acc_present_or_copyin_64_h 207 procedure :: acc_present_or_copyin_array_h 208 end interface 209 210 interface acc_create 211 subroutine acc_create_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_create_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_create_array_h (a) 226 type (*), dimension (..), contiguous :: a 227 end subroutine 228 end interface 229 230 interface acc_present_or_create 231 subroutine acc_present_or_create_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_create_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_create_array_h (a) 246 type (*), dimension (..), contiguous :: a 247 end subroutine 248 end interface 249 250 interface acc_pcreate 251 procedure :: acc_present_or_create_32_h 252 procedure :: acc_present_or_create_64_h 253 procedure :: acc_present_or_create_array_h 254 end interface 255 256 interface acc_copyout 257 subroutine acc_copyout_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_copyout_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_copyout_array_h (a) 272 type (*), dimension (..), contiguous :: a 273 end subroutine 274 end interface 275 276 interface acc_copyout_finalize 277 subroutine acc_copyout_finalize_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_copyout_finalize_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_copyout_finalize_array_h (a) 292 type (*), dimension (..), contiguous :: a 293 end subroutine 294 end interface 295 296 interface acc_delete 297 subroutine acc_delete_32_h (a, len) 298 use iso_c_binding, only: c_int32_t 299 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 300 type (*), dimension (*) :: a 301 integer (c_int32_t) len 302 end subroutine 303 304 subroutine acc_delete_64_h (a, len) 305 use iso_c_binding, only: c_int64_t 306 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 307 type (*), dimension (*) :: a 308 integer (c_int64_t) len 309 end subroutine 310 311 subroutine acc_delete_array_h (a) 312 type (*), dimension (..), contiguous :: a 313 end subroutine 314 end interface 315 316 interface acc_delete_finalize 317 subroutine acc_delete_finalize_32_h (a, len) 318 use iso_c_binding, only: c_int32_t 319 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 320 type (*), dimension (*) :: a 321 integer (c_int32_t) len 322 end subroutine 323 324 subroutine acc_delete_finalize_64_h (a, len) 325 use iso_c_binding, only: c_int64_t 326 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 327 type (*), dimension (*) :: a 328 integer (c_int64_t) len 329 end subroutine 330 331 subroutine acc_delete_finalize_array_h (a) 332 type (*), dimension (..), contiguous :: a 333 end subroutine 334 end interface 335 336 interface acc_update_device 337 subroutine acc_update_device_32_h (a, len) 338 use iso_c_binding, only: c_int32_t 339 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 340 type (*), dimension (*) :: a 341 integer (c_int32_t) len 342 end subroutine 343 344 subroutine acc_update_device_64_h (a, len) 345 use iso_c_binding, only: c_int64_t 346 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 347 type (*), dimension (*) :: a 348 integer (c_int64_t) len 349 end subroutine 350 351 subroutine acc_update_device_array_h (a) 352 type (*), dimension (..), contiguous :: a 353 end subroutine 354 end interface 355 356 interface acc_update_self 357 subroutine acc_update_self_32_h (a, len) 358 use iso_c_binding, only: c_int32_t 359 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 360 type (*), dimension (*) :: a 361 integer (c_int32_t) len 362 end subroutine 363 364 subroutine acc_update_self_64_h (a, len) 365 use iso_c_binding, only: c_int64_t 366 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 367 type (*), dimension (*) :: a 368 integer (c_int64_t) len 369 end subroutine 370 371 subroutine acc_update_self_array_h (a) 372 type (*), dimension (..), contiguous :: a 373 end subroutine 374 end interface 375 376 ! acc_map_data: Only available in C/C++ 377 ! acc_unmap_data: Only available in C/C++ 378 ! acc_deviceptr: Only available in C/C++ 379 ! acc_hostptr: Only available in C/C++ 380 381 interface acc_is_present 382 function acc_is_present_32_h (a, len) 383 use iso_c_binding, only: c_int32_t 384 logical acc_is_present_32_h 385 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 386 type (*), dimension (*) :: a 387 integer (c_int32_t) len 388 end function 389 390 function acc_is_present_64_h (a, len) 391 use iso_c_binding, only: c_int64_t 392 logical acc_is_present_64_h 393 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 394 type (*), dimension (*) :: a 395 integer (c_int64_t) len 396 end function 397 398 function acc_is_present_array_h (a) 399 logical acc_is_present_array_h 400 type (*), dimension (..), contiguous :: a 401 end function 402 end interface 403 404 ! acc_memcpy_to_device: Only available in C/C++ 405 ! acc_memcpy_from_device: Only available in C/C++ 406 407 interface acc_copyin_async 408 subroutine acc_copyin_async_32_h (a, len, async) 409 use iso_c_binding, only: c_int32_t 410 import acc_handle_kind 411 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 412 type (*), dimension (*) :: a 413 integer (c_int32_t) len 414 integer (acc_handle_kind) async 415 end subroutine 416 417 subroutine acc_copyin_async_64_h (a, len, async) 418 use iso_c_binding, only: c_int64_t 419 import acc_handle_kind 420 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 421 type (*), dimension (*) :: a 422 integer (c_int64_t) len 423 integer (acc_handle_kind) async 424 end subroutine 425 426 subroutine acc_copyin_async_array_h (a, async_) 427 import acc_handle_kind 428 type (*), dimension (..), contiguous :: a 429 integer (acc_handle_kind) async_ 430 end subroutine 431 end interface 432 433 interface acc_create_async 434 subroutine acc_create_async_32_h (a, len, async) 435 use iso_c_binding, only: c_int32_t 436 import acc_handle_kind 437 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 438 type (*), dimension (*) :: a 439 integer (c_int32_t) len 440 integer (acc_handle_kind) async 441 end subroutine 442 443 subroutine acc_create_async_64_h (a, len, async) 444 use iso_c_binding, only: c_int64_t 445 import acc_handle_kind 446 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 447 type (*), dimension (*) :: a 448 integer (c_int64_t) len 449 integer (acc_handle_kind) async 450 end subroutine 451 452 subroutine acc_create_async_array_h (a, async_) 453 import acc_handle_kind 454 type (*), dimension (..), contiguous :: a 455 integer (acc_handle_kind) async_ 456 end subroutine 457 end interface 458 459 interface acc_copyout_async 460 subroutine acc_copyout_async_32_h (a, len, async) 461 use iso_c_binding, only: c_int32_t 462 import acc_handle_kind 463 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 464 type (*), dimension (*) :: a 465 integer (c_int32_t) len 466 integer (acc_handle_kind) async 467 end subroutine 468 469 subroutine acc_copyout_async_64_h (a, len, async) 470 use iso_c_binding, only: c_int64_t 471 import acc_handle_kind 472 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 473 type (*), dimension (*) :: a 474 integer (c_int64_t) len 475 integer (acc_handle_kind) async 476 end subroutine 477 478 subroutine acc_copyout_async_array_h (a, async_) 479 import acc_handle_kind 480 type (*), dimension (..), contiguous :: a 481 integer (acc_handle_kind) async_ 482 end subroutine 483 end interface 484 485 interface acc_delete_async 486 subroutine acc_delete_async_32_h (a, len, async) 487 use iso_c_binding, only: c_int32_t 488 import acc_handle_kind 489 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 490 type (*), dimension (*) :: a 491 integer (c_int32_t) len 492 integer (acc_handle_kind) async 493 end subroutine 494 495 subroutine acc_delete_async_64_h (a, len, async) 496 use iso_c_binding, only: c_int64_t 497 import acc_handle_kind 498 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 499 type (*), dimension (*) :: a 500 integer (c_int64_t) len 501 integer (acc_handle_kind) async 502 end subroutine 503 504 subroutine acc_delete_async_array_h (a, async_) 505 import acc_handle_kind 506 type (*), dimension (..), contiguous :: a 507 integer (acc_handle_kind) async_ 508 end subroutine 509 end interface 510 511 interface acc_update_device_async 512 subroutine acc_update_device_async_32_h (a, len, async) 513 use iso_c_binding, only: c_int32_t 514 import acc_handle_kind 515 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 516 type (*), dimension (*) :: a 517 integer (c_int32_t) len 518 integer (acc_handle_kind) async 519 end subroutine 520 521 subroutine acc_update_device_async_64_h (a, len, async) 522 use iso_c_binding, only: c_int64_t 523 import acc_handle_kind 524 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 525 type (*), dimension (*) :: a 526 integer (c_int64_t) len 527 integer (acc_handle_kind) async 528 end subroutine 529 530 subroutine acc_update_device_async_array_h (a, async_) 531 import acc_handle_kind 532 type (*), dimension (..), contiguous :: a 533 integer (acc_handle_kind) async_ 534 end subroutine 535 end interface 536 537 interface acc_update_self_async 538 subroutine acc_update_self_async_32_h (a, len, async) 539 use iso_c_binding, only: c_int32_t 540 import acc_handle_kind 541 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 542 type (*), dimension (*) :: a 543 integer (c_int32_t) len 544 integer (acc_handle_kind) async 545 end subroutine 546 547 subroutine acc_update_self_async_64_h (a, len, async) 548 use iso_c_binding, only: c_int64_t 549 import acc_handle_kind 550 !GCC$ ATTRIBUTES NO_ARG_CHECK :: a 551 type (*), dimension (*) :: a 552 integer (c_int64_t) len 553 integer (acc_handle_kind) async 554 end subroutine 555 556 subroutine acc_update_self_async_array_h (a, async_) 557 import acc_handle_kind 558 type (*), dimension (..), contiguous :: a 559 integer (acc_handle_kind) async_ 560 end subroutine 561 end interface 562