forked from conda-forge/openmpi-feedstock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-mpi.sh
executable file
·112 lines (100 loc) · 3.75 KB
/
build-mpi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
set -ex
# avoid absolute-paths in compilers
export CC=$(basename "$CC")
export CXX=$(basename "$CXX")
export FC=$(basename "$FC")
# unset unused Fortran compiler variables
unset FFLAGS F77 F90 F95
# tweak compiler flags
export LIBRARY_PATH="$PREFIX/lib"
if [[ "$target_platform" == osx-* ]]; then
# FIXME: remove autogen when autotools patch no longer required
perl autogen.pl --force
if [[ -n "$CONDA_BUILD_SYSROOT" ]]; then
export CFLAGS="$CFLAGS -isysroot $CONDA_BUILD_SYSROOT"
export CXXFLAGS="$CXXFLAGS -isysroot $CONDA_BUILD_SYSROOT"
fi
fi
# tweak wrapper ldflags
wrapper_ldflags=""
if [[ "$target_platform" == linux-* ]]; then
# allow-shlib-undefined required for dependencies to link against older sysroot
# avoids undefined
wrapper_ldflags='-Wl,--allow-shlib-undefined'
fi
if [[ "$target_platform" == osx-* ]]; then
# rpath required for '@rpath/libmpi.*.dylib' to be found at runtime
wrapper_ldflags='-Wl,-rpath,${libdir}'
fi
# UCX support
build_with_ucx=""
if [[ "$target_platform" == linux-* ]]; then
build_with_ucx="--with-ucx=$PREFIX"
fi
# CUDA support
build_with_cuda=""
if [[ -n "$CUDA_HOME" ]]; then
build_with_cuda="--with-cuda=$CUDA_HOME --with-cuda-libdir=$CUDA_HOME/lib64/stubs"
fi
if [[ $CONDA_BUILD_CROSS_COMPILATION == "1" ]]; then
#
# To regenerate the `cross-gfortran.*.sh` files follow these steps:
#
# * Create and activate a conda environment with `gcc=X.Y gfortran`
# packages and any other package required to configure openmpi.
# $ conda create -n ompi-config gcc=X.Y gfortran
# $ conda activate ompi-config
#
# * Run openmpi's `./configure` script
# $ tar -xf openmpi-X.Y.Z.tar.bz2
# $ cd openmpi-X.Y.Z
# $ ./configure
#
# * Use `grep` to get configure variables out of `config.log`:
# $ grep ompi_cv_fortran_ config.log | sed 's/^/export /' >> cross-gfortran.$target_arch.sh
# $ grep ompi_cv_real16_ config.log | sed 's/^/export /' >> cross-gfortran.$target_arch.sh
#
source $RECIPE_DIR/cross-gfortran.$target_platform.sh
fi
# disable wrapper-runpath for consistency with conda-forge wrt dtags
# openmpi's runpath adds new dtags to compiler wrappers
./configure --prefix=$PREFIX \
--disable-dependency-tracking \
--disable-wrapper-runpath \
--enable-mpi-fortran \
--with-mpi-moduledir='${includedir}' \
--with-wrapper-ldflags="${wrapper_ldflags}" \
--with-sge \
--with-hwloc=$PREFIX \
--with-libevent=$PREFIX \
--with-zlib=$PREFIX \
--enable-mca-dso \
--enable-ipv6 \
$build_with_ucx \
$build_with_cuda \
|| (cat config.log; false)
make -j"${CPU_COUNT:-1}"
make install
POST_LINK=$PREFIX/bin/.openmpi-post-link.sh
if [ -n "$build_with_ucx" ]; then
echo "setting MCA pml to ^ucx..."
echo "pml = ^ucx" >> $PREFIX/etc/openmpi-mca-params.conf
echo "setting MCA osc to ^ucx..."
echo "osc = ^ucx" >> $PREFIX/etc/openmpi-mca-params.conf
cat $RECIPE_DIR/post-link-ucx.sh >> $POST_LINK
fi
if [ -n "$build_with_cuda" ]; then
echo "setting MCA mca_base_component_show_load_errors to 0..."
echo "mca_base_component_show_load_errors = 0" >> $PREFIX/etc/openmpi-mca-params.conf
echo "setting MCA opal_warn_on_missing_libcuda to 0..."
echo "opal_warn_on_missing_libcuda = 0" >> $PREFIX/etc/openmpi-mca-params.conf
echo "setting MCA opal_cuda_support to 0..."
echo "opal_cuda_support = 0" >> $PREFIX/etc/openmpi-mca-params.conf
cat $RECIPE_DIR/post-link-cuda.sh >> $POST_LINK
fi
if [ -f $POST_LINK ]; then
chmod +x $POST_LINK
fi
mkdir -p $PREFIX/etc/conda/activate.d
cp -v $RECIPE_DIR/openmpi_activate.sh $PREFIX/etc/conda/activate.d/