openacc.f90 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ! OpenACC Runtime Library Definitions.
  2. ! Copyright (C) 2014-2022 Free Software Foundation, Inc.
  3. ! Contributed by Tobias Burnus <burnus@net-b.de>
  4. ! and Mentor Embedded.
  5. ! This file is part of the GNU Offloading and Multi Processing Library
  6. ! (libgomp).
  7. ! Libgomp is free software; you can redistribute it and/or modify it
  8. ! under the terms of the GNU General Public License as published by
  9. ! the Free Software Foundation; either version 3, or (at your option)
  10. ! any later version.
  11. ! Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
  12. ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. ! FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. ! more details.
  15. ! Under Section 7 of GPL version 3, you are granted additional
  16. ! permissions described in the GCC Runtime Library Exception, version
  17. ! 3.1, as published by the Free Software Foundation.
  18. ! You should have received a copy of the GNU General Public License and
  19. ! a copy of the GCC Runtime Library Exception along with this program;
  20. ! see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  21. ! <http://www.gnu.org/licenses/>.
  22. ! Wrapper functions will be built from openacc.f90. We use a separate file
  23. ! here, because for using ../../openacc.f90, implementations are required for
  24. ! all the functions that it wraps, which we currently don't provide, so linking
  25. ! would fail.
  26. module openacc_kinds
  27. use iso_fortran_env, only: int32
  28. implicit none
  29. public
  30. private :: int32
  31. ! When adding items, also update 'public' setting in 'module openacc' below.
  32. integer, parameter :: acc_device_kind = int32
  33. ! Keep in sync with include/gomp-constants.h.
  34. integer (acc_device_kind), parameter :: acc_device_current = -1
  35. integer (acc_device_kind), parameter :: acc_device_none = 0
  36. integer (acc_device_kind), parameter :: acc_device_default = 1
  37. integer (acc_device_kind), parameter :: acc_device_host = 2
  38. ! integer (acc_device_kind), parameter :: acc_device_host_nonshm = 3 removed.
  39. integer (acc_device_kind), parameter :: acc_device_not_host = 4
  40. integer (acc_device_kind), parameter :: acc_device_nvidia = 5
  41. integer (acc_device_kind), parameter :: acc_device_radeon = 8
  42. end module openacc_kinds
  43. module openacc_internal
  44. use openacc_kinds
  45. implicit none
  46. interface
  47. function acc_on_device_h (devicetype)
  48. import
  49. integer (acc_device_kind) devicetype
  50. logical acc_on_device_h
  51. end function
  52. end interface
  53. interface
  54. function acc_on_device_l (devicetype) &
  55. bind (C, name = "acc_on_device")
  56. use iso_c_binding, only: c_int
  57. integer (c_int) :: acc_on_device_l
  58. integer (c_int), value :: devicetype
  59. end function
  60. end interface
  61. end module openacc_internal
  62. module openacc
  63. use openacc_kinds
  64. use openacc_internal
  65. implicit none
  66. private
  67. ! From openacc_kinds
  68. public :: acc_device_kind
  69. public :: acc_device_none, acc_device_default, acc_device_host
  70. public :: acc_device_not_host, acc_device_nvidia, acc_device_radeon
  71. public :: acc_on_device
  72. interface acc_on_device
  73. procedure :: acc_on_device_h
  74. end interface
  75. end module openacc
  76. function acc_on_device_h (devicetype)
  77. use openacc_internal, only: acc_on_device_l
  78. use openacc_kinds
  79. integer (acc_device_kind) devicetype
  80. logical acc_on_device_h
  81. acc_on_device_h = acc_on_device_l (devicetype) /= 0
  82. end function