Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Fortran setup in workflows to access multiple compilers. #164

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
123 changes: 123 additions & 0 deletions .github/workflows/test_suite_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Workflow to run the FTorch test suite
name: TestSuiteMacOS

# 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_macos.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:
# This workflow contains a single job called "test-suite-macos"
test-suite-macos:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Newest possible gcc on macos-latest (arm64)
- os: macos-latest
toolchain: {compiler: gcc, version: 13}
# Oldest possible gcc on macos-latest (arm64)
- os: macos-latest
toolchain: {compiler: gcc, version: 11}
# Newest possible gcc on macos (x86)
- os: macos-15
toolchain: {compiler: gcc, version: 13}
- os: macos-13
toolchain: {compiler: gcc, version: 13}
# Newest possible intel-classic on macos
- os: macos-15
toolchain: {compiler: intel-classic, version: '2021.10'}
- os: macos-14
toolchain: {compiler: intel-classic, version: '2021.10'}
- os: macos-13
toolchain: {compiler: intel-classic, version: '2021.10'}
# Newest possible lfortran on macos
- os: macos-15
toolchain: {compiler: lfortran, version: '0.33.0'}
- os: macos-14
toolchain: {compiler: lfortran, version: '0.33.0'}
- os: macos-13
toolchain: {compiler: lfortran, version: '0.33.0'}

# 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.11'

- 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: 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)/src/build
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
cmake --build .
cmake --install .

- name: Integration tests
run: |
. ftorch/bin/activate
./run_integration_tests.sh -V
32 changes: 30 additions & 2 deletions .github/workflows/test_suite_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,21 @@ jobs:
strategy:
fail-fast: false
matrix:
std: ["f2008", "f2018"]
toolchain:
- {compiler: gcc, version: 13}
- {compiler: gcc, version: 12}
- {compiler: gcc, version: 11}
- {compiler: gcc, version: 10}
- {compiler: gcc, version: 9}
- {compiler: intel, version: '2024.1'}
- {compiler: intel-classic, version: '2021.10'}
- {compiler: lfortran, version: '0.33.0'}
- {compiler: nvidia-hpc, version: '23.11'}
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:
Expand All @@ -50,10 +64,21 @@ jobs:
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'
python-version: '3.11'

- name: Install PyTorch
run: |
Expand All @@ -73,6 +98,9 @@ jobs:
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_Fortran_FLAGS="-std=${{matrix.std}}"
Expand Down
Loading