added mpi version checks in toolchain, updated prepend-path and append-path commands

svn-origin-rev: 16730
This commit is contained in:
Tong Lianheng 2016-03-24 17:13:29 +00:00
parent 0948657a02
commit 209b97d909
5 changed files with 118 additions and 48 deletions

View file

@ -649,17 +649,7 @@ export CP_LDFLAGS="-Wl,--enable-new-dtags"
# ------------------------------------------------------------------------
cat <<EOF > "$SETUPFILE"
#!/bin/bash
prepend_path() {
local __env_var=\$1
local __path=\$2
if eval [ x\"\\\$\$__env_var\" = x ] ; then
eval \$__env_var=\"\$__path\"
eval export \$__env_var
elif ! eval [[ \"\\\$\$__env_var\" =~ '(^|:)'\"\$__path\"'(\$|:)' ]] ; then
eval \$__env_var=\"\\\$__path:\\\$\$__env_var\"
eval export \$__env_var
fi
}
source "${SCRIPTDIR}/tool_kit.sh"
EOF
# ------------------------------------------------------------------------

View file

@ -79,6 +79,19 @@ prepend_path LIBRARY_PATH "$pkg_install_dir/lib"
prepend_path CPATH "$pkg_install_dir/include"
EOF
cat "${BUILDDIR}/setup_mpich" >> $SETUPFILE
mpi_bin="$pkg_install_dir/bin/mpirun"
else
mpi_bin=mpirun
fi
# check MPICH version, versions less than 3.0 will get -D__MPI_VERSION=2 flag
raw_version=$($mpi_bin --version | \
grep "Version:" | awk '{print $2}')
major_version=$(echo $raw_version | cut -d '.' -f 1)
minor_version=$(echo $raw_version | cut -d '.' -f 2)
if [ $major_version -lt 3 ] ; then
mpi2_dflags="-D__MPI_VERSION=2"
else
mpi2_dflags=''
fi
cat <<EOF >> "${BUILDDIR}/setup_mpich"
export MPI_MODE="__MPICH__"
@ -88,7 +101,7 @@ export MPICH_LIBS="${MPICH_LIBS}"
export MPI_CFLAGS="${MPICH_CFLAGS}"
export MPI_LDFLAGS="${MPICH_LDFLAGS}"
export MPI_LIBS="${MPICH_LIBS}"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__parallel -D__MPI_VERSION=3|)"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__parallel ${mpi2_dflags}|)"
export CP_CFLAGS="\${CP_CFLAGS} IF_MPI(${MPICH_CFLAGS}|)"
export CP_LDFLAGS="\${CP_LDFLAGS} IF_MPI(${MPICH_LDFLAGS}|)"
export CP_LIBS="\${CP_LIBS} IF_MPI(${MPICH_LIBS}|)"

View file

@ -39,8 +39,8 @@ case "$with_openmpi" in
glibc_version=$(ldd --version | awk '(NR == 1){print $4}')
glibc_major_ver=$(echo $glibc_version | cut -d . -f 1)
glibc_minor_ver=$(echo $glibc_version | cut -d . -f 2)
if [ $glibc_major_ver -le 2 ] && \
[ $glibc_minor_ver -lt 12 ] ; then
if [ $glibc_major_ver -lt 2 ] || \
[ $glibc_major_ver -eq 2 -a $glibc_minor_ver -lt 12 ] ; then
CFLAGS="${CFLAGS} -fgnu89-inline"
fi
./configure --prefix=${pkg_install_dir} CFLAGS="${CFLAGS}" > configure.log 2>&1
@ -86,6 +86,20 @@ prepend_path LIBRARY_PATH "$pkg_install_dir/lib"
prepend_path CPATH "$pkg_install_dir/include"
EOF
cat "${BUILDDIR}/setup_openmpi" >> $SETUPFILE
mpi_bin="$pkg_install_dir/bin/mpirun"
else
mpi_bin=mpirun
fi
# check openmpi version, versions less than 1.8 will get -D__MPI_VERSION=2 flag
raw_version=$($mpi_bin --version 2>&1 | \
grep "(Open MPI)" | awk '{print $4}')
major_version=$(echo $raw_version | cut -d '.' -f 1)
minor_version=$(echo $raw_version | cut -d '.' -f 2)
if [ $major_version -lt 1 ] || \
[ $major_version -eq 1 -a $minor_version -lt 8 ] ; then
mpi2_dflags="-D__MPI_VERSION=2"
else
mpi2_dflags=''
fi
cat <<EOF >> "${BUILDDIR}/setup_openmpi"
export OPENMPI_CFLAGS="${OPENMPI_CFLAGS}"
@ -94,7 +108,7 @@ export OPENMPI_LIBS="${OPENMPI_LIBS}"
export MPI_CFLAGS="${OPENMPI_CFLAGS}"
export MPI_LDFLAGS="${OPENMPI_LDFLAGS}"
export MPI_LIBS="${OPENMPI_LIBS}"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__parallel|)"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__parallel ${mpi2_dflags}|)"
export CP_CFLAGS="\${CP_CFLAGS} IF_MPI(${OPENMPI_CFLAGS}|)"
export CP_LDFLAGS="\${CP_LDFLAGS} IF_MPI(${OPENMPI_LDFLAGS}|)"
export CP_LIBS="\${CP_LIBS} IF_MPI(${OPENMPI_LIBS}|)"

View file

@ -23,7 +23,7 @@ case "$with_reflapack" in
if [ -f "${install_lock_file}" ] ; then
echo "lapack-${reflapack_ver} is already installed, skipping it."
else
if [ -f lapack-${reflapack_ver}.tar.gz ] ; then
if [ -f lapack-${reflapack_ver}.tgz ] ; then
echo "reflapack-${reflapack_ver}.tgz is found"
else
download_pkg ${DOWNLOADER_FLAGS} \

View file

@ -1,8 +1,5 @@
#!/bin/bash -e
# BASH_SOURCE is better than $0, because it also works correctly with
# source ./script_name. For $0, this will be "bash" instead. However
# BASH_SOURCE is only avaliable for bash version >= 3.0
# [ "$BASH_SOURCE" ] && script_name=$BASH_SOURCE || script_name=$0
# A set of tools used in the toolchain installer, intended to be used
# by sourcing this file inside other scipts.
SYS_INCLUDE_PATH=${SYS_INCLUDE_PATH:-"/usr/local/include:/usr/include"}
SYS_LIB_PATH=${SYS_LIB_PATH:-"/user/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib:/lib64:/lib"}
@ -66,24 +63,66 @@ realpath() {
}
# given a list, outputs a list with duplicated items filtered out
unique() {
local __sep=$'\n'
local __item=''
unique() (
# given a list, outputs a list with duplicated items filtered out.
# If -d <delimiter> option exists, then output the list delimited
# by <delimiter>; note that this option does not effect the input.
local __result=''
# double quoting $@ is essential as this will then be equilavent
# to "$1" "$2" "$3" ... and takes care the possible spaces in the
# arguments correctly
local __delimiter=' '
local __item=''
if [ "$1" = "-d" ] ; then
shift
__delimiter="$1"
shift
fi
# It is essential that we quote $@, which makes it equivalent to
# "$1" "$2" ... So this works if any of the arguments contains
# space. And we use \n to separate the fields in the
# __result for now, so that fields that contain spaces are
# correctly grepped.
for __item in "$@" ; do
if [ x"$__result" = "x" ] ; then
if [ x"$__result" = x ] ; then
__result="${__item}"
elif ! [[ "$__result" =~ (^|"$__sep")"$__item"($|"$__sep") ]] ; then
__result="${__result}${__sep}${__item}"
# Note that quoting $__result after echo is essential to
# retain the \n in the variable from the output of echo. Also
# remember grep only works on a line by line basis, so if
# items are delimited by newlines, then for grep search it
# should be delimited by ^ and $ (beginning and end of line)
elif ! (echo "$__result" | \
grep -s -q -e "^$__item\$") ; then
__result="${__result}
${__item}"
fi
done
__result="${__result//${__sep}/ }"
__result="$(echo "$__result" | paste -s -d "$__delimiter" -)"
# quoting $__result below is again essential for correct
# behaviour if IFS is set to be the same $__delimiter in the
# parent shell calling this macro
echo "$__result"
}
)
# reverse a list
reverse() (
# given a list, output a list with reversed order. If -d
# <delimiter> option exists, then output the list delimited by
# <delimiter>; note that this option does not effect the input.
local __result=''
local __delimiter=' '
local __item=''
if [ "$1" = "-d" ] ; then
shift
__delimiter="$1"
shift
fi
for __item in "$@" ; do
if [ x"$__result" = x ] ; then
__result="$__item"
else
__result="${__item}${__delimiter}${__result}"
fi
done
echo "$__result"
)
# get the number of processes avaliable for compilation
get_nprocs() {
@ -432,28 +471,42 @@ allowed_gxx_flags() {
# prepend a directory to a given path
prepend_path() {
local __env_var=$1
local __path=$2
if eval [ x\"\$$__env_var\" = x ] ; then
eval $__env_var=\"$__path\"
eval export $__env_var
elif ! eval [[ \"\$$__env_var\" =~ '(^|:)'\"$__path\"'($|:)' ]] ; then
eval $__env_var=\"$__path:\$$__env_var\"
eval export $__env_var
# prepend directory to $path_name and then export path_name. If
# the directory already exists in path, bring the directory to the
# front of the list.
local __path_name=$1
local __directory=$2
if eval [ x\"\$$__path_name\" = x ] ; then
eval $__path_name=\"$__directory\"
else
eval $__path_name=\"$__directory:\$$__path_name\"
fi
eval $__path_name=\"$(IFS=:; eval unique -d ':' \$$__path_name)\"
export $__path_name
}
# append a directory to a given path
append_path() {
local __env_var=$1
local __path=$2
if eval [ x\"\$$__env_var\" = x ] ; then
eval $__env_var=\"$__path\"
eval export $__env_var
elif ! eval [[ \"\$$__env_var\" =~ '(^|:)'\"$__path\"'($|:)' ]] ; then
eval $__env_var=\"'$'$__env_var:"$__path"\"
eval export $__env_var
# append directory to $path_name and then export path_name. If
# the directory already exists in path, bring the directory to the
# back of the list.
#
# $1 is path_name
# $2 is directory
local __path_name=$1
local __directory=$2
if eval [ x\"\$$__path_name\" = x ] ; then
eval $__path_name=\"$__directory\"
else
eval $__path_name=\"\$$__path_name:$__directory\"
fi
# here, we reverse the list, apply unique, and then reverse back,
# so that the last instance of the repeated directory is kept
eval $__path_name=\"$(IFS=':'; \
reverse -d ':' \
$(unique -d ':' \
$(eval reverse -d ':' \$$__path_name)))\"
export $__path_name
}
# helper routine for reading --enable=* input options