Skip to content

CI: MPICH on CI #36

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

Merged
merged 11 commits into from
Mar 25, 2025
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
134 changes: 118 additions & 16 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ env:
MACOSX_DEPLOYMENT_TARGET: 14.0

jobs:
Run_standalone_tests_with_GFortran:
name: "Run standalone tests with GFortran"
Run_standalone_tests_with_GFortran_with_OpenMPI:
name: "Run standalone tests with GFortran with Open MPI"
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -25,17 +25,17 @@ jobs:
uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_gfortran.yml
environment-file: ci/environment_gfortran_openmpi.yml

- name: Run standalone tests with GFortran with and without optimization
- name: Run standalone tests with GFortran with and without optimization using Open MPI
shell: bash -e -x -l {0}
run: |
cd tests
FC="gfortran" ./run_tests.sh
FC="gfortran -O3 -march=native" ./run_tests.sh

Run_standalone_tests_with_LFortran:
name: "Run standalone tests with LFortran"
Run_standalone_tests_with_GFortran_with_MPICH:
name: "Run standalone tests with GFortran with MPICH"
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -47,17 +47,119 @@ jobs:
uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_lfortran.yml
environment-file: ci/environment_gfortran_mpich.yml

- name: Run standalone tests with LFortran with and without optimization
- name: Run standalone tests with GFortran with and without optimization using MPICH
shell: bash -e -x -l {0}
run: |
cd tests
FC="gfortran" ./run_tests.sh
FC="gfortran -O3 -march=native" ./run_tests.sh

Run_standalone_tests_with_LFortran_with_OpenMPI:
name: "Run standalone tests with LFortran with Open MPI"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["macos-latest", "ubuntu-20.04"]
steps:
- uses: actions/checkout@v4

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_lfortran_openmpi.yml

- name: Run standalone tests with LFortran with and without optimization using Open MPI
shell: bash -e -x -l {0}
run: |
cd tests
FC="lfortran" ./run_tests.sh
FC="lfortran --fast" ./run_tests.sh

Run_standalone_tests_with_LFortran_with_MPICH:
name: "Run standalone tests with LFortran with MPICH"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["macos-latest", "ubuntu-20.04"]
steps:
- uses: actions/checkout@v4

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_lfortran_mpich.yml

- name: Run standalone tests with LFortran with and without optimization using MPICH
shell: bash -e -x -l {0}
run: |
cd tests
FC="lfortran" ./run_tests.sh
FC="lfortran --fast" ./run_tests.sh

Compile_POT3D_with_GFortran:
name: "Build POT3D and validate with GFortran"
Compile_POT3D_with_GFortran_with_OpenMPI:
name: "Build POT3D and validate with GFortran with Open MPI"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["macos-latest", "ubuntu-20.04"]
steps:
- uses: actions/checkout@v4

- name: Set up Micromamba
uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_gfortran_openmpi.yml

# build and validation with GFortran's optimization
- name: POT3D Build and validation with GFortran with optimization using Open MPI (MPI only)
shell: bash -e -x -l {0}
run: |
cd tests/pot3d
FC="gfortran -O3 -march=native" ./build_and_run_gfortran.sh

# build and validation without GFortran's optimization
- name: POT3D Build and validation with GFortran without optimization using Open MPI (MPI only)
shell: bash -e -x -l {0}
run: |
cd tests/pot3d
FC="gfortran" ./build_and_run_gfortran.sh

Compile_POT3D_with_LFortran_with_OpenMPI:
name: "Build POT3D and validate with LFortran with Open MPI"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["macos-latest", "ubuntu-20.04"]
steps:
- uses: actions/checkout@v4

- name: Set up Micromamba
uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_lfortran_openmpi.yml

# build and validation with LFortran's optimization
- name: POT3D Build and validation with LFortran with optimization using Open MPI (MPI only)
shell: bash -e -x -l {0}
run: |
cd tests/pot3d
FC="lfortran --fast" ./build_and_run_lfortran.sh

# build and validation without LFortran's optimization
- name: POT3D Build and validation with LFortran without optimization using Open MPI (MPI only)
shell: bash -e -x -l {0}
run: |
cd tests/pot3d
FC="lfortran" ./build_and_run_lfortran.sh

Compile_POT3D_with_GFortran_with_MPICH:
name: "Build POT3D and validate with GFortran with MPICH"
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -69,7 +171,7 @@ jobs:
uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_gfortran.yml
environment-file: ci/environment_gfortran_mpich.yml

# build and validation with GFortran's optimization
- name: POT3D Build and validation with GFortran with optimization (MPI only)
Expand All @@ -85,8 +187,8 @@ jobs:
cd tests/pot3d
FC="gfortran" ./build_and_run_gfortran.sh

Compile_POT3D_with_LFortran:
name: "Build POT3D and validate with LFortran"
Compile_POT3D_with_LFortran_with_MPICH:
name: "Build POT3D and validate with LFortran with MPICH"
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -98,17 +200,17 @@ jobs:
uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_lfortran.yml
environment-file: ci/environment_lfortran_mpich.yml

# build and validation with LFortran's optimization
- name: POT3D Build and validation with LFortran with optimization (MPI only)
- name: POT3D Build and validation with LFortran with optimization using MPICH (MPI only)
shell: bash -e -x -l {0}
run: |
cd tests/pot3d
FC="lfortran --fast" ./build_and_run_lfortran.sh

# build and validation without LFortran's optimization
- name: POT3D Build and validation with LFortran without optimization (MPI only)
- name: POT3D Build and validation with LFortran without optimization using MPICH (MPI only)
shell: bash -e -x -l {0}
run: |
cd tests/pot3d
Expand Down
7 changes: 7 additions & 0 deletions ci/environment_gfortran_mpich.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: c_mpich_gfortran_env
channels:
- conda-forge
dependencies:
# GFortran version 14 isn't available on conda for macOS atleast
- gfortran=13.2.0
- mpich=4.3.0
File renamed without changes.
8 changes: 8 additions & 0 deletions ci/environment_lfortran_mpich.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: c_mpich_lfortran_env
channels:
- conda-forge
dependencies:
- lfortran=0.49.0
- make
- cmake
- mpich=4.3.0
File renamed without changes.
12 changes: 6 additions & 6 deletions src/mpi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ module mpi
integer, parameter :: MPI_PROC_NULL = -1
integer, parameter :: MPI_SUCCESS = 0

integer, parameter :: MPI_COMM_WORLD = 0
integer, parameter :: MPI_COMM_WORLD = -1000
real(8), parameter :: MPI_IN_PLACE = -1
integer, parameter :: MPI_SUM = 1
integer, parameter :: MPI_INFO_NULL = 0
integer, parameter :: MPI_INFO_NULL = -2000
integer :: MPI_STATUS_IGNORE = 0
! NOTE: I've no idea for how to implement this, refer
! see section 2.5.4 page 21 of mpi40-report.pdf
Expand Down Expand Up @@ -141,16 +141,16 @@ subroutine MPI_Init_thread_proc(required, provided, ierr)
type(c_ptr) :: argv = c_null_ptr
integer(c_int) :: c_required
integer(c_int) :: c_provided

! Map Fortran MPI_THREAD_FUNNELED to C MPI_THREAD_FUNNELED if needed
c_required = int(required, c_int)

! Call C MPI_Init_thread directly
local_ierr = c_mpi_init_thread(argc, argv, required, provided)

! Copy output values back to Fortran
provided = int(c_provided)

if (present(ierr)) then
ierr = int(local_ierr)
else if (local_ierr /= 0) then
Expand Down
Loading