Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions include/language-support.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,31 @@
#define HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY 0
#endif
#endif

! ISO_FORTRAN_ENV constant value control:
! The following knobs influence Caffeine's choice of value for the named constants
! specified by PRIF for ISO_FORTRAN_ENV:
! * CAF_IMPORT_{ATOMIC,STAT,TEAM}_CONSTANTS: Import PRIF constant values
! of the given category from the compiler's ISO_FORTRAN_ENV
! * CAF_IMPORT_CONSTANTS: Provides a default value for each category-specific knob above,
! which take precedence
! NOTE: In all cases imported constant values are silently assumed to satisfy
! the requirements for the corresponding PRIF named constant.
! Additionally, the ATOMIC KIND constants are assumed to denote a 64-bit interoperable type
Comment thread
bonachea marked this conversation as resolved.
Resolved
#ifndef CAF_IMPORT_CONSTANTS
# if defined(__flang__)
# define CAF_IMPORT_CONSTANTS 1
# else
# define CAF_IMPORT_CONSTANTS 0
# endif
#endif
#ifndef CAF_IMPORT_ATOMIC_CONSTANTS
#define CAF_IMPORT_ATOMIC_CONSTANTS CAF_IMPORT_CONSTANTS
#endif
#ifndef CAF_IMPORT_STAT_CONSTANTS
#define CAF_IMPORT_STAT_CONSTANTS CAF_IMPORT_CONSTANTS
#endif
#ifndef CAF_IMPORT_TEAM_CONSTANTS
#define CAF_IMPORT_TEAM_CONSTANTS CAF_IMPORT_CONSTANTS
#endif

53 changes: 46 additions & 7 deletions src/prif.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ module prif
c_char, c_int, c_bool, c_intptr_t, c_ptr, &
c_funptr, c_size_t, c_ptrdiff_t, c_null_ptr, c_int64_t

#if CAF_IMPORT_ATOMIC_CONSTANTS
use iso_fortran_env, only: ATOMIC_INT_KIND, ATOMIC_LOGICAL_KIND
#endif
#if CAF_IMPORT_STAT_CONSTANTS
use iso_fortran_env, only: &
STAT_FAILED_IMAGE, STAT_STOPPED_IMAGE, &
STAT_LOCKED, STAT_LOCKED_OTHER_IMAGE, &
STAT_UNLOCKED, STAT_UNLOCKED_FAILED_IMAGE
#endif
#if CAF_IMPORT_TEAM_CONSTANTS
use iso_fortran_env, only: CURRENT_TEAM, INITIAL_TEAM, PARENT_TEAM
#endif

implicit none

private
Expand Down Expand Up @@ -50,24 +63,50 @@ module prif
integer(c_int), parameter, public :: PRIF_VERSION_MAJOR = 0
integer(c_int), parameter, public :: PRIF_VERSION_MINOR = 6

integer(c_int), parameter, public :: PRIF_ATOMIC_INT_KIND = c_int64_t

#if HAVE_SELECTED_LOGICAL_KIND
integer(c_int), parameter, public :: PRIF_ATOMIC_LOGICAL_KIND = selected_logical_kind(64)
#if CAF_IMPORT_ATOMIC_CONSTANTS
integer(c_int), parameter, public :: PRIF_ATOMIC_INT_KIND = ATOMIC_INT_KIND
integer(c_int), parameter, public :: PRIF_ATOMIC_LOGICAL_KIND = ATOMIC_LOGICAL_KIND
#else
integer(c_int), parameter, public :: PRIF_ATOMIC_LOGICAL_KIND = PRIF_ATOMIC_INT_KIND
integer(c_int), parameter, public :: PRIF_ATOMIC_INT_KIND = c_int64_t

# if HAVE_SELECTED_LOGICAL_KIND
integer(c_int), parameter, public :: PRIF_ATOMIC_LOGICAL_KIND = selected_logical_kind(64)
# else
integer(c_int), parameter, public :: PRIF_ATOMIC_LOGICAL_KIND = PRIF_ATOMIC_INT_KIND
# endif
#endif

#if CAF_IMPORT_TEAM_CONSTANTS
integer(c_int), parameter, public :: &
PRIF_CURRENT_TEAM = CURRENT_TEAM, &
PRIF_INITIAL_TEAM = INITIAL_TEAM, &
PRIF_PARENT_TEAM = PARENT_TEAM
#else
integer(c_int), parameter, public :: &
PRIF_CURRENT_TEAM = 101, &
PRIF_INITIAL_TEAM = 102, &
PRIF_PARENT_TEAM = 103, &
PRIF_PARENT_TEAM = 103
#endif

#if CAF_IMPORT_STAT_CONSTANTS
integer(c_int), parameter, public :: &
PRIF_STAT_FAILED_IMAGE = STAT_FAILED_IMAGE, &
PRIF_STAT_LOCKED = STAT_LOCKED, &
PRIF_STAT_LOCKED_OTHER_IMAGE = STAT_LOCKED_OTHER_IMAGE, &
PRIF_STAT_STOPPED_IMAGE = STAT_STOPPED_IMAGE, &
PRIF_STAT_UNLOCKED = STAT_UNLOCKED, &
PRIF_STAT_UNLOCKED_FAILED_IMAGE = STAT_UNLOCKED_FAILED_IMAGE
#else
integer(c_int), parameter, public :: &
PRIF_STAT_FAILED_IMAGE =-201, &
PRIF_STAT_LOCKED = 202, &
PRIF_STAT_LOCKED_OTHER_IMAGE = 203, &
PRIF_STAT_STOPPED_IMAGE = 204, &
PRIF_STAT_UNLOCKED = 205, &
PRIF_STAT_UNLOCKED_FAILED_IMAGE = 206, &
PRIF_STAT_UNLOCKED_FAILED_IMAGE = 206
#endif

integer(c_int), parameter, public :: &
PRIF_STAT_OUT_OF_MEMORY = 301, &
PRIF_STAT_ALREADY_INIT = 302

Expand Down
Loading