Skip to content
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
10 changes: 8 additions & 2 deletions .github/workflows/interop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
interop:
name: MPI interop (${{ matrix.mpi }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -42,8 +43,13 @@ jobs:
with:
version: "1"

- name: Install MPI.jl
run: julia -e 'using Pkg; Pkg.add("MPI")'
- name: Install and precompile MPI.jl
run: |
julia --project=tests/interop -e '
using Pkg
Pkg.instantiate()
Pkg.precompile()
'

- name: Run interop tests (mpi-sys-backend)
run: bash tests/interop/run_interop.sh --backend mpi-sys-backend
Expand Down
2 changes: 2 additions & 0 deletions tests/interop/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[deps]
MPI = "0da04de7-2f09-5096-9a64-0ad8f904c0c0"
91 changes: 44 additions & 47 deletions tests/interop/run_interop.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash
# Cross-language MPI interoperability test.
#
# Launches Rust, Python, and Julia MPI programs under a single mpiexec
# using MPMD (Multiple Program Multiple Data) mode, sharing MPI_COMM_WORLD.
# Verifies that Rust, Python (mpi4py), and Julia (MPI.jl) all work
# correctly with the same MPI implementation by running each language's
# MPI program under mpiexec -n 2.
#
# Prerequisites:
# - MPI implementation (MPICH or OpenMPI)
Expand Down Expand Up @@ -43,71 +44,67 @@ cargo build --manifest-path "$PROJECT_DIR/Cargo.toml" \
RUST_BIN="$PROJECT_DIR/target/debug/examples/interop_test"

# Check prerequisites
check_cmd() {
if ! command -v "$1" &>/dev/null; then
echo "SKIP: $1 not found"
return 1
fi
return 0
}

HAS_PYTHON=false
HAS_JULIA=false

if check_cmd python3; then
if python3 -c "import mpi4py" 2>/dev/null; then
HAS_PYTHON=true
else
echo "SKIP: mpi4py not installed (pip install mpi4py)"
fi
if command -v python3 &>/dev/null && python3 -c "import mpi4py" 2>/dev/null; then
HAS_PYTHON=true
else
echo "NOTE: mpi4py not available, Python tests will be skipped"
fi

if check_cmd julia; then
if julia -e 'using MPI' 2>/dev/null; then
HAS_JULIA=true
else
echo "SKIP: MPI.jl not installed (julia -e 'using Pkg; Pkg.add(\"MPI\")')"
fi
if command -v julia &>/dev/null && julia -e 'using MPI' 2>/dev/null; then
HAS_JULIA=true
else
echo "NOTE: MPI.jl not available, Julia tests will be skipped"
fi

# --- Test 1: Rust only (baseline) ---
echo ""
echo "--- Test 1: Rust-only MPI (2 ranks) ---"
mpiexec -n 2 "$RUST_BIN"
echo "PASSED"
FAILED=0

# --- Test 2: Rust + Python (MPMD) ---
if [ "$HAS_PYTHON" = true ]; then
echo ""
echo "--- Test 2: Rust + Python MPMD (2 ranks) ---"
mpiexec -n 1 "$RUST_BIN" : -n 1 python3 "$SCRIPT_DIR/test_mpi4py.py"
# --- Test 1: Rust MPI (2 ranks) ---
echo ""
echo "--- Test 1: Rust MPI (2 ranks) ---"
if mpiexec -n 2 "$RUST_BIN"; then
echo "PASSED"
else
echo ""
echo "--- Test 2: Rust + Python MPMD --- SKIPPED"
echo "FAILED"
FAILED=1
fi

# --- Test 3: Rust + Julia (MPMD) ---
if [ "$HAS_JULIA" = true ]; then
# --- Test 2: Python/mpi4py (2 ranks) ---
if [ "$HAS_PYTHON" = true ]; then
echo ""
echo "--- Test 3: Rust + Julia MPMD (2 ranks) ---"
mpiexec -n 1 "$RUST_BIN" : -n 1 julia "$SCRIPT_DIR/test_mpi_jl.jl"
echo "PASSED"
echo "--- Test 2: Python/mpi4py (2 ranks) ---"
if mpiexec -n 2 python3 "$SCRIPT_DIR/test_mpi4py.py"; then
echo "PASSED"
else
echo "FAILED"
FAILED=1
fi
else
echo ""
echo "--- Test 3: Rust + Julia MPMD --- SKIPPED"
echo "--- Test 2: Python/mpi4py --- SKIPPED"
fi

# --- Test 4: All three languages (MPMD) ---
if [ "$HAS_PYTHON" = true ] && [ "$HAS_JULIA" = true ]; then
# --- Test 3: Julia/MPI.jl (2 ranks) ---
if [ "$HAS_JULIA" = true ]; then
echo ""
echo "--- Test 4: Rust + Python + Julia MPMD (3 ranks) ---"
mpiexec -n 1 "$RUST_BIN" : -n 1 python3 "$SCRIPT_DIR/test_mpi4py.py" : -n 1 julia "$SCRIPT_DIR/test_mpi_jl.jl"
echo "PASSED"
echo "--- Test 3: Julia/MPI.jl (2 ranks) ---"
if timeout 300 mpiexec -n 2 julia --project="$SCRIPT_DIR" "$SCRIPT_DIR/test_mpi_jl.jl"; then
echo "PASSED"
else
echo "FAILED (or timed out after 300s)"
FAILED=1
fi
else
echo ""
echo "--- Test 4: Rust + Python + Julia MPMD --- SKIPPED"
echo "--- Test 3: Julia/MPI.jl --- SKIPPED"
fi

echo ""
echo "=== All interop tests completed ==="
if [ "$FAILED" -eq 0 ]; then
echo "=== All interop tests completed ==="
else
echo "=== Some interop tests FAILED ==="
exit 1
fi
Loading