Skip to content

Commit c76b5ba

Browse files
authored
Merge pull request #5 from tjhei/lla-python-mpi-hello-tested
Add Python MPI Hello World example and test it
2 parents 8c76ce0 + afe6c55 commit c76b5ba

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

.github/workflows/linux.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,16 @@ jobs:
129129
with:
130130
submodules: recursive
131131
- uses: astral-sh/setup-uv@v6
132-
- name: setup
132+
- name: Python Setup
133133
run: |
134134
uv python install 3.12
135135
uv venv
136136
uv sync
137+
- name: Python Tests
138+
run: |
139+
. ./.venv/bin/activate
140+
cd cookbooks/landlab/
141+
./test.sh
137142
- name: compile
138143
run: |
139144
mkdir build
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from mpi4py import MPI
2+
3+
comm = MPI.COMM_WORLD
4+
rank = comm.Get_rank()
5+
size = comm.Get_size()
6+
7+
sum = comm.allreduce(rank, op=MPI.SUM)
8+
9+
if rank == 0:
10+
print(f"Hello World! I am process {rank} of {size}, sum = {sum}")
11+

cookbooks/landlab/test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# MPI hello world to see if mpi4py works
5+
6+
cd mpi-hello-world
7+
mpirun -n 2 python test.py
8+
cd ..

0 commit comments

Comments
 (0)