Skip to content

Commit 98a670d

Browse files
authored
Merge pull request #192 from bonachea/ci-expand
Reorganize and expand CI action
2 parents d5d0faa + 3b75af1 commit 98a670d

3 files changed

Lines changed: 121 additions & 22 deletions

File tree

.github/workflows/CI.yml

Lines changed: 100 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,126 @@ on: [push, pull_request]
44

55
jobs:
66
Build:
7-
runs-on: [ubuntu-latest]
7+
name: ${{ matrix.compiler }}-${{ matrix.version }} (${{ matrix.os }})
8+
runs-on: ${{ matrix.os }}
9+
defaults:
10+
run:
11+
shell: bash
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ macos-14, macos-15, macos-15-intel, macos-26, ubuntu-24.04 ]
16+
compiler: [ gfortran ]
17+
version: [ 14 ]
18+
extra_flags: [ -g ]
19+
oc_version: [ 2.10.3 ]
20+
21+
include:
22+
- os: ubuntu-24.04
23+
compiler: gfortran
24+
version: 13
25+
extra_flags: -g -ffree-line-length-0
26+
oc_version: 2.10.3
827

928
env:
10-
FC: gfortran
11-
GCC_V: 14
29+
COMPILER_VERSION: ${{ matrix.version }}
30+
OC_VERSION: ${{ matrix.oc_version }}
31+
FC: ${{ matrix.compiler }}
32+
FFLAGS: ${{ matrix.extra_flags }}
33+
FPM_FLAGS: --profile release --verbose
1234

1335
steps:
1436
- name: Checkout code
1537
uses: actions/checkout@v4
1638

1739
- name: Install fpm
18-
uses: fortran-lang/setup-fpm@v7
40+
uses: fortran-lang/setup-fpm@main
1941
with:
2042
github-token: ${{ secrets.GITHUB_TOKEN }}
43+
fpm-version: latest
2144

2245
- name: Get Time
2346
id: time
24-
uses: nanzm/get-time-action@v1.1
47+
uses: nanzm/get-time-action@master
2548
with:
2649
format: 'YYYY-MM'
2750

28-
- name: Setup cache for opencoarrays
51+
- name: Install macOS Dependencies
52+
if: ${{ contains(matrix.os, 'macos') && matrix.compiler == 'gfortran' && matrix.version == 14 }}
53+
run: |
54+
set -x
55+
brew update
56+
# fpm binary distribution for macOS requires gfortran shared libraries from gcc@12
57+
brew install -v gcc@12
58+
brew install -v opencoarrays gcc@14 open-mpi
59+
#brew --prefix
60+
#ls -alR $(brew --prefix)/bin
61+
echo "FC=gfortran-${COMPILER_VERSION}" >> "$GITHUB_ENV"
62+
63+
- name: Install Ubuntu Native Dependencies
64+
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container == '' && matrix.compiler == 'gfortran' }}
65+
run: |
66+
set -x
67+
sudo apt update
68+
sudo apt install -y build-essential pkg-config make
69+
sudo apt install -y gfortran-${COMPILER_VERSION} g++-${COMPILER_VERSION}
70+
71+
- name: OpenCoarrays/MPICH Cache
72+
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container == '' }}
2973
id: cache-opencoarrays
30-
uses: actions/cache@v3
74+
uses: actions/cache@v4
3175
with:
32-
path: "OpenCoarrays-2.10.2/"
33-
key: ${{ steps.time.outputs.time }}
76+
path: OpenCoarrays-${{ matrix.oc_version }}
77+
key: OpenCoarrays-${{ matrix.oc_version }}-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }}-${{ steps.time.outputs.time }}
3478

35-
- name: Install GFortran, OpenCoarrays
79+
- name: OpenCoarrays/MPICH Build
80+
if: ${{ steps.cache-opencoarrays.outputs.cache-hit != 'true' && contains(matrix.os, 'ubuntu') && matrix.container == '' }}
3681
run: |
37-
sudo apt update
38-
sudo apt install -y build-essential gfortran-${GCC_V} g++-${GCC_V} pkg-config make
39-
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
40-
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
41-
--slave /usr/bin/g++ g++ /usr/bin/g++-${GCC_V}
42-
if [ ! -d OpenCoarrays-2.10.2 ] ; then wget -P . https://github.com/sourceryinstitute/OpenCoarrays/releases/download/2.10.2/OpenCoarrays-2.10.2.tar.gz && tar -xf OpenCoarrays-2.10.2.tar.gz && cd OpenCoarrays-2.10.2 && TERM=xterm ./install.sh -y; fi
82+
set -x
83+
rm -Rf OpenCoarrays-${OC_VERSION}
84+
#OC_URL=https://github.com/sourceryinstitute/OpenCoarrays/releases/download/${OC_VERSION}/OpenCoarrays-${OC_VERSION}.tar.gz
85+
OC_URL=https://github.com/sourceryinstitute/OpenCoarrays/archive/refs/tags/${OC_VERSION}.tar.gz
86+
wget -P . ${OC_URL}
87+
tar -xf ${OC_VERSION}.tar.gz
88+
cd OpenCoarrays-${OC_VERSION}
89+
TERM=xterm ./install.sh --yes-to-all \
90+
--with-fortran gfortran-${COMPILER_VERSION} \
91+
--with-cxx g++-${COMPILER_VERSION} \
92+
--with-c gcc-${COMPILER_VERSION}
93+
94+
- name: Setup Ubuntu Compilers
95+
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container == '' && matrix.compiler == 'gfortran' }}
96+
run: |
97+
set -x
98+
PREFIX="$PWD/OpenCoarrays-${OC_VERSION}/prerequisites/installations"
99+
OC_PATH="$PREFIX/opencoarrays/${OC_VERSION}"
100+
MPI_PATH=$(ls -d $PREFIX/mpich/*)
101+
#ls -alR ${PREFIX}
102+
cat ${OC_PATH}/setup.sh
103+
echo "PATH=${OC_PATH}/bin:${MPI_PATH}/bin:$PATH" >> "$GITHUB_ENV"
104+
echo "FC=gfortran-${COMPILER_VERSION}" >> "$GITHUB_ENV"
105+
echo "FPM_FFLAGS=${FFLAGS}" >> "$GITHUB_ENV"
106+
echo "FPM_CFLAGS=${CFLAGS}" >> "$GITHUB_ENV"
107+
echo "FPM_CXXFLAGS=${CXXFLAGS}" >> "$GITHUB_ENV"
108+
echo "FPM_LDFLAGS=${LDFLAGS}" >> "$GITHUB_ENV"
109+
110+
- name: Version info
111+
run: |
112+
echo == TOOL VERSIONS ==
113+
echo Platform version info:
114+
uname -a
115+
if test -r /etc/os-release ; then grep -e NAME -e VERSION /etc/os-release ; fi
116+
if test -x /usr/bin/sw_vers ; then /usr/bin/sw_vers ; fi
117+
echo
118+
echo PATH="$PATH"
119+
for tool in ${FC} caf mpicc mpif90 fpm ; do
120+
( echo ; set -x ; w=$(which $tool) ; \
121+
if test -n "$w" ; then \
122+
ls -al $w ; ls -alhL $w ; $tool --version || echo ERROR=$? ; \
123+
fi )
124+
done
43125
44126
- name: Build, run, and test
45127
run: |
46-
source OpenCoarrays-2.10.2/prerequisites/installations/opencoarrays/2.10.2/setup.sh
47-
fpm test --compiler caf --runner "cafrun -n 2"
128+
#source OpenCoarrays-${OC_VERSION}/prerequisites/installations/opencoarrays/${OC_VERSION}/setup.sh
129+
fpm test --compiler caf --runner "cafrun -n 2" ${FPM_FLAGS}

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Despite advances in microscopy, imaging techniques only capture a very small spa
99

1010
Prerequisites
1111
-------------
12-
1. A Fortran 2018 compiler (`gfortran` + [OpenCoarrays])
12+
1. A Fortran 2018 compiler with multi-image/coarray support (e.g. `gfortran` + [OpenCoarrays])
1313
2. The Fortran Package Manager
1414

1515
Downloading, Building, and Testing
@@ -44,8 +44,11 @@ export FOR_COARRAY_NUM_IMAGES=4
4444
fpm test --compiler ifx --profile release --flag "-heap-arrays -coarray"
4545
```
4646

47+
Note this requires a working install of Intel MPI.
48+
4749
#### Single-image (serial) execution
4850
Same as multi-image execution except `FOR_COARRAY_NUM_IMAGES=1`.
51+
Also requires a working install of Intel MPI.
4952

5053
#### Automatic GPU-based acceleration: _Experimental_
5154
The following command is listed here for reference while we investigate what appear to be platform-specific compiler issues causing a crashe when automatic GPU-based acceleration is enabled with the required coarray features:

test/subdomain_test_m.F90

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,13 @@ function concave_laplacian() result(test_diagnosis)
9797

9898
block
9999
real, parameter :: tolerance = 1.0E-06
100+
integer :: nx, ny, nz
100101
logical internally_zero, concave_at_faces, doubly_concave_at_edges, triply_concave_in_corners, constant_away_from_edges
101102

102-
associate(me=>this_image(), n_subdomains=>num_images(), nx=>size(lap_f_vals,1), ny=>size(lap_f_vals,2),nz=>size(lap_f_vals,3))
103+
nx = size(lap_f_vals,1)
104+
ny = size(lap_f_vals,2)
105+
nz = size(lap_f_vals,3)
106+
associate(me=>this_image(), n_subdomains=>num_images())
103107
associate(first_zero_in_x => merge(3, 1, me==1), last_zero_in_x => merge(nx-2, nx, me==n_subdomains))
104108
internally_zero = all(abs(lap_f_vals(first_zero_in_x:last_zero_in_x, 3:ny-2, 3:nz-2)) < tolerance)
105109
end associate
@@ -197,20 +201,30 @@ function correct_steady_state() result(test_diagnosis)
197201
end associate
198202

199203
associate(residual => T%values() - T_steady)
204+
#ifdef __INTEL_COMPILER
205+
! workaround a typecheck defect observed in ifx 2025.2.1
206+
test_diagnosis = .all. [(residual .isAtLeast. 0.) .and. (residual .isAtMost. tolerance)]
207+
#else
200208
test_diagnosis = .all. ((residual .isAtLeast. 0.) .and. (residual .isAtMost. tolerance))
209+
#endif
201210
end associate
202211
end function
203212

204213
function functional_matches_procedural() result(test_diagnosis)
205214
type(test_diagnosis_t) test_diagnosis
206-
real, parameter :: tolerance = 1.E-06
215+
real, parameter :: tolerance = 1.E-05
207216
integer, parameter :: steps = 1000, n=21
208217
real, parameter :: alpha = 1.
209218
real, parameter :: side=1., boundary_val=1., internal_val=2.
210219

211220
associate( T_f => T_functional(), T_p => T_procedural())
212221
associate(L_infinity_norm => maxval(abs(T_f - T_p)))
222+
#ifdef __INTEL_COMPILER
223+
! workaround a typecheck defect observed in ifx 2025.2.1
224+
test_diagnosis = .all. [T_f .approximates. T_p .within. tolerance]
225+
#else
213226
test_diagnosis = .all. (T_f .approximates. T_p .within. tolerance)
227+
#endif
214228
end associate
215229
end associate
216230

@@ -249,4 +263,4 @@ function T_procedural()
249263
end function
250264

251265
end function
252-
end module subdomain_test_m
266+
end module subdomain_test_m

0 commit comments

Comments
 (0)