| 1 |
! OpenACC Runtime Library Definitions. |
| 2 |
|
| 3 |
! Copyright (C) 2014-2025 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
! Contributed by Tobias Burnus <[email protected]> |
| 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 |
! Wrapper functions will be built from openacc.f90. We use a separate file |
| 31 |
! here, because for using ../../openacc.f90, implementations are required for |
| 32 |
! all the functions that it wraps, which we currently don't provide, so linking |
| 33 |
! would fail. |
| 34 |
|
| 35 |
module openacc_kinds |
| 36 |
use iso_fortran_env, only: int32 |
| 37 |
implicit none |
| 38 |
|
| 39 |
public |
| 40 |
private :: int32 |
| 41 |
|
| 42 |
! When adding items, also update 'public' setting in 'module openacc' below. |
| 43 |
|
| 44 |
integer, parameter :: acc_device_kind = int32 |
| 45 |
|
| 46 |
! Keep in sync with include/gomp-constants.h. |
| 47 |
integer (acc_device_kind), parameter :: acc_device_current = -1 |
| 48 |
integer (acc_device_kind), parameter :: acc_device_none = 0 |
| 49 |
integer (acc_device_kind), parameter :: acc_device_default = 1 |
| 50 |
integer (acc_device_kind), parameter :: acc_device_host = 2 |
| 51 |
! integer (acc_device_kind), parameter :: acc_device_host_nonshm = 3 removed. |
| 52 |
integer (acc_device_kind), parameter :: acc_device_not_host = 4 |
| 53 |
integer (acc_device_kind), parameter :: acc_device_nvidia = 5 |
| 54 |
integer (acc_device_kind), parameter :: acc_device_radeon = 8 |
| 55 |
|
| 56 |
end module openacc_kinds |
| 57 |
|
| 58 |
module openacc_internal |
| 59 |
use openacc_kinds |
| 60 |
implicit none |
| 61 |
|
| 62 |
interface |
| 63 |
function acc_on_device_h (devicetype) |
| 64 |
import |
| 65 |
integer (acc_device_kind) devicetype |
| 66 |
logical acc_on_device_h |
| 67 |
end function |
| 68 |
end interface |
| 69 |
|
| 70 |
interface |
| 71 |
function acc_on_device_l (devicetype) & |
| 72 |
bind (C, name = "acc_on_device") |
| 73 |
use iso_c_binding, only: c_int |
| 74 |
integer (c_int) :: acc_on_device_l |
| 75 |
integer (c_int), value :: devicetype |
| 76 |
end function |
| 77 |
end interface |
| 78 |
end module openacc_internal |
| 79 |
|
| 80 |
module openacc |
| 81 |
use openacc_kinds |
| 82 |
use openacc_internal |
| 83 |
implicit none |
| 84 |
|
| 85 |
private |
| 86 |
|
| 87 |
! From openacc_kinds |
| 88 |
public :: acc_device_kind |
| 89 |
public :: acc_device_none, acc_device_default, acc_device_host |
| 90 |
public :: acc_device_not_host, acc_device_nvidia, acc_device_radeon |
| 91 |
|
| 92 |
public :: acc_on_device |
| 93 |
|
| 94 |
interface acc_on_device |
| 95 |
procedure :: acc_on_device_h |
| 96 |
end interface |
| 97 |
|
| 98 |
end module openacc |
| 99 |
|
| 100 |
function acc_on_device_h (devicetype) |
| 101 |
use openacc_internal, only: acc_on_device_l |
| 102 |
use openacc_kinds |
| 103 |
integer (acc_device_kind) devicetype |
| 104 |
logical acc_on_device_h |
| 105 |
acc_on_device_h = acc_on_device_l (devicetype) /= 0 |
| 106 |
end function |