Skip to content

Commit 7a277f9

Browse files
jfdev001jatkinson1000joewallwork
authored
CI for ifx, ifort, and gcc v9-13 (fixes issue Cambridge-ICCS#140) (PR Cambridge-ICCS#438) (Cambridge-ICCS#438)
------- Summary ------- Splits CI into GNU and Intel compiler jobs. Builds OpenMPI with Intel compilers to run MPI integration tests. ------- Details ------- * Dynamically builds matrix for GNU job -- that is use GCC v13 during PRs, but test GCC v9-13 only during merge with main. * Provides Intel job to test ifx/ifort v2023.2.0. V2023.2.0 is the actual version that gets setup by `setup-fortran` when calling intel classic v2021.10. Note, icc and icpc are not used, just icx and icpx where needed. Intel job is only run during merge with main. * Intel job builds OpenMPI from source using Intel compilers since Intel oneAPI MPI does not support `mpi_gather` (which is used in the MPI integration tests). Co-authored-by: Jack Atkinson <jwa34@cam.ac.uk> Co-authored-by: Joe Wallwork <jw2423@cam.ac.uk> Co-authored-by: Jack Atkinson <109271713+jatkinson1000@users.noreply.github.com>
1 parent fcc7938 commit 7a277f9

File tree

2 files changed

+195
-9
lines changed

2 files changed

+195
-9
lines changed

.github/workflows/test_suite_ubuntu.yml

Lines changed: 194 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Workflow to run the FTorch test suite
1+
# Workflow to run the FTorch test suite using jobs for Intel and GNU compilers
2+
# Any changes need to be reflected in both GNU and Intel jobs
23
name: Test suite (Ubuntu CPU)
34

45
# Controls when the workflow will run
@@ -36,14 +37,54 @@ permissions: {}
3637

3738
# Workflow run - one or more jobs that can run sequentially or in parallel
3839
jobs:
39-
# This workflow contains a single job called "test-suite-ubuntu"
40-
test-suite-ubuntu:
40+
# Dynamically build matrix for GNU job
41+
setup-gnu-matrix:
42+
runs-on: ubuntu-latest
43+
outputs:
44+
matrix: ${{ steps.set-matrix.outputs.matrix }}
45+
env:
46+
EVENT_NAME: ${{ github.event_name }}
47+
steps:
48+
- id: set-matrix
49+
run: |
50+
if [[ "$EVENT_NAME" == 'push' ]]
51+
then
52+
# Include GCC 9–13 for PRs to main
53+
MATRIX_JSON='
54+
{
55+
"toolchain": [
56+
{"compiler": "gcc", "version": 13},
57+
{"compiler": "gcc", "version": 12},
58+
{"compiler": "gcc", "version": 11},
59+
{"compiler": "gcc", "version": 10},
60+
{"compiler": "gcc", "version": 9}
61+
],
62+
"std": ["f2008"],
63+
"include": [
64+
{"toolchain": {"compiler": "gcc", "version": 13}, "std": "f2018"}
65+
]
66+
}'
67+
else
68+
# Only GCC 13 for everything else
69+
MATRIX_JSON='
70+
{
71+
"toolchain": [
72+
{"compiler": "gcc", "version": 13}
73+
],
74+
"std": ["f2008", "f2018"]
75+
}'
76+
fi
77+
# Convert json to compact line expected by github action
78+
MATRIX_JSON=$(echo "$MATRIX_JSON" | jq -c .)
79+
echo "matrix=${MATRIX_JSON}" >> $GITHUB_OUTPUT
80+
81+
GNU:
82+
needs: setup-gnu-matrix
4183
# The type of runner that the job will run on
4284
runs-on: ubuntu-latest
4385
strategy:
4486
fail-fast: false
45-
matrix:
46-
std: ["f2008", "f2018"]
87+
matrix: ${{ fromJSON(needs.setup-gnu-matrix.outputs.matrix) }}
4788

4889
# Terminate the job if it runs for more than 10 minutes
4990
timeout-minutes: 10
@@ -56,6 +97,17 @@ jobs:
5697
persist-credentials: false
5798
uses: actions/checkout@v4
5899

100+
- name: setup-fortran
101+
uses: fortran-lang/setup-fortran@d2ba6ea44297a24407def2f6e117954d844a5368 # v1
102+
with:
103+
compiler: ${{ matrix.toolchain.compiler }}
104+
version: ${{ matrix.toolchain.version }}
105+
106+
- name: check-compilers-env
107+
run: ${FC}
108+
env:
109+
FC: ${{ steps.setup-fortran.outputs.fc }}
110+
59111
- name: Install Python
60112
uses: actions/setup-python@v5
61113
with:
@@ -68,11 +120,10 @@ jobs:
68120
. ftorch/bin/activate
69121
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
70122
71-
# MPI is required by pFUnit
72-
- name: Install an MPI distribution
123+
- name: Install OpenMPI
73124
run: |
74125
sudo apt update
75-
sudo apt install openmpi-bin openmpi-common libopenmpi-dev
126+
sudo apt install -y openmpi-bin openmpi-common libopenmpi-dev
76127
77128
- name: Install pFUnit
78129
run: |
@@ -86,6 +137,8 @@ jobs:
86137
make -j 4 install
87138
88139
- name: Build FTorch
140+
env:
141+
FORTRAN_STANDARD: ${{ matrix.std }}
89142
run: |
90143
. ftorch/bin/activate
91144
VN=$(python -c "import sys; print('.'.join(sys.version.split('.')[:2]))")
@@ -95,13 +148,145 @@ jobs:
95148
export PFUNIT_DIR=$(pwd)/pFUnit/build/installed/PFUNIT-4.12
96149
mkdir ${BUILD_DIR}
97150
cd ${BUILD_DIR}
151+
98152
cmake .. \
99153
-DPython_EXECUTABLE="$(which python)" \
100154
-DCMAKE_BUILD_TYPE=Release \
155+
-DCMAKE_Fortran_COMPILER=${FC} \
156+
-DCMAKE_C_COMPILER=${CC} \
157+
-DCMAKE_CXX_COMPILER=${CXX} \
101158
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR} \
102159
-DCMAKE_BUILD_TESTS=TRUE \
103160
-DCMAKE_PREFIX_PATH="${PFUNIT_DIR};${Torch_DIR}" \
104-
-DCMAKE_Fortran_FLAGS="-std=${{ matrix.std }}"
161+
-DCMAKE_Fortran_FLAGS="-std=$FORTRAN_STANDARD"
162+
cmake --build .
163+
cmake --install .
164+
165+
- name: Run unit tests
166+
run: |
167+
. ftorch/bin/activate
168+
cd build
169+
ctest --verbose --tests-regex unit
170+
171+
- name: Run integration tests
172+
run: |
173+
. ftorch/bin/activate
174+
cd build
175+
ctest --verbose --tests-regex example
176+
177+
Intel:
178+
# Trigger intel build only if push to main
179+
if: github.event_name == 'push'
180+
# The type of runner that the job will run on
181+
runs-on: ubuntu-latest
182+
strategy:
183+
fail-fast: false
184+
matrix:
185+
toolchain: [intel-ifx, intel-ifort]
186+
std: ["f08"]
187+
include:
188+
- toolchain: intel-ifx
189+
FC: "/opt/intel/oneapi/compiler/2023.2.0/linux/bin/ifx"
190+
CC: "/opt/intel/oneapi/compiler/2023.2.0/linux/bin/icx"
191+
CXX: "/opt/intel/oneapi/compiler/2023.2.0/linux/bin/icpx"
192+
- toolchain: intel-ifort
193+
FC: "/opt/intel/oneapi/compiler/2023.2.0/linux/bin/intel64/ifort"
194+
CC: "/opt/intel/oneapi/compiler/2023.2.0/linux/bin/icx"
195+
CXX: "/opt/intel/oneapi/compiler/2023.2.0/linux/bin/icpx"
196+
197+
# Steps represent a sequence of tasks that will be executed as part of the job
198+
steps:
199+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
200+
- name: Checkout code
201+
with:
202+
persist-credentials: false
203+
uses: actions/checkout@v4
204+
205+
- name: Install Python
206+
uses: actions/setup-python@v5
207+
with:
208+
python-version: '3.x'
209+
210+
- name: Install PyTorch
211+
run: |
212+
python -m pip install --upgrade pip
213+
python -m venv ftorch
214+
. ftorch/bin/activate
215+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
216+
217+
# NOTE: Based on github action logs, this installs ifx/ifort,
218+
# icx/icc, and icpx/icpc for v2023.2.0
219+
# see https://www.intel.com/content/www/us/en/developer/articles/tool/compilers-redistributable-libraries-by-version.html
220+
- name: Install Intel classic and modern compilers
221+
uses: fortran-lang/setup-fortran@d2ba6ea44297a24407def2f6e117954d844a5368 # v1
222+
id: setup-fortran
223+
with:
224+
compiler: intel-classic
225+
version: '2021.10'
226+
227+
- name: Cache OpenMPI
228+
id: cache-openmpi
229+
uses: actions/cache@v4
230+
with:
231+
path: /home/runner/openmpi-${{ matrix.toolchain }}
232+
key: openmpi-${{ runner.os }}-openmpi-4.1.2-${{ matrix.toolchain }}
233+
234+
- name: Build OpenMPI with Intel compilers
235+
if: steps.cache-openmpi.outputs.cache-hit != 'true'
236+
run: |
237+
wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.2.tar.gz
238+
tar -xzf openmpi-4.1.2.tar.gz
239+
cd openmpi-4.1.2
240+
./configure \
241+
CC=${{ matrix.CC }} CXX=${{ matrix.CXX }} FC=${{ matrix.FC }} \
242+
--prefix=$HOME/openmpi-${{ matrix.toolchain }}
243+
make -j 8
244+
make install
245+
246+
- name: Add OpenMPI to env
247+
run: |
248+
echo "PATH=$HOME/openmpi-${{ matrix.toolchain }}/bin:${PATH}" >> $GITHUB_ENV
249+
echo "LD_LIBRARY_PATH=$HOME/openmpi-${{ matrix.toolchain }}/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
250+
251+
- name: Install pFUnit
252+
run: |
253+
export FC=${{ matrix.FC }}
254+
export CC=${{ matrix.CC }}
255+
export CXX=${{ matrix.CXX }}
256+
export MPIF90=mpif90
257+
export OPENMPI_DIR=$HOME/openmpi-${{ matrix.toolchain }}
258+
# TODO: Avoid version pinning (needed because version appears in install path)
259+
git clone -b v4.12.0 https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git
260+
mkdir pFUnit/build
261+
cd pFUnit/build
262+
cmake .. -DCMAKE_PREFIX_PATH=${OPENMPI_DIR}
263+
make -j 4 install
264+
265+
- name: Build FTorch
266+
run: |
267+
. ftorch/bin/activate
268+
VN=$(python -c "import sys; print('.'.join(sys.version.split('.')[:2]))")
269+
export Torch_DIR=${VIRTUAL_ENV}/lib/python${VN}/site-packages
270+
export BUILD_DIR=$(pwd)/build
271+
# NOTE: The pFUnit version (pinned during installation above) is used in the install path.
272+
export PFUNIT_DIR=$(pwd)/pFUnit/build/installed/PFUNIT-4.12
273+
mkdir ${BUILD_DIR}
274+
cd ${BUILD_DIR}
275+
276+
export FC=${{ matrix.FC }}
277+
export CC=${{ matrix.CC }}
278+
export CXX=${{ matrix.CXX }}
279+
export OPENMPI_DIR=$HOME/openmpi-${{ matrix.toolchain }}
280+
cmake .. \
281+
-DPython_EXECUTABLE="$(which python)" \
282+
-DCMAKE_BUILD_TYPE=Release \
283+
-DCMAKE_Fortran_COMPILER=${FC} \
284+
-DCMAKE_C_COMPILER=${CC} \
285+
-DCMAKE_CXX_COMPILER=${CXX} \
286+
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR} \
287+
-DCMAKE_BUILD_TESTS=TRUE \
288+
-DCMAKE_PREFIX_PATH="${OPENMPI_DIR};${PFUNIT_DIR};${Torch_DIR}" \
289+
-DCMAKE_Fortran_FLAGS="-stand ${{ matrix.std }}"
105290
cmake --build .
106291
cmake --install .
107292

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ For specific details see the [FTorch online documentation](https://cambridge-icc
1111

1212
### Added
1313

14+
- Intel-ifx and Intel-ifort CI and GCC v9-13 CI. Intel CI builds OpenMPI from source to accomodate MPI integration tests [#438](https://github.com/Cambridge-ICCS/FTorch/pull/438)
1415
- Expose tensor strides via `get_stride` method [#416](https://github.com/Cambridge-ICCS/FTorch/pull/416)
1516
- Remove `UNIX` preprocessor variable that selected the right C-integer type for 64bit int. Use `int64_t` instead [#416](https://github.com/Cambridge-ICCS/FTorch/pull/416)
1617
- A new cmake option `MULTI_GPU` to control the build of multi GPU integration tests in [#410](https://github.com/Cambridge-ICCS/FTorch/pull/410)

0 commit comments

Comments
 (0)