Skip to content

Commit e0e0b7c

Browse files
committed
MPICH: Build with non-embedded internal libfabric
1 parent eaf7bc2 commit e0e0b7c

File tree

4 files changed

+68
-7
lines changed

4 files changed

+68
-7
lines changed

.github/workflows/cd-wheel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ jobs:
174174
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
175175
delocate-wheel
176176
--ignore-missing-dependencies
177-
--exclude libmpi --exclude libpmpi
177+
--exclude libmpi --exclude libpmpi --exclude libfabric
178178
--require-archs {delocate_archs}
179179
-w {dest_dir} -v {wheel}
180180

build-wheel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export CIBW_ARCHS=$ARCHLIST
1313
export CIBW_BEFORE_ALL='bash {project}/cibw-build-mpi.sh'
1414
export CIBW_TEST_COMMAND='bash {project}/cibw-check-mpi.sh'
1515
export CIBW_ENVIRONMENT_PASS='MPINAME RELEASE SOURCE WORKDIR DESTDIR'
16-
export CIBW_REPAIR_WHEEL_COMMAND_MACOS='delocate-wheel --ignore-missing-dependencies --exclude libmpi --exclude libpmpi --require-archs {delocate_archs -w {dest_dir} -v {wheel}'
16+
export CIBW_REPAIR_WHEEL_COMMAND_MACOS='delocate-wheel --ignore-missing-dependencies --exclude libmpi --exclude libpmpi --exclude libfabric --require-archs {delocate_archs -w {dest_dir} -v {wheel}'
1717

1818
if test "$(uname)" = Linux; then
1919
containerengine=$(basename "$(command -v podman || command -v docker)")

check-wheel.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ if test "$(uname)" = Linux; then
2929
libsdir=.libs
3030
print-runpath() { patchelf --print-rpath "$1"; }
3131
print-needed() { patchelf --print-needed "$1"; }
32+
if test -f "$data"/lib/libfabric.so; then
33+
runlibs=$runlibs'|libfabric'$soregex
34+
fi
3235
if test -f "$data"/lib/libucp.so; then
3336
runlibs=$runlibs'|libuc(m|p|s|t)'$soregex
3437
fi
@@ -41,6 +44,9 @@ if test "$(uname)" = Darwin; then
4144
libsdir=.dylibs
4245
print-runpath() { otool -l "$1" | sed -n '/RPATH/{n;n;p;}'; }
4346
print-needed() { otool -L "$1" | sed 1,1d; }
47+
if test -f "$data"/lib/libfabric.dylib; then
48+
runlibs=$runlibs'|libfabric'$soregex
49+
fi
4450
if test -f "$data"/lib/libucp.dylib; then
4551
runlibs=$runlibs'|libuc(m|p|s|t)'$soregex
4652
fi
@@ -67,6 +73,11 @@ if test "$mpiname" = "mpich"; then
6773
libraries=(
6874
"$data"/lib/libmpi.*
6975
)
76+
if ls "$data"/lib/libfabric.* > /dev/null 2>&1; then
77+
libraries+=(
78+
"$data"/lib/libfabric.*
79+
)
80+
fi
7081
if test -d "$data"/lib/ucx; then
7182
libraries+=(
7283
"$data"/lib/libuc[mpst]*.*

cibw-build-mpi.sh

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,29 @@ case $(uname) in
8282
Darwin) njobs=$(sysctl -n hw.physicalcpu);;
8383
esac
8484

85-
mkdir -p "$WORKDIR"
86-
cd "$WORKDIR"
85+
if test "$mpiname" = "mpich"; then
86+
mkdir -p "$WORKDIR"/libfabric && cd "$WORKDIR"/libfabric
87+
echo running configure on libfabric
88+
"$SOURCE"/modules/libfabric/configure --prefix="$PREFIX"
89+
echo running make with "${njobs:-1}" jobs on libfabric
90+
make -j "${njobs:-1}" install DESTDIR="$DESTDIR"
91+
withofi=--with-libfabric="${DESTDIR}${PREFIX}"
92+
options=("${options[@]/--with-libfabric=embedded/$withofi}")
93+
destdirfixfiles+=(src/include/mpichinfo.h)
94+
destdirfixfiles+=(src/pm/hydra/hydra_config.h)
95+
fi
96+
97+
mkdir -p "$WORKDIR" && cd "$WORKDIR"
8798

8899
echo running configure
89100
"$SOURCE"/configure "${options[@]}" || cat config.log
90101

102+
for hdr in "${destdirfixfiles[@]-}"; do
103+
test -n "$hdr" || break
104+
echo removing DESTDIR from "$hdr"
105+
sed -i.orig "s|$DESTDIR||g" "$hdr"
106+
done
107+
91108
echo running make with "${njobs:-1}" jobs
92109
make -j "${njobs:-1}" install DESTDIR="$DESTDIR"
93110

@@ -97,7 +114,6 @@ cd "${DESTDIR}${PREFIX}"
97114
rm -f include/*cxx.h
98115
rm -f include/*.mod
99116
rm -f include/*f.h
100-
rm -fr include/rdma
101117
rm -f bin/mpif77
102118
rm -f bin/mpif90
103119
rm -f bin/mpifort
@@ -112,6 +128,12 @@ rm -f lib/lib*mpifort.*
112128
rm -fr lib/pkgconfig
113129
rm -fr share
114130

131+
cd "${DESTDIR}${PREFIX}"
132+
rm -fr include/rdma
133+
rm -f bin/fi_*
134+
rm -f lib/libfabric.a
135+
rm -f lib/libfabric.la
136+
115137
cd "${DESTDIR}${PREFIX}"
116138
rm -f bin/io_demo
117139
rm -f bin/ucx_read_profile
@@ -153,6 +175,19 @@ if test "$(uname)" = Linux; then
153175
mv "$(readlink "$libmpi")" "$libmpi"
154176
ln -sf "$libmpi" "${libmpi%.*}"
155177
fi
178+
if test -f libfabric.so; then
179+
patchelf --set-rpath "\$ORIGIN" "$libmpi"
180+
for lib in libfabric.so.?; do
181+
if test -f "$lib".*.*; then
182+
mv "$(readlink "$lib")" "$lib"
183+
ln -sf "$lib" "${lib%.*}"
184+
fi
185+
patchelf --set-rpath "\$ORIGIN" "$lib"
186+
for exe in "${executables[@]}"; do
187+
patchelf --remove-needed "$lib" "../bin/$exe"
188+
done
189+
done
190+
fi
156191
if test -f libucp.so; then
157192
patchelf --set-rpath "\$ORIGIN" "$libmpi"
158193
for lib in libuc[mpst]*.so.?; do
@@ -182,16 +217,31 @@ if test "$(uname)" = Darwin; then
182217
libpmpi="libpmpi.12.dylib"
183218
cd "${DESTDIR}${PREFIX}/bin"
184219
for exe in "${executables[@]}"; do
185-
install_name_tool -change "$libdir/$libmpi" "@rpath/$libmpi" "$exe"
186-
install_name_tool -change "$libdir/$libpmpi" "@rpath/$libpmpi" "$exe"
187220
install_name_tool -add_rpath "@executable_path/../lib/" "$exe"
221+
for lib in "$libmpi" "$libpmpi"; do
222+
install_name_tool -change "$libdir/$lib" "@rpath/$lib" "$exe"
223+
done
188224
done
189225
cd "${DESTDIR}${PREFIX}/lib"
190226
for lib in "$libmpi" "$libpmpi"; do
191227
install_name_tool -id "@rpath/$lib" "$lib"
192228
install_name_tool -add_rpath "@loader_path/" "$lib"
193229
done
194230
install_name_tool -change "$libdir/$libpmpi" "@rpath/$libpmpi" "$libmpi"
231+
libfabric="libfabric.1.dylib"
232+
if test -f "$libfabric"; then
233+
install_name_tool -id "@rpath/$libfabric" "$libfabric"
234+
install_name_tool -add_rpath "@loader_path/" "$libfabric"
235+
oldname="$libdir/$libfabric"; newname="@rpath/$libfabric";
236+
cd "${DESTDIR}${PREFIX}/bin"
237+
for exe in "${executables[@]}"; do
238+
install_name_tool -change "$oldname" "$newname" "$exe"
239+
done
240+
cd "${DESTDIR}${PREFIX}/lib"
241+
for lib in "$libmpi" "$libpmpi"; do
242+
install_name_tool -change "$oldname" "$newname" "$lib"
243+
done
244+
fi
195245
fi
196246

197247
} # fixup-mpich()

0 commit comments

Comments
 (0)