#!/bin/bash

# testing on 5 processes is recommended by upstream where possible
# and is safe to oversubscribe with OpenMPI
# but oversubscribing might be a problem (runs slow) with mpich
# 32-bit arm is fine, but there are problems with i386

DEB_HOST_ARCH=`dpkg-architecture -qDEB_HOST_ARCH`

nproc=`nproc`
MIN_PROC=$(( nproc > 2 ? nproc : 2 ))
NUM_PROC=$(( MIN_PROC > 5 ? 5 : MIN_PROC ))

echo -e "nproc reports ${nproc} processing units available (using ${NUM_PROC})\n"

for pyver in `py3versions -vs`; do 
  OMPI_MCA_rmaps_base_oversubscribe=yes \
  GITHUB_ACTIONS=true MPI4PY_TEST_SPAWN=false \
  mpiexec -v -n $NUM_PROC python$pyver test/runtests.py --verbose
done
