diff --git a/flang/module/openacc.f90 b/flang/module/openacc.f90 new file mode 100644 --- /dev/null +++ b/flang/module/openacc.f90 @@ -0,0 +1,624 @@ +!===-- module/openacc.f90 --------------------------------------------------===! +! +! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +! See https://llvm.org/LICENSE.txt for license information. +! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +! +!===------------------------------------------------------------------------===! + + +! OpenACC 3.0 interface declarations. See Sections 3.1 and 3.2 of the OpenACC +! standard. +module openacc + use iso_fortran_env, only: int32 + implicit none + + public + private :: int32 + + ! 3.1 Runtime integer parameter openacc_version + integer, parameter :: openacc_version = 201911 + + integer, parameter :: acc_handle_kind = int32 + + ! Type of accelerator device (3.1) + integer, parameter :: acc_device_kind = int32 + 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 + integer(acc_device_kind), parameter :: acc_device_not_host = 3 + integer(acc_device_kind), parameter :: acc_device_nvidia = 4 + integer(acc_device_kind), parameter :: acc_device_radeon = 5 + + ! Property values for acc_get_property and acc_get_property_string (3.2.6) + integer, parameter :: acc_device_property_kind = int32 + integer(acc_device_property_kind), parameter :: acc_property_memory = 0 + integer(acc_device_property_kind), parameter :: acc_property_free_memory = 1 + integer(acc_device_property_kind), parameter :: & + acc_property_shared_memory_support = 2 + integer(acc_device_property_kind), parameter :: acc_property_name = 4 + integer(acc_device_property_kind), parameter :: acc_property_vendor = 5 + integer(acc_device_property_kind), parameter :: acc_property_driver = 6 + + ! 3.2.26 acc_copyin + interface acc_copyin + procedure :: acc_copyin_32_h + procedure :: acc_copyin_64_h + procedure :: acc_copyin_array_h + end interface + + interface acc_copyin_async + procedure :: acc_copyin_async_32_h + procedure :: acc_copyin_async_64_h + procedure :: acc_copyin_async_array_h + end interface + + ! 3.2.27 acc_create + interface acc_create + procedure :: acc_create_32_h + procedure :: acc_create_64_h + procedure :: acc_create_array_h + end interface + + interface acc_create_async + procedure :: acc_create_async_32_h + procedure :: acc_create_async_64_h + procedure :: acc_create_async_array_h + end interface + + ! 3.2.28 acc_copyout + interface acc_copyout + procedure :: acc_copyout_32_h + procedure :: acc_copyout_64_h + procedure :: acc_copyout_array_h + end interface + + interface acc_copyout_async + procedure :: acc_copyout_async_32_h + procedure :: acc_copyout_async_64_h + procedure :: acc_copyout_async_array_h + end interface + + interface acc_copyout_finalize + procedure :: acc_copyout_finalize_32_h + procedure :: acc_copyout_finalize_64_h + procedure :: acc_copyout_finalize_array_h + end interface + + interface acc_copyout_finalize_async + procedure :: acc_copyout_finalize_async_32_h + procedure :: acc_copyout_finalize_async_64_h + procedure :: acc_copyout_finalize_async_array_h + end interface + + ! 3.2.29 acc_delete + interface acc_delete + procedure :: acc_delete_32_h + procedure :: acc_delete_64_h + procedure :: acc_delete_array_h + end interface + + interface acc_delete_async + procedure :: acc_delete_async_32_h + procedure :: acc_delete_async_64_h + procedure :: acc_delete_async_array_h + end interface + + interface acc_delete_finalize + procedure :: acc_delete_finalize_32_h + procedure :: acc_delete_finalize_64_h + procedure :: acc_delete_finalize_array_h + end interface + + interface acc_delete_finalize_async + procedure :: acc_delete_finalize_async_32_h + procedure :: acc_delete_finalize_async_64_h + procedure :: acc_delete_finalize_async_array_h + end interface + + ! 3.2.30 acc_update_device + interface acc_update_device + procedure :: acc_update_device_32_h + procedure :: acc_update_device_64_h + procedure :: acc_update_device_array_h + end interface + + interface acc_update_device_async + procedure :: acc_update_device_async_32_h + procedure :: acc_update_device_async_64_h + procedure :: acc_update_device_async_array_h + end interface + + ! 3.2.31 acc_update_self + interface acc_update_self + procedure :: acc_update_self_32_h + procedure :: acc_update_self_64_h + procedure :: acc_update_self_array_h + end interface + + interface acc_update_self_async + procedure :: acc_update_self_async_32_h + procedure :: acc_update_self_async_64_h + procedure :: acc_update_self_async_array_h + end interface + + ! 3.2.31 acc_map_data + ! No Fortran signature + + ! 3.2.32 acc_unmap_data + ! No Fortran signature + + ! 3.2.34 acc_deviceptr + ! No Fortran signature + + ! 3.2.35 acc_hostptr + ! No Fortran signature + + ! 3.2.36 acc_is_present + interface acc_is_present + procedure :: acc_is_present_32_h + procedure :: acc_is_present_64_h + procedure :: acc_is_present_array_h + end interface + + ! 3.2.37 acc_memcpy_to_device + ! No Fortran signature + + ! 3.2.38. acc memcpy from device + ! No Fortran signature + + ! 3.2.39. acc memcpy device + ! No Fortran signature + + ! 3.2.40. acc attach + ! No Fortran signature + + ! 3.2.41. acc detach + ! No Fortran signature + + ! 3.2.42 acc_memcpy_d2d + interface acc_memcpy_d2d + ! TODO + end interface + + interface acc_memcpy_d2d_async + ! TODO + end interface + + interface + ! 3.2.1 + integer function acc_get_num_devices( devicetype ) + integer(acc_device_kind) :: devicetype + end function acc_get_num_devices + + ! 3.2.2 + subroutine acc_set_device_type( devicetype ) + integer(acc_device_kind) :: devicetype + end subroutine acc_set_device_type + + ! 3.2.3 + function acc_get_device_type() + integer(acc_device_kind) :: acc_get_device_type + end function acc_get_device_type + + ! 3.2.4 + subroutine acc_set_device_num( devicenum, devicetype ) + integer :: devicenum + integer(acc_device_kind) :: devicetype + end subroutine acc_set_device_num + + ! 3.2.5 + integer function acc_get_device_num( devicetype ) + integer(acc_device_kind) :: devicetype + end function acc_get_device_num + + ! 3.2.6 + integer function acc_get_property( devicenum, devicetype, property ) + integer, value :: devicenum + integer(acc_device_kind), value :: devicetype + integer(acc_device_property_kind), value :: property + integer(acc_device_property_kind) :: acc_get_propert + end function acc_get_property + + subroutine acc_get_property_string( devicenum, devicetype, property, string ) + integer, value :: devicenum + integer(acc_device_kind), value :: devicetype + integer(acc_device_property_kind), value :: property + character*(*) :: string + end subroutine acc_get_property_string + + ! 3.2.7 + subroutine acc_init( devicetype ) + integer(acc_device_kind) :: devicetype + end subroutine acc_init + + ! 3.2.8 + subroutine acc_shutdown( devicetype ) + integer(acc_device_kind) :: devicetype + end subroutine acc_shutdown + + ! 3.2.9 + logical function acc_async_test( arg ) + integer(acc_handle_kind) :: arg + end function acc_async_test + + ! 3.2.10 + logical function acc_async_test_device( arg, device ) + integer(acc_handle_kind) :: arg + integer :: device + end function acc_async_test_device + + ! 3.2.11 + logical function acc_async_test_all() + end function acc_async_test_all + + ! 3.2.11 + logical function acc_async_test_all_device( device ) + integer :: device + end function acc_async_test_all_device + + ! 3.2.13 + subroutine acc_wait( arg ) + integer(acc_handle_kind) :: arg + end subroutine acc_wait + + ! 3.2.14 + subroutine acc_wait_device( arg, device ) + integer(acc_handle_kind) :: arg + integer :: device + end subroutine acc_wait_device + + ! 3.2.15 + subroutine acc_wait_async( arg, async ) + integer(acc_handle_kind) :: arg, async + end subroutine acc_wait_async + + ! 3.2.16 + subroutine acc_wait_device_async( arg, async, device ) + integer(acc_handle_kind) :: arg, async + integer :: device + end subroutine acc_wait_device_async + + ! 3.2.17 + subroutine acc_wait_all() + end subroutine acc_wait_all + + ! 3.2.18 + subroutine acc_wait_all_device( device ) + integer :: device + end subroutine acc_wait_all_device + + ! 3.2.19 + subroutine acc_wait_all_async( async ) + integer(acc_handle_kind) :: async + end subroutine acc_wait_all_async + + ! 3.2.20 + subroutine acc_wait_all_device_async( async, device ) + integer(acc_handle_kind) :: async + integer :: device + end subroutine acc_wait_all_device_async + + ! 3.2.21 + function acc_get_default_async( ) + integer(acc_handle_kind) :: acc_get_default_async + end function acc_get_default_async + + ! 3.2.22 + subroutine acc_set_default_async( async ) + integer(acc_handle_kind) :: async + end subroutine acc_set_default_async + + ! 3.2.23 + logical function acc_on_device( devicetype ) + integer(acc_device_kind) :: devicetype + end function acc_on_device + + ! Signatures for acc_copyin 3.2.26 + subroutine acc_copyin_32_h(a, len) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension (*) :: a + integer(c_int64_t) :: len + end subroutine + + subroutine acc_copyin_array_h(a) + type(*), dimension (..), contiguous :: a + end subroutine + + subroutine acc_copyin_async_32_h(a, len, async) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension (*) :: a + integer(c_int64_t) :: len + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_copyin_async_array_h(a, async) + type(*), dimension (..), contiguous :: a + integer(acc_handle_kind) :: async + end subroutine + + ! 3.2.27 acc_create + subroutine acc_create_32_h(a, len) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + end subroutine + + subroutine acc_create_array_h(a) + type(*), dimension(..), contiguous :: a + end subroutine + + subroutine acc_create_async_32_h(a, len, async) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_create_async_array_h(a, async) + type(*), dimension(..), contiguous :: a + integer(acc_handle_kind) :: async + end subroutine + + ! 3.2.28 acc_copyout + subroutine acc_copyout_32_h(a, len) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + end subroutine + + subroutine acc_copyout_array_h(a) + type(*), dimension(..), contiguous :: a + end subroutine + + subroutine acc_copyout_async_32_h(a, len, async) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_copyout_async_array_h(a, async) + type(*), dimension(..), contiguous :: a + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_copyout_finalize_32_h(a, len) + use iso_c_binding, only: c_int32_t + 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 + type (*), dimension (*) :: a + integer (c_int64_t) :: len + end subroutine + + subroutine acc_copyout_finalize_array_h(a) + type (*), dimension (..), contiguous :: a + end subroutine + + subroutine acc_copyout_finalize_async_32_h(a, len, async) + use iso_c_binding, only: c_int32_t + type(*), dimension(*) :: a + integer(c_int32_t) :: len + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_copyout_finalize_async_64_h(a, len, async) + use iso_c_binding, only: c_int64_t + type (*), dimension (*) :: a + integer (c_int64_t) :: len + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_copyout_finalize_async_array_h(a, async) + type (*), dimension (..), contiguous :: a + integer(acc_handle_kind) :: async + end subroutine + + ! 3.2.29 acc_delete + subroutine acc_delete_32_h(a, len) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + end subroutine + + subroutine acc_delete_array_h(a) + type(*), dimension(..), contiguous :: a + end subroutine + + subroutine acc_delete_async_32_h(a, len, async) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_delete_async_array_h(a, async) + type (*), dimension (..), contiguous :: a + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_delete_finalize_32_h(a, len) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + end subroutine + + subroutine acc_delete_finalize_array_h(a) + type(*), dimension(..), contiguous :: a + end subroutine + + subroutine acc_delete_finalize_async_32_h(a, len, async) + use iso_c_binding, only: c_int32_t + type(*), dimension(*) :: a + integer(c_int32_t) :: len + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_delete_finalize_async_64_h(a, len, async) + use iso_c_binding, only: c_int64_t + type(*), dimension(*) :: a + integer(c_int64_t) :: len + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_delete_finalize_async_array_h(a, async) + type (*), dimension (..), contiguous :: a + integer(acc_handle_kind) :: async + end subroutine + + ! 3.2.30 acc_update_device + subroutine acc_update_device_32_h(a, len) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + end subroutine + + subroutine acc_update_device_array_h(a) + type(*), dimension(..), contiguous :: a + end subroutine + + subroutine acc_update_device_async_32_h(a, len, async) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_update_device_async_array_h(a, async) + type(*), dimension(..), contiguous :: a + integer(acc_handle_kind) :: async + end subroutine + + ! 3.2.31 acc_update_self + subroutine acc_update_self_32_h(a, len) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + end subroutine + + subroutine acc_update_self_array_h(a) + type(*), dimension(..), contiguous :: a + end subroutine + + subroutine acc_update_self_async_32_h(a, len, async) + use iso_c_binding, only: c_int32_t + 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 + type(*), dimension(*) :: a + integer(c_int64_t) :: len + integer(acc_handle_kind) :: async + end subroutine + + subroutine acc_update_self_async_array_h(a, async) + type(*), dimension(..), contiguous :: a + integer(acc_handle_kind) :: async + end subroutine + + ! 3.2.36 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 + 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 + 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 + +end module openacc diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt --- a/flang/tools/f18/CMakeLists.txt +++ b/flang/tools/f18/CMakeLists.txt @@ -24,6 +24,7 @@ "iso_c_binding" "iso_fortran_env" "omp_lib" + "openacc" "__fortran_builtins" )