Newer
Older
function haveProg() {
[ -x "$(command -v $1)" ]
}
source script/solve_cmake
source script/solve_git
source script/solve_wget
source script/solve_brew
source script/detect_gcc
source script/detect_osx
if [ x"$platform" = x"osx" -a x"$pcman" = x"" ]; then
echo -e "\033[30;43;5;1m WARNING \033[0m No package manager has been found on this system"
solve_brew $platform
discover_package_manager $platform
pcman=$discover_package_manager_ret
if [ x"$pcman" != x"brew" ]; then
echo -e "brew \033[91;5;1m FAILED \033[0m"
fi
### Additional package required for apt-get based distros
if [ x"$platform" = x"linux" -a x"$pcman" = x"apt-get" ]; then
dpkg-query -l libbz2-dev
ret1=$?
dpkg-query -l python-dev
ret2=$?
dpkg-query -l libxml2-dev
ret3=$?
dpkg-query -l libxslt-dev
ret4=$?
if [ $ret1 -ne 0 -o $ret2 -ne 0 -o $ret3 -ne 0 -o $ret4 -ne 0 ]; then
echo "OpenFPM require additional packages in order to install correctly"
commands[0]="sudo $pcman install libbz2-dev python-dev libxml2-dev libxslt-dev"
possible_solutions "${commands[@]}"
fi
fi
### Additional package required for yum based distros
if [ x"$platform" = x"linux" -a x"$pcman" = x"yum" ]; then
rpm -V bzip2-devel
ret1=$?
rpm -V python-devel
ret2=$?
if [ $ret2 -ne 0 ]; then
echo "Cheking python2-devel"
rpm -V python2-devel
ret2=$?
fi
rpm -V libxml2-devel
ret3=$?
rpm -V libxslt-devel
ret4=$?
if [ $ret1 -ne 0 -o $ret2 -ne 0 -o $ret3 -ne 0 -o $ret4 -ne 0 ]; then
echo "OpenFPM require additional packages in order to install correctly"
commands[0]="su -c \"$pcman install bzip2-devel python-devel libxml2-devel libxslt-devel\""
commands[1]="sudo $pcman install bzip2-devel python-devel libxml2-devel libxslt-devel"
possible_solutions "${commands[@]}"
fi
fi
#### if we are on OSX we install gnu-sed
if haveProg gsed; then
echo -e "gsed\033[92;1m SUCCESS \033[0m"
else
echo >&2
echo -e "gsed\033[91;5;1m FAILED \033[0m"
echo "OpenFPM require gnu-sed but it's not installed, searching a solution... "
if haveProg gsed; then
echo -e "gsed\033[92;1m SUCCESS \033[0m"
else
echo -e "gsed\033[91;5;1m FAILED \033[0m"
exit 1
fi
fi
fi
## cmake
if haveProg cmake; then
echo -e "cmake\033[92;1m SUCCESS \033[0m"
else
echo -e "cmake\033[91;5;1m FAILED \033[0m"
echo "OpenFPM require cmake but it's not installed, searching a solution... "
if haveProg cmake; then
echo -e "cmake\033[92;1m SUCCESS \033[0m"
else
## wget
if haveProg wget; then
echo -e "wget \033[92;1m SUCCESS \033[0m"
else
echo >&2
echo -e "wget\033[91;5;1m FAILED \033[0m"
echo "OpenFPM require wget but it's not installed, searching a solution... "
if haveProg wget; then
echo -e "wget\033[92;1m SUCCESS \033[0m"
else
echo -e "wget\033[91;5;1m FAILED \033[0m"
exit 1
fi
fi
## git
if haveProg git; then
echo -e "git \033[92;1m SUCCESS \033[0m"
else
echo >&2
echo -e "git\033[91;5;1m FAILED \033[0m"
echo "OpenFPM require git but it's not installed, searching a solution... "
if haveProg git; then
echo -e "git\033[92;1m SUCCESS \033[0m"
else
echo -e "git\033[91;5;1m FAILED \033[0m"
exit 1
fi
fi
elif [ $dgc_ret -eq 2 ]; then
detect_osx $platform
if [ $dosx_ret -eq 1 ]; then
echo -e "\033[30;43;5;1m------------------------------- WARNING --------------------------------\033[0m"
echo "g++ seem to be present, but we failed to detect the version. Your system $dosx_major.$dosx_middle.$dosx_minor seem to be recent enough, so we will continue the installation"
sleep 10
#### Detection gfortran
detect_fortran gfortran
if [ $dgc_ret -eq 0 ]; then
solve_gfortran $platform
detect_fortran $compiler_fortran
if [ $dgc_ret -eq 0 ]; then
exit 1
fi
else
echo -e "gfortran \033[92;1m SUCCESS \033[0m"
fi
if [ -d "$i_dir/MPI" ]; then
export PATH="$i_dir/MPI/bin:$PATH"
fi
if haveProg mpirun; then
call_test_working_mpi_options=0
# Here we check if we are running openmpi mpich or unknown
version=$(mpirun --version 2>&1 | grep mpirun | sed 's/.*Open MPI.*/openmpi/g')
if [ x"$version" == x"" ]; then
version=$(mpirun --version 2>&1 | grep HYDRA | sed 's/HYDRA.*/mpich/g')
fi
if [ x"$version" == x"openmpi" ]; then
# Check if we are compiling with GPU support
if [ x"$gpu_support" == x"1" ]; then
is_openmpi_cuda_aware
if [ x"$cuda_mpi_support" == x"false" ]; then
echo -e " \033[91;5;1m OpenMPI has been compiled without GPU support \033[0m"
echo -e "\033[1m OpenFPM use GPUDirect RDMA to move data from one GPU to another GPU (intranode and extranode) without moving the data on host. This feature requires that OpenMPI is compiled with CUDA support. OpenFPM can works also without this feature using GPUDirect old version (1.0). In practice it requires that MPI work with host pinned memory allocated with CUDA. This feature has been introduced with CUDA 5.0 in 2010. At best of our knowledge this feature should work without special compilation options for OpenMPI. On the other end we found several problems with GPUDirect v1.0 and Infiniband cards, when OpenMPI is not compiled with CUDA support. If you are on a super-computer or a machine you did not set-up, we suggest to re-install OpenMPI with CUDA support using the same options used to compile the one detected (option 1). Alternatively you can reinstall OpenMPI using the default options (option 2), or use the OpenMPI detected (option 3) \033[0m"
if [ $sq -eq 0 ]; then
unset commands
commands[0]="Reinstall MPI and mirror the one detected"
commands[1]="Reinstall MPI, use the default arguments"
commands[2]="Continue with the detected one"
possible_solutions_no_execute "${commands[@]}"
else
possible_solutions_ret=0
fi
# Remove old MPI
rm -rf $i_dir/MPI
if [ x"$possible_solutions_ret" == x"0" ]; then
get_openmpi_compilation_options
else
echo "OpenMPI is CUDA aware"
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
major=$(mpirun --version 2>&1 | grep mpirun | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1/g')
middle=$(mpirun --version 2>&1 | grep mpirun | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\2/g')
minor=$(mpirun --version 2>&1 | grep mpirun | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\3/g')
if [ $major -gt 1 ]; then
echo -e "openmpi $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
MPI_valid=yes
elif [ $major -lt 1 ]; then
echo -e "openmpi $major.$middle.$minor \033[33;5;1m WARNING \033[0m is too old, 1.8.1 at least required, (Automatic fix activated)"
elif [ $middle -gt 8 ]; then
echo -e "openmpi $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
MPI_valid=yes
elif [ $middle -lt 8 ]; then
echo -e "opnmpi $major.$middle.$minor \033[33;5;1m WARNING \033[0m is too old, 1.8.1 at least required (Automatic fix activated)"
elif [ $minor -gt 0 ]; then
echo -e "openmpi $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
MPI_valid=yes
else
echo -e "openmpi $major.$middle.$minor \033[33;5;1m WARNING \033[0m is too old, 1.8.1 at least required, (Automatic fix activated)"
fi
elif [ x"$version" == x"mpich" ]; then
major=$(mpirun --version 2>&1 | grep Version | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1/g')
middle=$(mpirun --version 2>&1 | grep Version | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\2/g')
if [ $major -gt 3 ]; then
echo -e "mpich $major.$middle \033[92;1m SUCCESS \033[0m"
MPI_valid=yes
elif [ $major -lt 3 ]; then
echo -e "mpich $major.$middle \033[33;5;1m WARNING \033[0m is too old, 3.2 at least required, (Automatic fix activated)"
elif [ $middle -gt 1 ]; then
echo -e "mpich $major.$middle \033[92;1m SUCCESS \033[0m"
MPI_valid=yes
elif [ $middle -lt 1 ]; then
echo -e "mpich $major.$middle \033[33;5;1m WARNING \033[0m is too old, 3.2 at least required (Automatic fix activated)"
else
echo -e "mpich $major.$middle \033[33;5;1m WARNING \033[0m is too old, 3.2 at least required, (Automatic fix activated)"
fi
#### Unkown version of MPI print a warning
echo -e "\033[43;30;1;5mWARNING: \033[0m Found an unkown version of MPI, OpenFPM work with any MPI version that implement MPI-3.0 interface. If you know that the installed MPI implement the MPI-3.0 interface choose 1) continue. If you are not sure, or you do not even know what this message mean choose 2) install OpenMPI"
echo "1) Continue"
echo "2) Install OpenMPI"
choose=1
if [ $sq -eq 0 ]; then
read choose
fi
if [ $choose -eq 1 ]; then
MPI_valid=yes
fi
fi
# invalidate MPI, must be reinstalled
if [ $call_test_working_mpi_options -eq 1 ]; then
MPI_valid=no
else
echo -e "No MPI"
## Check for potential problem in the MPI installation
if [ -d $1/MPI ]; then
where_mpi=$(which mpic++)
if [ x"$where_mpi" != x"$1/MPI/bin/mpic++" ]; then
echo -e "\033[91;5;1m MPI instalation: CONFLICT \033[0m"
echo "Performing a \"which mpic++\", we found that you have installed one system wide MPI "
echo -e "\033[1m $where_mpi \033[0m"
echo "this MPI has priority over OpenFPM MPI installation in: "
echo -e "\033[1m $1/MPI/bin/mpic++ \033[0m"
echo "Such configuration is not supported, one MPI must be uniquely selected"
echo "The possible solutions are: "
echo -e "\033[1m 1) Set your PATH to give priority to $1/MPI/bin \033[0m"
echo -e "\033[1m 2) Eliminate OpenFPM MPI removing $1/MPI \033[0m"
echo -e "\033[1m 3) Eliminate the system wide MPI \033[0m"
exit 1
fi
fi
#### Detect a potential dangerous situation ###
#### In which g++ is different from mpic++ ###
output_mpi=$(mpic++ --version)
output_gcc=$($dgc_compiler --version)
if [ x"$output_mpi" != x"$output_gcc" ]; then
echo -e "\033[91;5;1m MPI dangerous installation \033[0m"
echo -e "Performing a \033[1m \"mpic++ --version\" \033[0m, we detect that your installed mpic++ does not wrap the standard command g++"
echo "In general we strongly disencourage to override the default compiler(s), this configuration not only is not supported by OpenFPM, but can lead potentialy to several problems at system level. For the following reasons"
echo -e "\033[1m 1) All system wide dependencies become potentially useless \033[0m"
echo -e "\033[1m 2) A package maneger (apt-get or brew) installing a packege from source can potentialy generate incompatible system packages \033[0m"
echo -e "\033[1m 3) It is not easy to discover which compiler has been used to compile one dependency \033[0m"
echo -e "For just the time of the installation the installer will realign mpic++ to g++, unfortunately this could be not enough to ensure that all the dependencies has been compiled with the same compiler"
echo -e "\033[1m Installation will resume in 20 seconds \033[0m"
export OMPI_CXX=g++
if [ x"$output_mpi" != x"$output_gcc" ]; then
echo -e "\033[91;5;1m MPI dangerous installation \033[0m"
echo -e "\033[1m The realign operation failed the installation will continue \033[0m"
sleep 10
fi