Skip to content

Commit

Permalink
Support for OFI and UCX
Browse files Browse the repository at this point in the history
* MPICH: Configure --with-device=ch4:ofi,ucx
* Open MPI: Configure --with-ofi --with-ucx
* Reproducible builds
* Strip binaries to reduce size
* Remove unneeded binaries
* Package various licenses
  • Loading branch information
dalcinl committed Nov 13, 2024
1 parent eaf7bc2 commit 696ccc4
Show file tree
Hide file tree
Showing 13 changed files with 703 additions and 120 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/cd-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
shell: python
name: 'setup build matrix'
run: |
# setup build matrix # "
keys = ("os", "arch", "runner")
rows = [
("Linux", "aarch64", "ubuntu-22.04"),
Expand All @@ -93,6 +94,7 @@ jobs:
import os, json
with open(os.getenv("GITHUB_OUTPUT"), "w") as out:
print(f"matrix={json.dumps(matrix)}", file=out)
# "
build:
needs: setup
Expand All @@ -117,12 +119,12 @@ jobs:
cd $(brew --prefix)/bin
gfortran=$(ls gfortran-* | sort | head -n 1)
sudo ln -s $gfortran gfortran
# unlink libevent
brew unlink libevent || true
# install autotools
brew install autoconf
brew install automake
brew install libtool
# unlink libevent
brew unlink libevent || true
# install uv
brew install uv
Expand All @@ -142,9 +144,13 @@ jobs:

- id: source-date-epoch
run: |
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
read -r SOURCE_DATE_EPOCH < source-date-epoch || true
SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-$(git log -1 --pretty=%ct)}
echo SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH >> $GITHUB_ENV
echo $(git log -1 --pretty=%ci) [timestamp=$SOURCE_DATE_EPOCH]
echo [SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH] $(
date -u -d @$SOURCE_DATE_EPOCH 2>/dev/null ||
date -u -r $SOURCE_DATE_EPOCH 2>/dev/null )
working-directory: package/source

- id: build
uses: pypa/[email protected]
Expand Down Expand Up @@ -190,7 +196,9 @@ jobs:
- id: upload
uses: actions/upload-artifact@v4
with:
name: wheel-${{ inputs.mpiname }}-${{ matrix.os }}-${{ matrix.arch }}
name: "wheel-${{ inputs.mpiname }}-\
${{ inputs.version || 'latest' }}-\
${{ matrix.os }}-${{ matrix.arch }}"
path: wheelhouse/*.whl

- id: check
Expand Down
24 changes: 22 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,32 @@ on: # yamllint disable-line rule:truthy

jobs:

mpich:
mpich-42:
uses: ./.github/workflows/cd-wheel.yml
with:
mpiname: mpich
version:

openmpi:
mpich-41:
uses: ./.github/workflows/cd-wheel.yml
with:
mpiname: mpich
version: 4.1.3

mpich-34:
uses: ./.github/workflows/cd-wheel.yml
with:
mpiname: mpich
version: 3.4.3

openmpi-50:
uses: ./.github/workflows/cd-wheel.yml
with:
mpiname: openmpi
version:

openmpi-41:
uses: ./.github/workflows/cd-wheel.yml
with:
mpiname: openmpi
version: 4.1.6
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/venv/
*.egg-info/
*.tar.gz
*.tar.bz2
*~
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ lint:
yamllint .github/

clean:
$(RM) -r package/METADATA
$(RM) -r package/LICENSE*
$(RM) -r package/build
$(RM) -r package/LICENSE
$(RM) -r package/install
$(RM) -r package/source
$(RM) -r package/workdir
$(RM) -r package/install
$(RM) -r package/*.egg-info
$(RM) -r .*_cache
151 changes: 144 additions & 7 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ case "$mpiname" in
esac
version=${VERSION:-$version}

ucxversion=1.17.0
ofiversion=1.22.0
ucxversion=${UCXVERSION:-$ucxversion}
ofiversion=${OFIVERSION:-$ofiversion}

PROJECT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
PACKAGE=$PROJECT/package
SOURCE=$PACKAGE/source
Expand All @@ -27,28 +32,160 @@ fi
if test ! -d "$SOURCE"; then
if test ! -f "$tarball"; then
echo downloading "$urlbase"/"$tarball"...
curl -fsO "$urlbase"/"$tarball"
curl -fsSLO "$urlbase"/"$tarball"
else
echo reusing "$tarball"...
fi
echo extracting "$tarball" to "$SOURCE"...
echo extracting "$tarball"...
tar xf "$tarball"
mv "$mpiname-$version" "$SOURCE"
patch="$PROJECT/patches/$mpiname-$version"
if test -f "$patch"; then
patch -p1 -i "$patch" -d "$SOURCE"
fi
if test "$mpiname-$(uname)" = "openmpi-Darwin"; then
if test -d "$SOURCE"/3rd-party; then
cd "$SOURCE"/3rd-party
tar xf libevent-*.tar.gz && cd libevent-*
if test "$mpiname" = "mpich"; then
if test "${version}" \< "4.2.0"; then
disable_doc='s/^\(install-data-local:\s\+\)\$/\1#\$/'
Makefile="$SOURCE"/Makefile.in
sed -i.orig "$disable_doc" "$Makefile"
fi
fi
if test "$mpiname" = "openmpi"; then
for deptarball in "$SOURCE"/3rd-party/*.tar.*; do
test -f "$deptarball" || continue
echo extracting "$(basename "$deptarball")"
tar xf "$deptarball" -C "$(dirname "$deptarball")"
done
makefiles=(
"$SOURCE"/3rd-party/openpmix/src/util/keyval/Makefile.in
"$SOURCE"/3rd-party/prrte/src/mca/rmaps/rank_file/Makefile.in
"$SOURCE"/3rd-party/prrte/src/util/hostfile/Makefile.in
)
for makefile in "${makefiles[@]}"; do
test -f "$makefile" || continue
echo "PMIX_CFLAGS_BEFORE_PICKY = @CFLAGS@" >> "$makefile"
echo "PRTE_CFLAGS_BEFORE_PICKY = @CFLAGS@" >> "$makefile"
done
fi
if test "$mpiname" = "openmpi" && test "${version}" \< "5.0.5"; then
if test "$(uname)" = "Darwin" && test -d "$SOURCE"/3rd-party; then
cd "$SOURCE"/3rd-party/libevent-*
echo running autogen.sh on "$(basename "$(pwd)")"
./autogen.sh
cd "$PROJECT"
fi
fi
else
echo reusing directory "$SOURCE"...
check() { test "$(awk "/$1/"'{print $2}' "$PACKAGE/METADATA")" = "$2"; }
check Name "$mpiname" || (echo not "$mpiname-$version"!!! && exit 1)
check Version "$version" || (echo not "$mpiname-$version"!!! && exit 1)
fi

if test "$(uname)" = "Linux"; then
case "$mpiname" in
mpich) MODSOURCE="$SOURCE"/modules ;;
openmpi) MODSOURCE="$SOURCE"/3rd-party ;;
esac
ofigithub="https://github.com/ofiwg/libfabric"
ofiurlbase="$ofigithub/releases/download/v$ofiversion"
ofitarball="libfabric-$ofiversion.tar.bz2"
ofidestdir="$MODSOURCE"/"${ofitarball%%.tar.*}"
if test ! -d "$ofidestdir"; then
if test ! -f "$ofitarball"; then
echo downloading "$ofiurlbase"/"$ofitarball"...
curl -fsSLO "$ofiurlbase"/"$ofitarball"
else
echo reusing "$ofitarball"...
fi
echo extracting "$ofitarball"...
tar xf "$ofitarball"
mkdir -p "$(dirname "$ofidestdir")"
mv "$(basename "$ofidestdir")" "$ofidestdir"
else
echo reusing directory "$ofidestdir"...
fi
ucxgithub="https://github.com/openucx/ucx"
ucxurlbase="$ucxgithub/releases/download/v$ucxversion"
ucxtarball="ucx-$ucxversion.tar.gz"
ucxdestdir="$MODSOURCE"/"${ucxtarball%%.tar.*}"
if test ! -d "$ucxdestdir"; then
if test ! -f "$ucxtarball"; then
echo downloading "$ucxurlbase"/"$ucxtarball"...
curl -fsSLO "$ucxurlbase"/"$ucxtarball"
else
echo reusing "$ucxtarball"...
fi
echo extracting "$ucxtarball"...
tar xf "$ucxtarball"
mkdir -p "$(dirname "$ucxdestdir")"
mv "$(basename "$ucxdestdir")" "$ucxdestdir"
if test "${ucxversion}" \< "1.17.1"; then
cmd='s/\(#include <limits.h>\)/\1\n#include <math.h>/'
sed -i.orig "$cmd" "$ucxdestdir/src/ucs/time/time.h"
fi
else
echo reusing directory "$ucxdestdir"...
fi
fi
echo copying license file...

if test "$mpiname" = "mpich"; then
mpidate=$(sed -nE "s/MPICH_RELEASE_DATE=\"(.*)\"/\1/p" "$SOURCE/configure")
fi
if test "$mpiname" = "openmpi"; then
mpidate=$(sed -nE "s/date=\"(.*)\"/\1/p" "$SOURCE/VERSION")
fi
if test -n "${mpidate+x}"; then
case "$(uname)" in
Linux)
timestamp=$(date -d "$mpidate" "+%s")
;;
Darwin)
datefmt="%b %d, %Y %T%z"
if test "$mpiname" = "mpich"; then
mpidate=$(awk '{$3=$3",";print $2,$3,$NF}' <<< "$mpidate")
fi
timestamp=$(date -j -f "$datefmt" "$mpidate 12:00:00+0000" "+%s")
;;
esac
echo writing source-date-epoch ...
echo "$timestamp" > "$SOURCE/source-date-epoch"
fi

echo writing package metadata ...
echo "Name: $mpiname" > "$PACKAGE/METADATA"
echo "Version: $version" >> "$PACKAGE/METADATA"

echo copying MPI license file...
cp "$SOURCE"/"$license" "$PACKAGE/LICENSE"
if test -n "${ofidestdir+x}"; then
echo copying OFI license file...
cp "$ofidestdir/COPYING" "$PACKAGE/LICENSE.ofi"
fi
if test -n "${ucxdestdir+x}"; then
echo copying UCX license file...
cp "$ucxdestdir/LICENSE" "$PACKAGE/LICENSE.ucx"
fi
if test "$mpiname" = "mpich"; then
licenses=(
"$SOURCE"/modules/hwloc/COPYING
"$SOURCE"/modules/json-c/COPYING
"$SOURCE"/modules/yaksa/COPYRIGHT
)
fi
if test "$mpiname" = "openmpi"; then
licenses=(
"$SOURCE"/3rd-party/hwloc-*/COPYING
"$SOURCE"/3rd-party/libevent-*/LICENSE
"$SOURCE"/3rd-party/openpmix/LICENSE
"$SOURCE"/3rd-party/prrte/LICENSE
"$SOURCE"/3rd-party/treematch/COPYING
)
fi
for license in "${licenses[@]}"; do
test -f "$license" || continue
module=$(basename "$(dirname "$license")")
module="${module%%-[0-9]*}"
echo copying "$module" license file...
cp "$license" "$PACKAGE/LICENSE.$module"
done
9 changes: 6 additions & 3 deletions build-wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ WORKDIR=package/workdir
DESTDIR=package/install
ARCHLIST=${ARCHLIST:-$(uname -m)}

read -r SOURCE_DATE_EPOCH < "$SOURCE"/source-date-epoch
export SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH

export CIBW_BUILD_FRONTEND='build'
export CIBW_BUILD='cp313-*'
export CIBW_SKIP='*musllinux*'
Expand All @@ -19,8 +22,8 @@ if test "$(uname)" = Linux; then
containerengine=$(basename "$(command -v podman || command -v docker)")
export CIBW_CONTAINER_ENGINE=$containerengine
export SOURCE="/project/$SOURCE"
export WORKDIR="/host/$PWD/$WORKDIR"
export DESTDIR="/host/$PWD/$DESTDIR"
export WORKDIR="/host$PWD/$WORKDIR"
export DESTDIR="/host$PWD/$DESTDIR"
platform=linux
fi
if test "$(uname)" = Darwin; then
Expand All @@ -31,7 +34,7 @@ if test "$(uname)" = Darwin; then
platform=macos
fi

python -m pipx run \
pipx run \
cibuildwheel \
--platform "$platform" \
--output-dir "${1:-dist}" \
Expand Down
Loading

0 comments on commit 696ccc4

Please sign in to comment.