set_mpi 2.14 KB
Newer Older
incardon's avatar
incardon committed
1
2
3
4
#! /bin/bash

function set_mpi()
{
Pietro Incardona's avatar
Pietro Incardona committed
5
6
7
  if [ x"$MPI_valid" == x"yes" ]; then
        configure_options="$configure_options CXX=mpic++ "
  else
incardon's avatar
incardon committed
8
        ./script/install_MPI.sh $1 $2 $3 $4 $5 $6 $7 "$openmpi_working_options"
Pietro Incardona's avatar
Pietro Incardona committed
9
        MPI_installed=1
10
        export PATH="$1/MPI/bin:$PATH"
Pietro Incardona's avatar
Pietro Incardona committed
11
        configure_options="$configure_options CXX=mpic++ "
incardon's avatar
incardon committed
12
  fi
Pietro Incardona's avatar
Pietro Incardona committed
13

incardon's avatar
incardon committed
14
15
}

incardon's avatar
incardon committed
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function is_openmpi_cuda_aware()
{
  output=$(ompi_info --parsable --all | grep mpi_built_with_cuda_support:value)
  cuda_mpi_support=$(echo $output | sed 's/mca:mpi:base:param:mpi_built_with_cuda_support:value:\(.*\)/\1/g')
}

function get_openmpi_compilation_options()
{
	output=$(ompi_info --config | grep "Configure command line:")
	list=$(echo $output | sed 's/Configure command line:\(.*\)/\1/g')
	arr=($list)

	openmpi_compilation_options=()
	for opt in ${arr[@]}; do
		opt_filter=$(echo $opt | sed "s/'\(.*\)'/\1/g" )
		openmpi_compilation_options+=("$opt_filter")
	done
}

function test_working_mpi_options()
{
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
	script/download_MPI.sh
	cd openmpi-3.1.3
	openmpi_working_options=()
        for opt in ${openmpi_compilation_options[@]}; do
	       # prefix and --with-cuda must be avoided

		if [[ $opt == --with-cuda* ]]; then
			continue;
		fi

                if [[ $opt == --prefix* ]]; then
                        continue;
                fi

		if [[ $opt == --enable-mpi-fortran* ]]; then
			continue;
		fi

                if [[ $opt == CC* ]]; then
                        continue;
                fi

                if [[ $opt == CXX* ]]; then
                        continue;
                fi

                if [[ $opt == FC* ]]; then
                        continue;
                fi

                if [[ $opt == F77* ]]; then
                        continue;
                fi

		echo "Testing ./configure --prefix=$1/MPI --enable-mpi-fortran=yes CC=$4 CXX=$5 F77=$6 FC=$7 $openmpi_working_options"
                ./configure --prefix=$1/MPI --enable-mpi-fortran=yes CC=$4 CXX=$5 F77=$6 FC=$7 $openmpi_working_options $opt

	       if [ $? -eq 0 ]; then
	           openmpi_working_options="$openmpi_working_options $opt"
	       fi
	done

	echo "OpenMPI working options: $openmpi_working_options"

	cd ..
incardon's avatar
incardon committed
82
83
}