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
46 changes: 18 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,11 @@ jobs:
compiler: flang
label: Homebrew
brew_via_install: 1
install_filter: '2>&1 | perl -pe "$LINUXBREW_WARNING_FILTER" ; test ${PIPESTATUS[0]} = 0'

- os: ubuntu-26.04-arm
label: Homebrew
compiler: flang
brew_via_install: 1
install_filter: '2>&1 | perl -pe "$LINUXBREW_WARNING_FILTER" ; test ${PIPESTATUS[0]} = 0'

# https://hub.docker.com/r/snowstep/llvm/tags
- os: ubuntu-24.04
Expand Down Expand Up @@ -197,24 +195,12 @@ jobs:
container: ghcr.io/lfortran/lfortran:v0.67.0

# --- PRIF-old coverage ---
- os: ubuntu-24.04
compiler: flang
version: 21
label: PRIF-0.5
FFLAGS: -DFORCE_PRIF_0_5
container: phhargrove/llvm-flang:21.1.0-latest
- os: ubuntu-24.04
compiler: flang
version: 21
label: PRIF-0.6
FFLAGS: -DFORCE_PRIF_0_6
container: phhargrove/llvm-flang:21.1.0-latest
- os: ubuntu-24.04
compiler: flang
version: 21
label: PRIF-0.7
FFLAGS: -DFORCE_PRIF_0_7
container: phhargrove/llvm-flang:21.1.0-latest
# - os: ubuntu-24.04
# compiler: flang
# version: 23
# label: PRIF-0.8
# FFLAGS: -DFORCE_PRIF_0_8
# container: phhargrove/llvm-flang:23.1.0-latest

# --- udp coverage for selected configs ---
- os: macos-26
Expand Down Expand Up @@ -306,8 +292,10 @@ jobs:
GASNET_SPAWNFN: L
GASNET_MASTERIP: 127.0.0.1
CAF_IMAGES: 8
BREW_WARNING_FILTER: 's/^[[:punct:]]*warning[[:punct:]]*(You are using macOS)/warn: \1/i'
LINUXBREW_WARNING_FILTER: 's/^[[:punct:]]*warning[[:punct:]]*(Landlock)/warn: \1/i'
BREW_WARNING_FILTER: 's/^[[:punct:]]+warning[[:punct:]]+/warning: /i'
INSTALL_FILTER: ${{ matrix.brew_via_install &&
'2>&1 | perl -pe "$BREW_WARNING_FILTER" ; test ${PIPESTATUS[0]} = 0' ||
'' }}
INSTALL_VARS: FC CC CXX FFLAGS CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LIBS GASNET_CONFIGURE_ARGS FPM CMAKE MAKE PKG_CONFIG

steps:
Expand Down Expand Up @@ -357,7 +345,7 @@ jobs:
env CI=1 ./install-homebrew.sh
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
retry ${HOMEBREW_PREFIX}/bin/brew install -v gcc@${COMPILER_VERSION} binutils \
2>&1 | perl -pe "$LINUXBREW_WARNING_FILTER" ; test ${PIPESTATUS[0]} = 0
2>&1 | perl -pe "$BREW_WARNING_FILTER" ; test ${PIPESTATUS[0]} = 0
ls -al ${HOMEBREW_PREFIX}/bin
echo "PATH=${HOMEBREW_PREFIX}/bin:${PATH}" >> "$GITHUB_ENV"
: Homebrew GCC@15 needs binutils 2.44+
Expand All @@ -373,7 +361,8 @@ jobs:
if: ${{ contains(matrix.os, 'macos') && !matrix.macports }}
run: |
# silence Homebrew tap trust warnings:
(set +e ; brew untap -f aws/tap hashicorp/tap 2>&1 | perl -pe 's/^::*//;s/^##*//' ; brew trust azure/bicep ; echo )
(set +e ; brew untap -f aws/tap hashicorp/tap ; brew trust azure/bicep ; echo ) \
2>&1 | perl -pe "$BREW_WARNING_FILTER"
# set some Homebrew knobs to accelerate installation
# but only when we are not simulating the user environment brew-via-install workflow
if [[ -z "${{ matrix.brew_via_install }}" ]] ; then
Expand All @@ -390,7 +379,8 @@ jobs:
- name: Install macOS Dependencies (Homebrew)
if: ${{ contains(matrix.os, 'macos') && !matrix.macports && !matrix.brew_via_install }}
run: |
retry brew update
retry brew update \
2>&1 | perl -pe "$BREW_WARNING_FILTER" ; test ${PIPESTATUS[0]} = 0
# fpm binary distribution for macOS requires gfortran shared libraries from gcc@12
retry brew install gcc@12 \
2>&1 | perl -pe "$BREW_WARNING_FILTER" ; test ${PIPESTATUS[0]} = 0
Expand Down Expand Up @@ -567,7 +557,7 @@ jobs:
run: |
(set +x ; for var in ${{ env.INSTALL_VARS }} ; do eval echo "$var=\$$var"; done)
./install.sh ${CONFIGURE_ARGS} ${NETWORK_ARG} \
${{ inputs.install_args }} ${{ matrix.install_filter }}
${{ inputs.install_args }} ${{ env.INSTALL_FILTER }}
if ! grep -q 'NATIVEFLAGS=""' run-fpm.sh ; then
echo "NATIVE_MULTI_IMAGE=true" >> "$GITHUB_ENV"
fi
Expand Down Expand Up @@ -655,7 +645,7 @@ jobs:
rm -Rf build install/lib/libcaffeine* install/lib/pkgconfig/caffeine*
(set +x ; for var in ${{ env.INSTALL_VARS }} ; do eval echo "$var=\$$var"; done)
./install.sh ${CONFIGURE_ARGS} ${NETWORK_ARG} --enable-threads \
${{ inputs.install_args }} ${{ matrix.install_filter }}
${{ inputs.install_args }} ${{ env.INSTALL_FILTER }}
./run-fpm.sh test --verbose -- ${{ inputs.julienne_args }}
./install/bin/ident ./install/lib/libcaffeine.a | tee output
test ${PIPESTATUS[0]} = 0 && grep -q "CaffeineAssertions" output
Expand All @@ -668,7 +658,7 @@ jobs:
(set +e ; rm -f $(type -P fpm) )
(set +x ; for var in ${{ env.INSTALL_VARS }} ; do eval echo "$var=\$$var"; done)
./install.sh ${CONFIGURE_ARGS} ${NETWORK_ARG} --enable-cmake \
${{ inputs.install_args }} ${{ matrix.install_filter }}
${{ inputs.install_args }} ${{ env.INSTALL_FILTER }}
./run-fpm.sh info
./install/bin/ident ./install/lib/libcaffeine.a | tee output
test ${PIPESTATUS[0]} = 0 && grep -q "CaffeineAssertions" output
Expand Down
6 changes: 3 additions & 3 deletions include/caffeine-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#endif
#define CAF_PRIF_VERSION_MAJOR 0
#if FORCE_PRIF_0_5
# define CAF_PRIF_VERSION_MINOR 5
# error FORCE_PRIF_0_5 is not supported
#elif FORCE_PRIF_0_6
# define CAF_PRIF_VERSION_MINOR 6
# error FORCE_PRIF_0_6 is not supported
#elif FORCE_PRIF_0_7
# define CAF_PRIF_VERSION_MINOR 7
# error FORCE_PRIF_0_7 is not supported
#elif FORCE_PRIF_0_8
# define CAF_PRIF_VERSION_MINOR 8
#else
Expand Down
6 changes: 2 additions & 4 deletions src/caffeine/alias_s.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
! start with a copy of the source descriptor
allocate(alias_cdp, source=cdp)

# if CAF_PRIF_VERSION >= 6
alias_cdp%coarray_data = &
as_c_ptr(as_int(alias_cdp%coarray_data) + data_pointer_offset)
# endif
alias_cdp%coarray_data = &
as_c_ptr(as_int(alias_cdp%coarray_data) + data_pointer_offset)

! apply provided cobounds
alias_cdp%corank = corank
Expand Down
65 changes: 13 additions & 52 deletions src/caffeine/allocation_s.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,12 @@
contains

module subroutine prif_allocate_coarray(lcobounds, ucobounds, size_in_bytes, &
# if CAF_PRIF_VERSION >= 8
final_proc, &
# else
final_func, &
# endif
coarray_handle, allocated_memory, stat, errmsg, errmsg_alloc)
final_proc, coarray_handle, allocated_memory, stat, errmsg, errmsg_alloc)
implicit none
! redundant redeclaration of arguments here is a GCC 13..15 bug workaround:
integer(c_int64_t), dimension(:), intent(in) :: lcobounds, ucobounds
integer(c_size_t), intent(in) :: size_in_bytes
# if CAF_PRIF_VERSION >= 8
procedure(prif_coarray_cleanup_interface), pointer, intent(in) :: final_proc
# else
type(c_funptr), intent(in) :: final_func
# endif
type(prif_coarray_handle), intent(out) :: coarray_handle
type(c_ptr), intent(out) :: allocated_memory
integer(c_int), intent(out), optional :: stat
Expand Down Expand Up @@ -94,6 +85,8 @@ module subroutine prif_allocate_coarray(lcobounds, ucobounds, size_in_bytes, &
call caf_establish_child_heap
end if
return
else if (present(stat)) then
stat = 0
end if
if (me /= 1) whole_block = as_c_ptr(current_team%info%heap_start + block_offset)

Expand All @@ -118,15 +111,13 @@ module subroutine prif_allocate_coarray(lcobounds, ucobounds, size_in_bytes, &
end block
cdp%corank = corank
cdp%coarray_size = size_in_bytes
# if CAF_PRIF_VERSION >= 8
if (associated(final_proc)) then
cdp%final_proc = CAF_C_FUNLOC_PROCPTR(final_proc)
else
cdp%final_proc = c_null_funptr
end if
# else
cdp%final_proc = final_func
# endif

if (associated(final_proc)) then
cdp%final_proc = CAF_C_FUNLOC_PROCPTR(final_proc)
else
cdp%final_proc = c_null_funptr
end if

cdp%lcobounds(1:corank) = lcobounds
cdp%ucobounds(1:corank-1) = ucobounds(1:corank-1)
call compute_coshape_epp(lcobounds, ucobounds, cdp%coshape_epp(1:corank))
Expand Down Expand Up @@ -161,6 +152,7 @@ module subroutine prif_allocate_coarray(lcobounds, ucobounds, size_in_bytes, &
call report_error(PRIF_STAT_OUT_OF_MEMORY, out_of_memory_message(size_in_bytes, .false.), &
stat, errmsg, errmsg_alloc)
else
if (present(stat)) stat = 0
# if CAF_POISON
block
! The allocated memory is uninitialized, but often happens to be zero which can hide problems.
Expand Down Expand Up @@ -209,33 +201,15 @@ function pad(str) result(s)
end function
end function

#if CAF_PRIF_VERSION <= 6
module procedure prif_deallocate_coarray
#else
module procedure prif_deallocate_coarray
call prif_deallocate_coarrays([coarray_handle], stat, errmsg, errmsg_alloc)
end procedure

module procedure prif_deallocate_coarrays
#endif
integer :: i, num_handles
type(prif_coarray_handle), target :: coarray_handle
type(prif_coarray_descriptor), pointer :: cdp
# if CAF_PRIF_VERSION >= 8
procedure(prif_coarray_cleanup_interface), pointer :: coarray_cleanup
# else
abstract interface
subroutine coarray_cleanup_i(handle, stat, errmsg) bind(C)
import c_char, c_int, prif_coarray_handle
implicit none
type(prif_coarray_handle), pointer, intent(in) :: handle
integer(c_int), intent(out) :: stat
character(kind=c_char,len=:), intent(out), allocatable :: errmsg
end subroutine
end interface
procedure(coarray_cleanup_i), pointer :: coarray_cleanup
integer(c_int) :: local_stat
character(len=:), allocatable :: local_errmsg
# endif
procedure(prif_coarray_cleanup_interface), pointer :: coarray_cleanup

call_assert(prif_init_called_previously)
call prif_sync_all ! Need to ensure we don't deallocate anything till everyone gets here
Expand All @@ -254,20 +228,7 @@ subroutine coarray_cleanup_i(handle, stat, errmsg) bind(C)
cdp => handle_to_cdp(coarray_handle)
if (c_associated(cdp%final_proc)) then
call c_f_procpointer(cdp%final_proc, coarray_cleanup)
# if CAF_PRIF_VERSION >= 8
call coarray_cleanup(coarray_handle)
# else
call coarray_cleanup(coarray_handle, local_stat, local_errmsg)
call prif_co_max(local_stat) ! Need to be sure it didn't fail on any images
if (local_stat /= 0) then
if (.not. allocated(local_errmsg)) then ! provide a default errmsg
local_errmsg = "coarray_cleanup finalization callback failed"
end if
call report_error(local_stat, local_errmsg, &
stat, errmsg, errmsg_alloc)
return ! NOTE: We no longer have guarantees that coarrays are in consistent state
end if
# endif
end if
end do

Expand Down
8 changes: 2 additions & 6 deletions src/caffeine/sync_stmt_s.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@
! ALLOCATE( si_evt(NUM_IMAGES()) )
type(prif_event_type) :: dummy_event
type(c_ptr) :: allocated_memory
# if CAF_PRIF_VERSION >= 8
procedure(prif_coarray_cleanup_interface), pointer :: null_final_proc
null_final_proc => NULL()
# else
type(c_funptr), parameter :: null_final_proc = c_null_funptr
# endif
procedure(prif_coarray_cleanup_interface), pointer :: null_final_proc
null_final_proc => NULL()

associate(num_imgs => initial_team%num_images)

Expand Down
7 changes: 1 addition & 6 deletions src/caffeine/teams_s.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@
call c_f_pointer(cdp%next_handle, cdp)
end do
teams_coarrays(num_coarrays_in_team)%info = c_loc(cdp)
#if CAF_PRIF_VERSION <= 6
call prif_deallocate_coarray &
#else
call prif_deallocate_coarrays &
#endif
(teams_coarrays, stat, errmsg, errmsg_alloc)
call prif_deallocate_coarrays(teams_coarrays, stat, errmsg, errmsg_alloc)
nullify(current_team%info%coarrays)
else
! child team sync required by F23 11.1.5.2,
Expand Down
8 changes: 0 additions & 8 deletions src/caffeine/unit_test_parameters_m.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
module unit_test_parameters_m
use, intrinsic :: iso_c_binding, only: c_int, c_funptr, c_null_funptr
use prif, only: prif_sync_all, prif_this_image_no_coarray
#if CAF_PRIF_VERSION >= 8
use prif, only: prif_coarray_cleanup_interface
#endif
!! Define values and utilities for consistent use throughout the test suite
implicit none

Expand All @@ -20,21 +18,15 @@ module unit_test_parameters_m
character(len=:), allocatable :: subjob_prefix
character(len=:), allocatable :: fpm_driver

#if CAF_PRIF_VERSION >= 8
procedure(prif_coarray_cleanup_interface), pointer :: null_final_proc => NULL()
#else
type(c_funptr) :: null_final_proc = c_null_funptr
#endif

contains

#if CAF_PRIF_VERSION >= 8
function final_proc_usher(fp) result(res)
procedure(prif_coarray_cleanup_interface) :: fp
procedure(prif_coarray_cleanup_interface), pointer :: res
res => fp
end function
#endif

! Retrieve an environment parameter or its default value
subroutine getenv_withdefault(key, default, result)
Expand Down
Loading
Loading