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
40 changes: 29 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ jobs:
GASNET_MASTERIP: 127.0.0.1
CAF_IMAGES: 8
BREW_WARNING_FILTER: 's/^[[:punct:]]*warning[[:punct:]]*(You are using macOS on Intel)/warn: \1/i'
INSTALL_VARS: FC CC CXX FFLAGS CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LIBS GASNET_CONFIGURE_ARGS FPM CMAKE MAKE PKG_CONFIG

steps:
- name: Checkout code
Expand All @@ -312,7 +313,7 @@ jobs:
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container != '' && !contains(matrix.container, 'phhargrove') }}
run: |
apt update
apt install -y build-essential pkg-config make git curl
apt install -y build-essential pkg-config make git curl cmake

- name: Install Ubuntu Native Dependencies
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container == '' && !matrix.brew_via_install }}
Expand Down Expand Up @@ -473,11 +474,8 @@ jobs:
echo "FC=lfortran" >> "$GITHUB_ENV"
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
HEADER_NAME=ISO_Fortran_binding.h
HEADER_TARGET=include/$HEADER_NAME
HEADER_SOURCE=$(lfortran --print-c-include-dir)/$HEADER_NAME
echo "#include <$HEADER_SOURCE>" > $HEADER_TARGET
find / -name $HEADER_NAME -exec ls -al {} \; -exec md5sum {} \; -exec head {} \; -exec echo --- \;
ls -R $(lfortran --print-c-include-dir)
#find / -name $HEADER_NAME -exec ls -al {} \; -exec md5sum {} \; -exec head {} \; -exec echo --- \;

- name: Set Caffeine variables
run: |
Expand Down Expand Up @@ -538,8 +536,7 @@ jobs:

- name: Build Caffeine (install.sh)
run: |
for var in FC CC CXX FFLAGS CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LIBS GASNET_CONFIGURE_ARGS ; do
eval echo "$var=\$$var"; done
(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 }}
if ! grep -q 'NATIVEFLAGS=""' run-fpm.sh ; then
Expand All @@ -554,6 +551,8 @@ jobs:
./run-fpm.sh info
./install/bin/ident ./install/lib/libcaffeine.a | tee output
test ${PIPESTATUS[0]} = 0 && grep -q "CaffeineAssertions" output
pkg-config --validate install/lib/pkgconfig/caffeine.pc | tee output
test ${PIPESTATUS[0]} = 0 && ! grep -q -v pkgconfig/gasnet output

- name: Run examples
run: |
Expand Down Expand Up @@ -617,16 +616,35 @@ jobs:
if: ${{ contains(matrix.os, 'ubuntu') && matrix.brew_via_install }}
run: |
# the first install.sh command established Linux Brew, so add it to the
# PATH to prevent pointless overwrites in the second install.sh below
# PATH to prevent pointless overwrites in subsequent install.sh below
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
( set +e ; ls -al ${HOMEBREW_PREFIX}/bin ; exit 0 )
echo "PATH=${HOMEBREW_PREFIX}/bin:${PATH}" >> "$GITHUB_ENV"

- name: Build and Test Caffeine (thread-safe)
run: |
for var in FC CC CXX FFLAGS CPPFLAGS CFLAGS LDFLAGS LIBS GASNET_CONFIGURE_ARGS ; do
eval echo "$var=\$$var"; done
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 }}
./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
pkg-config --validate install/lib/pkgconfig/caffeine.pc | tee output
test ${PIPESTATUS[0]} = 0 && ! grep -q -v pkgconfig/gasnet output

- name: Build Caffeine (CMake)
run: |
rm -Rf build install/lib/libcaffeine* install/lib/pkgconfig/caffeine*
(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 }}
./run-fpm.sh info
./install/bin/ident ./install/lib/libcaffeine.a | tee output
test ${PIPESTATUS[0]} = 0 && grep -q "CaffeineAssertions" output
pkg-config --validate install/lib/pkgconfig/caffeine.pc | tee output
test ${PIPESTATUS[0]} = 0 && ! grep -q -v pkgconfig/gasnet output
if [[ -n $NATIVE_MULTI_IMAGE ]] ; then
make -C app prif
fi
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ The `install.sh` script uses the following packages to build Caffeine:
- LLVM Flang versions 19 or newer,
- GNU Fortran versions 13 or newer, and
- LFortran versions 0.64 or newer
* [`fpm`](https://github.com/fortran-lang/fpm), the Fortran package manager
* [`fpm`](https://github.com/fortran-lang/fpm), the Fortran package manager (optional)
* -*or*- [`cmake`](https://cmake.org/)
* [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/)
* [GNU make](https://www.gnu.org/software/make/)
* [git](https://git-scm.com)
Expand Down Expand Up @@ -102,6 +103,12 @@ env FC=<Fortran-compiler> CC=<C-compiler> CXX=<C++-compiler> ./install.sh <optio
env CAF_IMAGES=8 ./run-fpm.sh run --example hello
```

If you prefer not to use FPM, you can instead opt to use CMake with `install.sh --enable-cmake`, eg:
```
env FC=<Fortran-compiler> CC=<C-compiler> CXX=<C++-compiler> ./install.sh --enable-cmake <options>
make -C app prif
```

If `$FC` or `$CC` are unset, then `install.sh` will look for LLVM-based compilers in
the `PATH`, and failing that, offer to install such compilers using Homebrew.

Expand Down Expand Up @@ -139,18 +146,23 @@ using Fortran's multi-image features to print a message from each image.
Caffeine also includes a broad "smoke test" of multi-image Fortran features.
When Caffeine was installed using a PRIF-compatible Fortran compiler (currently
LLVM Flang 22+ or LFortran 0.64+) the following command will invoke this smoke
test:
test using FPM:
```bash
env CAF_IMAGES=8 ./run-fpm.sh run
```
This will exercise the available PRIF feature set of the compiler version
Alternatively without use of FPM:
```bash
make -C app prif
```

This test will exercise the available PRIF feature set of the compiler version
detected at install time.

Run tests
---------

After installation, one can optionally issue the following command to run
Caffeine's correctness unit tests to exercise the PRIF subroutines:
Caffeine's correctness unit tests to exercise the PRIF subroutines (requires FPM):

```
./run-fpm.sh test
Expand Down
83 changes: 70 additions & 13 deletions app/Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,88 @@
# This Makefile is for internal testing use only and not intended for end-users
# To run this test with Caffeine, please execute `./run-fpm.sh run` in the top-level directory
# See 'make all' for instructions

# overridable settings
NUM_IMAGES?=4
FLAGS=
NATIVE_FLAGS=$$($(MAKE) --no-print-directory print-flags FC=$$FC)
NATIVE_FLAGS=$$($(MAKE) --no-print-directory print-flags FC="$$FC")
GFORTRAN=gfortran
FC_FORCE=
PKG_CONFIG=pkg-config
CAFFEINE_PKG=caffeine
RUN_FPM_SH=../run-fpm.sh

# ----------------------------------------------------------------

SHELL = bash

all: gcc
all: force
@echo "------------------------------------------------------------------------------"
@echo
@echo "This Makefile builds the native-multi-image smoke test that exercises"
@echo "native compiler support for multi-image features in Fortran."
@echo
@echo "The test is automatically adjusted to the known/expected feature support"
@echo "based on detected Fortran compiler version."
@echo "In all cases the Makefile attempts to choose appropriate compiler flags,"
@echo "but these and other settings can be overridden (see top of Makefile)."
@echo "Execution commands for the built test are best-effort and might need"
@echo "adjustment based on your particular platform."
@echo
@echo "Make Targets:"
@echo
@echo "- 'make gcc' | 'make cce' | 'make intel' | 'make nag' :"
@echo " Build the test using commands appropriate for the selected compiler family,"
@echo " to evaluate built-in multi-image feature support. The FC_FORCE variable"
@echo " can optionally be set to override the compiler command name."
@echo
@echo "- 'make prif' :"
@echo " Build the test and link the Caffeine library to provide multi-image feature"
@echo " support through PRIF. This uses pkg-config to find Caffeine and may require setting:"
@echo " PKG_CONFIG_PATH=<Caffeine_prefix>/lib/pkgconfig"
@echo " Alternatively within an FPM-driven Caffeine build tree you simply can run:"
@echo " ./run-fpm.sh run"
@echo
@echo "------------------------------------------------------------------------------"

print-flags:
@$$FC print-native-flags.F90 -o print-native-flags
@./print-native-flags -s

PRINT_FLAGS_STAND_ALONE?=-s
print-flags: force
@$$FC $(FLAGS) print-native-flags.F90 -o print-native-flags
@./print-native-flags $(PRINT_FLAGS_STAND_ALONE)
@rm -f print-native-flags

gcc:

prif: force
@export PRINT_FLAGS_STAND_ALONE= ; \
if [[ -r $(RUN_FPM_SH) ]] ; then \
FPM_PREFIX=$$(grep PREFIX= $(RUN_FPM_SH) | cut -d= -f2) ; \
[[ -n $$FPM_PREFIX ]] && export PKG_CONFIG_PATH+=:$$FPM_PREFIX/lib/pkgconfig ; \
fi ; $(MAKE) prif-doit

prif-doit: force
$(PKG_CONFIG) --modversion $(CAFFEINE_PKG) >/dev/null
@( $(PKG_CONFIG) --path $(CAFFEINE_PKG) 2>/dev/null || exit 0 )
@export FC=$(if $(FC_FORCE),$(FC_FORCE),$$($(PKG_CONFIG) --variable=CAFFEINE_FC $(CAFFEINE_PKG))) ; \
if $$FC --version 2>&1 | grep -q LFortran ; then FC+=" --cpp" ; fi ; \
set -x ; export NATIVE_FLAGS="$(NATIVE_FLAGS)" && \
$$FC $$NATIVE_FLAGS native-multi-image.F90 -o native-multi-image-prif \
$$($(PKG_CONFIG) --libs-only-L $(CAFFEINE_PKG)) \
$$($(PKG_CONFIG) --libs-only-other $(CAFFEINE_PKG) | awk -v RS=' ' '/-Wl,-rpath/') \
$$($(PKG_CONFIG) --libs-only-l $(CAFFEINE_PKG)) \
$(FLAGS)
@export CAF_IMAGES=$(NUM_IMAGES) ; set -x ; eval $$($(PKG_CONFIG) --variable=CAFFEINE_RUNCMD $(CAFFEINE_PKG)) ./native-multi-image-prif


gcc: force
@set -x ; \
export FC=$(if $(FC_FORCE),$(FC_FORCE),$(GFORTRAN)) ; \
export NATIVE_FLAGS="$(NATIVE_FLAGS)" && \
( [[ -n $$NATIVE_FLAGS ]] || \
( echo ERROR: Currently requires GFortran 16 or later. ; exit 1 ) ) && \
$$FC -g -fcoarray=lib $$NATIVE_FLAGS $(FLAGS) \
native-multi-image.F90 -o native-multi-image-gcc -lcaf_shmem
env GFORTRAN_NUM_IMAGES=$(NUM_IMAGES) ./native-multi-image-gcc

nag:
nag: force
@set -x ; \
export FC=$(if $(FC_FORCE),$(FC_FORCE),nagfor) ; \
export NATIVE_FLAGS="$(NATIVE_FLAGS)" && \
Expand All @@ -37,7 +92,7 @@ nag:
@rm -f native-multi-image.i.F90
env NAGFORTRAN_NUM_IMAGES=$(NUM_IMAGES) ./native-multi-image-nag

cce:
cce: force
@set -x ; \
export FC=$(if $(FC_FORCE),$(FC_FORCE),ftn) ; \
export NATIVE_FLAGS="$(NATIVE_FLAGS)" && \
Expand All @@ -46,7 +101,7 @@ cce:
./native-multi-image-cce
srun -n $(NUM_IMAGES) ./native-multi-image-cce

intel:
intel: force
@set -x ; \
export FC=$(if $(FC_FORCE),$(FC_FORCE),ifx) ; \
export NATIVE_FLAGS="$(NATIVE_FLAGS)" && \
Expand All @@ -55,6 +110,8 @@ intel:
env FOR_COARRAY_NUM_IMAGES=$(NUM_IMAGES) ./native-multi-image-intel

clean:
rm -f *.mod *.i.F90 native-multi-image-{gcc,nag,cce,intel}
rm -f *.mod *.i.F90 native-multi-image-{gcc,nag,cce,intel,prif}

force:

.PHONY: nag gcc clean
.PHONY: force clean
1 change: 1 addition & 0 deletions app/print-native-flags.F90
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ subroutine write_flags
! no multi-image support before 0.64.0
# else
call set("--coarray=true")
call set("--realloc-lhs-arrays")
call no("EVENT")
call no("LOCK")
call no("NOTIFY")
Expand Down
Loading
Loading