a shell script to spawn mpi executables on the "free" nodes of a Scyld cluster

Florent Calvayrac fcalvay at aviion.univ-lemans.fr
Wed Oct 31 12:44:59 PST 2001


to those with the same problem

Since  I couldn't find any free programs to address
easily this issue I include below a dirty bash2 script 
to spawn mpi executables on the "free" nodes of a Scyld cluster

Comments and feedback welcome


-- 
Florent Calvayrac                          
Laboratoire de Physique de l'Etat Condense 
Universite du Maine-Faculte des Sciences
http://www.univ-lemans.fr/~fcalvay
-------------- next part --------------
#!/bin/bash2
#the above must strictly be the first line of the script

#
#	dirty hack to spawn an mpi executable on free nodes of a Beowulf
#       (Scyld) cluster  - this is, with a load below "loadlimit" 
#	specified below
#
#
#       version 0.01 of a quick and dirty hack by Florent.Calvayrac at univ-lemans.fr
#
#
#       problems as of yet : stdout is lost, I do not where yet
#
#
#       usage : ./this_script np executable
#
#
#       (must of course reside in a cluster-readable directory, like /home/...)
#
#
#

ARGS=2        # Number of arguments expected.
E_BADARGS=65  # Exit value if incorrect number of args passed.

test $# -ne $ARGS && echo "Usage: `basename $0` $ARGS argument(s)" && exit $E_BADARGS
# If condition-1 true (wrong number of args passed to script),
# then the rest of the line executes, and script terminates.

np=$1
command=$2
loadlimit=0.7

#generating hopefully unique temp files

file="$PWD"/pg`ps | tail -1 | cut -b 3-5`  
file2="$file"2  
echo "temporary files are " $file $file2

#machine loads 

bpsh -a -p cat /proc/loadavg | cut -b 2-10 > $file2

#process as a function of the number of procs required

count=0
echo "eof" >> $file2

number=""
while [ "$number" != "eof" ]
do 
	read number load
        if [[ load < loadlimit ]] ; then
		let "count += 1"
		if [[ $count -le $np ]] ; then
       	        	j=1
		        if [[ $count -eq 1 ]] ; then
		   		j=0
		   		master=`echo $number | sed --expression="s/\://"`
		   		echo "master is" $master
			fi 
		echo $number $j $command  | sed --expression="s/\://" >> $file 
        fi
fi
done <$file2



#spawn the master

echo "spawning job"
P4_PG=$file NO_INLINE_MPIRUN=true bpsh $master "$command" 
echo "job is ended"

#clean up
rm -f $file
rm -f $file2




More information about the Beowulf mailing list