Skip to content

Commit 8540c16

Browse files
committed
recipe: Update build and test scripts
1 parent af96fa9 commit 8540c16

File tree

8 files changed

+111
-82
lines changed

8 files changed

+111
-82
lines changed

recipe/build-mpi.sh

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
#!/bin/bash
22

3-
# unset unused old fortran compiler vars
4-
unset F90 F77
5-
63
set -ex
74

8-
export FCFLAGS="$FFLAGS"
9-
105
# avoid absolute-paths in compilers
116
export CC=$(basename "$CC")
127
export CXX=$(basename "$CXX")
138
export FC=$(basename "$FC")
149

15-
./autogen.pl --force
10+
# unset unused Fortran compiler variables
11+
unset FFLAGS F77 F90 F95
1612

13+
# tweak compiler flags
14+
export LIBRARY_PATH="$PREFIX/lib"
1715
if [[ "$target_platform" == osx-* ]]; then
18-
if [[ ! -z "$CONDA_BUILD_SYSROOT" ]]; then
16+
if [[ -n "$CONDA_BUILD_SYSROOT" ]]; then
1917
export CFLAGS="$CFLAGS -isysroot $CONDA_BUILD_SYSROOT"
2018
export CXXFLAGS="$CXXFLAGS -isysroot $CONDA_BUILD_SYSROOT"
2119
fi
2220
fi
2321

24-
if [[ -z $CUDA_HOME ]]; then
25-
build_with_cuda=""
26-
else
22+
# UCX support
23+
build_with_ucx=""
24+
if [[ "$target_platform" == linux-* ]]; then
25+
build_with_ucx="--with-ucx=$PREFIX"
26+
fi
27+
28+
# CUDA support
29+
build_with_cuda=""
30+
if [[ -n "$CUDA_HOME" ]]; then
31+
build_with_cuda="--with-cuda=yes"
2732
export CFLAGS="$CFLAGS -I$CUDA_HOME/include"
2833
export CXXFLAGS="$CXXFLAGS -I$CUDA_HOME/include"
29-
build_with_cuda="--with-cuda --with-ucx=$PREFIX"
34+
export LDFLAGS="$LDFLAGS -L$CUDA_HOME/lib64/stubs"
3035
fi
3136

3237
if [[ $CONDA_BUILD_CROSS_COMPILATION == "1" && $target_platform == osx-arm64 ]]; then
@@ -132,15 +137,6 @@ if [[ $CONDA_BUILD_CROSS_COMPILATION == "1" && $target_platform == osx-arm64 ]]
132137
export ompi_cv_fortran_use_only=yes
133138
fi
134139

135-
export LIBRARY_PATH="$PREFIX/lib"
136-
137-
## Replaced by the patch from open-mpi/ompi#8361
138-
# if [[ "$target_platform" == *-64 ]]; then
139-
# # -march=skylake-avx512 -march=nocona invalidates AVX512 flag. Remove -march flags and -mtune flags
140-
# export CFLAGS=$(echo $CFLAGS | sed 's/-march=[a-z0-9\-]*//g')
141-
# export CFLAGS=$(echo $CFLAGS | sed 's/-mtune=[a-z0-9\-]*//g')
142-
# fi
143-
144140
./configure --prefix=$PREFIX \
145141
--disable-dependency-tracking \
146142
--enable-mpi-fortran \
@@ -151,23 +147,32 @@ export LIBRARY_PATH="$PREFIX/lib"
151147
--with-wrapper-fcflags="-I$PREFIX/include" \
152148
--with-wrapper-ldflags="-L$PREFIX/lib -Wl,-rpath,$PREFIX/lib" \
153149
--with-sge \
154-
$build_with_cuda || (cat config.log; false)
150+
--with-hwloc=$PREFIX \
151+
--with-libevent=$PREFIX \
152+
--with-zlib=$PREFIX \
153+
--enable-mca-dso \
154+
$build_with_ucx \
155+
$build_with_cuda \
156+
|| (cat config.log; false)
155157

156158
make -j"${CPU_COUNT:-1}"
157159
make install
158160

159-
if [ ! -z "$build_with_cuda" ]; then
160-
echo "setting the mca opal_warn_on_missing_libcuda to 0..."
161-
echo "opal_warn_on_missing_libcuda = 0" >> $PREFIX/etc/openmpi-mca-params.conf
162-
echo "setting the mca opal_cuda_support to 0..."
163-
echo "opal_cuda_support = 0" >> $PREFIX/etc/openmpi-mca-params.conf
164-
165-
echo "setting the mca pml to ^ucx..."
161+
POST_LINK=$PREFIX/bin/.openmpi-post-link.sh
162+
if [ -n "$build_with_ucx" ]; then
163+
echo "setting MCA pml to ^ucx..."
166164
echo "pml = ^ucx" >> $PREFIX/etc/openmpi-mca-params.conf
167-
echo "setting the mca osc to ^ucx..."
165+
echo "setting MCA osc to ^ucx..."
168166
echo "osc = ^ucx" >> $PREFIX/etc/openmpi-mca-params.conf
169-
170-
POST_LINK=$PREFIX/bin/.openmpi-post-link.sh
171-
cp $RECIPE_DIR/post-link.sh $POST_LINK
167+
cat $RECIPE_DIR/post-link-ucx.sh >> $POST_LINK
168+
fi
169+
if [ -n "$build_with_cuda" ]; then
170+
echo "setting MCA opal_warn_on_missing_libcuda to 0..."
171+
echo "opal_warn_on_missing_libcuda = 0" >> $PREFIX/etc/openmpi-mca-params.conf
172+
echo "setting MCA opal_cuda_support to 0..."
173+
echo "opal_cuda_support = 0" >> $PREFIX/etc/openmpi-mca-params.conf
174+
cat $RECIPE_DIR/post-link-cuda.sh >> $POST_LINK
175+
fi
176+
if [ -f $POST_LINK ]; then
172177
chmod +x $POST_LINK
173178
fi

recipe/conda_build_config.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ docker_image: # [linux]
55
- quay.io/condaforge/linux-anvil-cos7-cuda:10.2 # [linux64]
66
- quay.io/condaforge/linux-anvil-ppc64le-cuda:11.0 # [ppc64le]
77
- quay.io/condaforge/linux-anvil-aarch64-cuda:11.0 # [aarch64]
8-
cudatoolkit: # [linux]
9-
- 10.2 # [linux64]
10-
- 11.0 # [ppc64le]
11-
- 11.0 # [aarch64]
8+
enable_ucx:
9+
- True # [linux]
10+
- False # [not linux]
1211
enable_cuda:
13-
- True # [linux]
14-
- False # [not linux]
12+
- True # [linux]
13+
- False # [not linux]
14+
cuda_version: # [linux]
15+
- 10.2 # [linux64]
16+
- 11.0 # [ppc64le]
17+
- 11.0 # [aarch64]

recipe/meta.yaml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,43 @@ outputs:
2929
run_exports:
3030
- {{ pin_subpackage('openmpi', min_pin='x.x.x', max_pin='x') }}
3131
ignore_run_exports:
32-
- ucx # [enable_cuda]
32+
- ucx # [enable_ucx]
3333
script_env:
34-
- CUDA_HOME # [enable_cuda]
34+
- CUDA_HOME # [enable_cuda]
3535
requirements:
3636
build:
3737
- {{ compiler('c') }}
3838
- {{ compiler('cxx') }}
3939
- {{ compiler('fortran') }}
40-
- autoconf # [unix]
41-
- automake # [unix]
40+
#- autoconf # [unix]
41+
#- automake # [unix]
4242
- libtool # [unix]
4343
- make # [unix]
44-
- perl 5.26.2
4544
host:
45+
#- openpmix
46+
#- prrte
47+
- libhwloc
48+
- libevent
4649
- zlib
47-
- ucx # [enable_cuda]
48-
- ucx-proc =*=gpu # [enable_cuda]
50+
- ucx # [enable_ucx]
51+
- cuda-version {{ cuda_version }} # [enable_cuda]
4952
run:
50-
- zlib
5153
- mpi 1.0 openmpi
54+
#- openpmix
55+
#- prrte
56+
- libhwloc
57+
- libevent
58+
- zlib
5259
run_constrained:
53-
- cudatoolkit >= {{ cudatoolkit }} # [enable_cuda]
54-
- {{ pin_compatible("ucx", max_pin="x") }} # [enable_cuda]
60+
- {{ pin_compatible("ucx", max_pin="x.x") }} # [enable_ucx]
61+
# Open MPI only uses CUDA Driver APIs, set the minimal driver version
62+
- __cuda >= {{ cuda_version }} # [enable_cuda]
63+
# Ensure a consistent CUDA environment
64+
- cuda-version >= {{ cuda_version }} # [enable_cuda]
65+
- cudatoolkit >= {{ cuda_version }} # [enable_cuda]
5566
test:
5667
script: run_test.sh
5768
files:
58-
- mpiexec.sh
5969
- tests/helloworld.sh
6070

6171
- name: openmpi-mpicc
@@ -73,7 +83,6 @@ outputs:
7383
test:
7484
script: run_test.sh
7585
files:
76-
- mpiexec.sh
7786
- tests/helloworld.c
7887

7988
- name: openmpi-mpicxx
@@ -91,7 +100,6 @@ outputs:
91100
test:
92101
script: run_test.sh
93102
files:
94-
- mpiexec.sh
95103
- tests/helloworld.cxx
96104

97105
- name: openmpi-mpifort
@@ -108,7 +116,6 @@ outputs:
108116
test:
109117
script: run_test.sh
110118
files:
111-
- mpiexec.sh
112119
- tests/helloworld.f
113120
- tests/helloworld.f90
114121
{% else %}

recipe/mpiexec.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

recipe/post-link-cuda.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
cat << EOF >> $PREFIX/.messages.txt
4+
5+
On Linux, Open MPI is built with CUDA awareness but it is disabled by default.
6+
To enable it, please set the environment variable
7+
OMPI_MCA_opal_cuda_support=true
8+
before launching your MPI processes.
9+
Equivalently, you can set the MCA parameter in the command line:
10+
mpiexec --mca opal_cuda_support 1 ...
11+
Note that you might also need to set UCX_MEMTYPE_CACHE=n for CUDA awareness via
12+
UCX. Please consult UCX documentation for further details.
13+
14+
EOF

recipe/post-link-ucx.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
cat << EOF >> $PREFIX/.messages.txt
4+
5+
On Linux, Open MPI is built with UCX support but it is disabled by default.
6+
To enable it, first install UCX (conda install -c conda-forge ucx).
7+
Afterwards, set the environment variables
8+
OMPI_MCA_pml=ucx OMPI_MCA_osc=ucx
9+
before launching your MPI processes.
10+
Equivalently, you can set the MCA parameters in the command line:
11+
mpiexec --mca pml ucx --mca osc ucx ...
12+
13+
EOF

recipe/post-link.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

recipe/run_test.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
11
#!/bin/bash
22
set -ex
33

4-
export OMPI_MCA_plm=isolated
5-
export OMPI_MCA_btl_vader_single_copy_mechanism=none
6-
export OMPI_MCA_rmaps_base_oversubscribe=yes
7-
MPIEXEC="${PWD}/mpiexec.sh"
4+
export OMPI_MCA_pml=ob1
5+
export OMPI_MCA_btl=sm,self
6+
export OMPI_MCA_plm_ssh_agent=false
7+
export OMPI_MCA_rmaps_default_mapping_policy=:oversubscribe
8+
export OMPI_ALLOW_RUN_AS_ROOT=1
9+
export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
10+
MPIEXEC="mpiexec"
811

912
pushd "tests"
1013

1114
if [[ $PKG_NAME == "openmpi" ]]; then
12-
command -v ompi_info
13-
ompi_info
1415

15-
if [[ ! -z "$(conda list | grep ucx)" ]]; then
16+
if [[ -n "$(conda list | grep ucx)" ]]; then
1617
echo "Improper UCX dependency!"
1718
exit 1
1819
fi
19-
if [[ ! -z "$(conda list | grep cudatoolkit)" ]]; then
20-
echo "Improper cuda dependency!"
20+
21+
if [[ -n "$(conda list | grep cuda-version)" ]]; then
22+
echo "Improper CUDA dependency!"
2123
exit 1
2224
fi
2325

26+
command -v ompi_info
27+
ompi_info
28+
29+
command -v prte_info
30+
prte_info
31+
2432
command -v mpiexec
2533
$MPIEXEC --help
2634
$MPIEXEC -n 4 ./helloworld.sh

0 commit comments

Comments
 (0)