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 15:44:59 EST 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
-------------- next part --------------
#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.


#generating hopefully unique temp files

file="$PWD"/pg`ps | tail -1 | cut -b 3-5`  
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

echo "eof" >> $file2

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