CI for Intel (ifx) and Intel Classic (ifort) each with OpenMPI (fixes #140) #667
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Workflow to run the FTorch test suite | |
name: TestSuiteUbuntu | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on pushes to the "main" branch, i.e., PR merges | |
push: | |
branches: [ "main" ] | |
# Triggers the workflow on pushes to open pull requests with code changes | |
pull_request: | |
paths: | |
- '.github/workflows/test_suite_ubuntu.yml' | |
- '**.c' | |
- '**.cpp' | |
- '**.fypp' | |
- '**.f90' | |
- '**.F90' | |
- '**.pf' | |
- '**.py' | |
- '**.sh' | |
- '**CMakeLists.txt' | |
- '**requirements.txt' | |
- '**data/*' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Cancel jobs running if new commits are pushed | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
# Workflow run - one or more jobs that can run sequentially or in parallel | |
jobs: | |
GNU: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
toolchain: | |
- {compiler: gcc, version: 13} | |
- {compiler: gcc, version: 12} | |
- {compiler: gcc, version: 11} | |
- {compiler: gcc, version: 10} | |
- {compiler: gcc, version: 9} | |
std: ["f2008"] | |
include: | |
# Run 2018 Fortran standards on latest gcc only | |
- toolchain: {compiler: gcc, version: 13} | |
std: "f2018" | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout code | |
with: | |
persist-credentials: false | |
uses: actions/checkout@v4 | |
- name: setup-fortran | |
uses: fortran-lang/setup-fortran@v1 | |
with: | |
compiler: ${{ matrix.toolchain.compiler }} | |
version: ${{ matrix.toolchain.version }} | |
- name: check-compilers-env | |
run: ${FC} | |
env: | |
FC: ${{ steps.setup-fortran.outputs.fc }} | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install PyTorch | |
run: | | |
python -m pip install --upgrade pip | |
python -m venv ftorch | |
. ftorch/bin/activate | |
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu | |
- name: Install OpenMPI | |
run: | | |
sudo apt update | |
sudo apt install -y openmpi-bin openmpi-common libopenmpi-dev | |
- name: Install pFUnit | |
run: | | |
export FC=/usr/bin/gfortran | |
export MPIF90=/usr/bin/mpif90 | |
# TODO: Avoid version pinning (needed because version appears in install path) | |
git clone -b v4.12.0 https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git | |
mkdir pFUnit/build | |
cd pFUnit/build | |
cmake .. | |
make -j 4 install | |
- name: Build FTorch | |
run: | | |
. ftorch/bin/activate | |
VN=$(python -c "import sys; print('.'.join(sys.version.split('.')[:2]))") | |
export Torch_DIR=${VIRTUAL_ENV}/lib/python${VN}/site-packages | |
export BUILD_DIR=$(pwd)/build | |
# NOTE: The pFUnit version (pinned during installation above) is used in the install path. | |
export PFUNIT_DIR=$(pwd)/pFUnit/build/installed/PFUNIT-4.12 | |
mkdir ${BUILD_DIR} | |
cd ${BUILD_DIR} | |
cmake .. \ | |
-DPython_EXECUTABLE="$(which python)" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_Fortran_COMPILER=${FC} \ | |
-DCMAKE_C_COMPILER=${CC} \ | |
-DCMAKE_CXX_COMPILER=${CXX} \ | |
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR} \ | |
-DCMAKE_BUILD_TESTS=TRUE \ | |
-DCMAKE_PREFIX_PATH="${PFUNIT_DIR};${Torch_DIR}" \ | |
-DCMAKE_Fortran_FLAGS="-std=${{ matrix.std }}" | |
cmake --build . | |
cmake --install . | |
- name: Run unit tests | |
run: | | |
. ftorch/bin/activate | |
cd build | |
ctest --verbose --tests-regex unit | |
- name: Run integration tests | |
run: | | |
. ftorch/bin/activate | |
cd build | |
ctest --verbose --tests-regex example | |
Intel: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
toolchain: [intel, intel-classic] | |
std: ["f08"] | |
CC: ["/opt/intel/oneapi/compiler/2023.2.0/linux/bin/icx"] | |
CXX: ["/opt/intel/oneapi/compiler/2023.2.0/linux/bin/icpx"] | |
include: | |
- toolchain: intel | |
FC: "/opt/intel/oneapi/compiler/2023.2.0/linux/bin/ifx" | |
- toolchain: intel-classic | |
FC: "/opt/intel/oneapi/compiler/2023.2.0/linux/bin/intel64/ifort" | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout code | |
with: | |
persist-credentials: false | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install PyTorch | |
run: | | |
python -m pip install --upgrade pip | |
python -m venv ftorch | |
. ftorch/bin/activate | |
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu | |
# NOTE: Based on github action logs, this installs ifx/ifort, | |
# icx/icc, and icpx/icpc for v2023.2.0 | |
# see https://www.intel.com/content/www/us/en/developer/articles/tool/compilers-redistributable-libraries-by-version.html | |
# TODO: This also installs intel oneapi mpi, which is not used in this | |
# workflow since the examples require openmpi (built with intel compilers) | |
- name: Install Intel classic and modern compilers | |
uses: fortran-lang/setup-fortran@v1 | |
id: setup-fortran | |
with: | |
compiler: intel-classic | |
version: '2021.10' | |
- name: Check Intel compiler paths | |
run: | | |
echo $(ls /opt/intel/oneapi/compiler/) | |
echo "ifx: $(which ifx)" | |
echo "icx: $(which icx)" | |
echo "icpx: $(which icpx)" | |
echo "ifort: $(which ifort)" | |
# TODO: Is this working? | |
- name: Cache OpenMPI | |
id: cache-openmpi | |
uses: actions/cache@v4 | |
with: | |
path: /home/runner/openmpi-${{ matrix.toolchain }} | |
key: openmpi-${{ runner.os }}-openmpi-4.1.2-${{ matrix.toolchain }} | |
- name: Build OpenMPI with Intel compilers | |
if: steps.cache-openmpi.outputs.cache-hit != 'true' | |
run: | | |
wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.2.tar.gz | |
tar -xzf openmpi-4.1.2.tar.gz | |
cd openmpi-4.1.2 | |
./configure \ | |
CC=${{ matrix.CC }} CXX=${{ matrix.CXX }} FC=${{ matrix.FC }} \ | |
--prefix=$HOME/openmpi-${{ matrix.toolchain }} | |
make -j 8 | |
make install | |
# TODO: Maybe redundant since you end up using prefix path anyways | |
# in cmake configs ?? | |
- name: Add OpenMPI to env | |
run: | | |
echo "PATH=$HOME/openmpi-${{ matrix.toolchain }}/bin:${PATH}" >> $GITHUB_ENV | |
echo "LD_LIBRARY_PATH=$HOME/openmpi-${{ matrix.toolchain }}/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV | |
- name: Inspect runner env variables | |
run: | | |
# entire env | |
echo "GITHUB_ENV: $GITHUB_ENV" | |
# libs | |
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" | |
# bins | |
echo "PATH: $PATH" | |
- name: Check OpenMPI installation | |
run: | | |
echo $(which mpicc) | |
mpicc --version | |
echo $(which mpif90) | |
mpif90 --version | |
echo $(which mpiexec) | |
mpiexec --version | |
- name: Install pFUnit | |
run: | | |
export FC=${{ matrix.FC }} | |
export CC=${{ matrix.CC }} | |
export CXX=${{ matrix.CXX }} | |
export MPIF90=mpif90 | |
export OPENMPI_DIR=$HOME/openmpi-${{ matrix.toolchain }} | |
# TODO: Avoid version pinning (needed because version appears in install path) | |
git clone -b v4.12.0 https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git | |
mkdir pFUnit/build | |
cd pFUnit/build | |
# TODO: is this prefix redundant?? | |
cmake .. -DCMAKE_PREFIX_PATH=${OPENMPI_DIR} | |
make -j 4 install | |
- name: Build FTorch | |
run: | | |
. ftorch/bin/activate | |
VN=$(python -c "import sys; print('.'.join(sys.version.split('.')[:2]))") | |
export Torch_DIR=${VIRTUAL_ENV}/lib/python${VN}/site-packages | |
export BUILD_DIR=$(pwd)/build | |
# NOTE: The pFUnit version (pinned during installation above) is used in the install path. | |
export PFUNIT_DIR=$(pwd)/pFUnit/build/installed/PFUNIT-4.12 | |
mkdir ${BUILD_DIR} | |
cd ${BUILD_DIR} | |
export FC=${{ matrix.FC }} | |
export CC=${{ matrix.CC }} | |
export CXX=${{ matrix.CXX }} | |
export OPENMPI_DIR=$HOME/openmpi-${{ matrix.toolchain }} | |
cmake .. \ | |
-DPython_EXECUTABLE="$(which python)" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_Fortran_COMPILER=${FC} \ | |
-DCMAKE_C_COMPILER=${CC} \ | |
-DCMAKE_CXX_COMPILER=${CXX} \ | |
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR} \ | |
-DCMAKE_BUILD_TESTS=TRUE \ | |
-DCMAKE_PREFIX_PATH="${OPENMPI_DIR};${PFUNIT_DIR};${Torch_DIR}" \ | |
-DCMAKE_Fortran_FLAGS="-stand ${{ matrix.std }}" | |
cmake --build . | |
cmake --install . | |
- name: Run unit tests | |
run: | | |
. ftorch/bin/activate | |
cd build | |
ctest --verbose --tests-regex unit | |
- name: Run integration tests | |
run: | | |
. ftorch/bin/activate | |
cd build | |
ctest --verbose --tests-regex example |