lsf.submit.mvapich2.job 5.72 KB
Newer Older
John Fleck's avatar
John Fleck committed
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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
#! /bin/bash
# BEGIN_ICS_COPYRIGHT8 ****************************************
# 
# Copyright (c) 2015, Intel Corporation
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 
#     * Redistributions of source code must retain the above copyright notice,
#       this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of Intel Corporation nor the names of its contributors
#       may be used to endorse or promote products derived from this software
#       without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 
# END_ICS_COPYRIGHT8   ****************************************

# [ICS VERSION STRING: unknown]


# initialize

# BASE PATH TO MPI EXECUTABLES: To use an alternate location,
# either edit this line or set MPICH_PREFIX in your environment.
# see iba_select_mpi for the set of default MPI selections
# default to MPI used for build
MPICH_PREFIX=

mpirunfile=
vfselectmethod=sid_qlc
vfname=
vfsid=
dsprtg=
qname=
mrailmap=

MPI_CMD_ARGS=

LSB_DJOB_NUMPROC=3

# Usage - display usage syntax and exit

Usage()
{
	echo "Usage: submit.mvapich2.job [-p num_proceses] [-V vf_select_method] [-s vf_sid] [-n vf_name] [-d dsp_rtg] [-q queue_name] [-m <unit:port>[,<unit:port>]] mpi_run_file [mpi_run_file args]"
	echo "  where vf_select_method is one of:"
	echo "    vf_name: Name of virtual fabric - use -n to define vf name"
	echo "    sid    : ServiceId of virtual fabric - use -s option to define service id"
	echo "    sid_qlc: ServiceId of virtual fabric - use -s option to define service id, uses dist_sa (default)"
	echo "  where dsp_rtg is one of: 1-adaptive, 2-static_src, 3-static_dest, 4-static_base"
	echo "  where queue_name is a valid LSF queue name (use bqueues for a list)"
	echo "  where unit:port is the unit/port pair is used to setup a rail"  
	exit 2
}




# process opts and args

while getopts V:s:n:d:p:q:m: param
do
	case $param in
	V)
		export vfselectmethod=$OPTARG;;
	s)
		export vfsid=$OPTARG;;
	n)
		export vfname=$OPTARG;;
	d)
		export dsprtg=$OPTARG;;
	p)
		export LSB_DJOB_NUMPROC=$OPTARG;;
	q)
		export qname=$OPTARG;;
	m)
		export mrailmap=$OPTARG;;
	?)
		Usage
	esac
done
shift $(($OPTIND -1))

mpirunfile=$1

# validate args

if [ "$mpirunfile" = "" ]
then
	echo "Must provide an mpi_run_file"
	Usage
fi

if [ ! -f $mpirunfile ]
then
	echo "mpi_run_file \"$mpirunfile\" does not exist"
	Usage
fi

if [ "$dsprtg" != "" ]
then
	if [ $dsprtg -lt 1 -o $dsprtg -gt 4 ]
	then
		echo dispersive routing value must be between 1 and 4
		Usage
	fi
fi

# get opagetvf_func definition
. /usr/bin/opagetvf_env

case $vfselectmethod in
	vf_name)
		opagetvf_func "-d '$vfname'" MV2_DEFAULT_PKEY MV2_DEFAULT_SERVICE_LEVEL MTU
		if [ $? -ne 0 ]
		then
			echo "Failed to get environment variables for VF with Name \"$vfname\""
			Usage
		fi
		export MPI_CMD_ARGS="MV2_DEFAULT_PKEY=$MV2_DEFAULT_PKEY MV2_DEFAULT_SERVICE_LEVEL=$MV2_DEFAULT_SERVICE_LEVEL MV2_DEFAULT_MTU=IBV_MTU_$MTU PSM_PKEY=$MV2_DEFAULT_PKEY IPATH_SL=$MV2_DEFAULT_SERVICE_LEVEL PSM_MTU=$MTU";;
	sid)
		opagetvf_func "-S '$vfsid'" MV2_DEFAULT_PKEY MV2_DEFAULT_SERVICE_LEVEL MTU
		if [ $? -ne 0 ]
		then
			echo "Failed to get environment variables for VF with SID \"$vfsid\""
			Usage
		fi
		export MPI_CMD_ARGS="MV2_DEFAULT_PKEY=$MV2_DEFAULT_PKEY MV2_DEFAULT_SERVICE_LEVEL=$MV2_DEFAULT_SERVICE_LEVEL MV2_DEFAULT_MTU=IBV_MTU_$MTU PSM_PKEY=$MV2_DEFAULT_PKEY IPATH_SL=$MV2_DEFAULT_SERVICE_LEVEL PSM_MTU=$MTU";;
	sid_qlc)
		export MPI_CMD_ARGS="PSM_PATH_REC=opp PSM_IB_SERVICE_ID=$vfsid";;
	*)
		echo Unknown vfselectmethod $vfselectmethod
		Usage;;
esac

if [ "$dsprtg" != "" ]
then
	case $dsprtg in
		1)
			export routing=adaptive;;
		2)
			export routing=static_src;;
		3)
			export routing=static_dest;;
		4)
			export routing=static_base;;
	esac
	export MPI_CMD_ARGS="$MPI_CMD_ARGS PSM_PATH_SELECTION=$routing"
fi

if [ "$MPICH_PREFIX" = "" ]
then
	. /usr/bin/iba_select_mpi
	if ! valid_mpich_prefix
	then
		find_mpi $prefix/mpi/gcc/mvapich2*qlc
	fi
	if ! valid_mpich_prefix
	then
		find_mpi $prefix/mpi/gcc/mvapich2*
	fi
fi

if [ "$mrailmap" != "" ]
then
	. /usr/bin/opagetvf_env
	
	iba_getpsm_func $mrailmap
	if [ $? -ne 0 ]
	then
		echo "Failed to get environment variable for PSM with value \"$mrailmap\""
		Usage
	else
		export MPI_CMD_ARGS="$MPI_CMD_ARGS PSM_MULTIRAIL=1 PSM_MULTIRAIL_MAP=$mrailmap"
	fi
fi

# submit the job from stdin

echo "#! /bin/sh" > .run.mvapich2
echo "#BSUB -n $LSB_DJOB_NUMPROC" >> .run.mvapich2
echo "#BSUB -o %J.out" >> .run.mvapich2
echo "#BSUB -e %J.err" >> .run.mvapich2
if [ "$qname" != "" ]
then
echo "#BSUB -q $qname" >> .run.mvapich2
fi
echo $MPICH_PREFIX/bin/mpirun_rsh -np $LSB_DJOB_NUMPROC -hostfile \$LSB_DJOB_HOSTFILE $MPI_CMD_ARGS $* >> .run.mvapich2

bsub < .run.mvapich2
rm .run.mvapich2

exit 0