1
1

* Add really, really basic mpirun shell script to start up MPI procs and

get a good enough environment to have the COFS stuff run.  Still far from
  perfect, but allows me to start testing the PCM code

This commit was SVN r367.
Этот коммит содержится в:
Brian Barrett 2004-01-14 08:38:51 +00:00
родитель 875c7241fc
Коммит 308b078068
6 изменённых файлов: 320 добавлений и 1 удалений

Просмотреть файл

@ -466,6 +466,7 @@ AC_CONFIG_FILES([
src/mca/mpi/topo/base/Makefile
src/tools/Makefile
src/tools/mpirun/Makefile
src/tools/wrappers/Makefile
test/Makefile

Просмотреть файл

@ -5,4 +5,4 @@
include $(top_srcdir)/config/Makefile.options
SUBDIRS = wrappers
SUBDIRS = mpirun wrappers

2
src/tools/mpirun/.cvsignore Обычный файл
Просмотреть файл

@ -0,0 +1,2 @@
Makefile
Makefile.in

9
src/tools/mpirun/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,9 @@
# -*- makefile -*-
#
# $HEADER$
#
include $(top_srcdir)/config/Makefile.options
bin_SCRIPTS = mpirun mpiboot

95
src/tools/mpirun/mpiboot Исполняемый файл
Просмотреть файл

@ -0,0 +1,95 @@
#!/bin/bash
#
# $HEADER$
#
# Quick and dirty hack of an mpirun to be used only with the cofs
# "RTE" (if you can call it that). Does not guarantee cleanup just
# yet (still trying to figure out how to make that one work..
#
# On the other hand, it will get us to MPI_INIT faster than just about
# any other idea I have...
#
# hboot is used to start procs on the remote side. fun, fun
######################################################################
#
# Some basic defaults
#
######################################################################
lam_myvpid=""
lam_numprocs=""
lam_jobhandle=""
lam_commdir=""
######################################################################
#
# Do argument parsing
#
######################################################################
args_err=1
for i ; do
case "${i}" in
-test)
exit 0
;;
-myvpid)
shift
lam_myvpid="${1}"
shift
;;
-numprocs)
shift
lam_numprocs="${1}"
shift
;;
-jobhandle)
shift
lam_jobhandle="${1}"
shift
;;
-commdir)
shift
lam_commdir="${1}"
shift
;;
-pwd)
shift
cd "${1}"
shift
;;
--)
shift
args_err=0
;;
esac
done
if test "${args_err}" != "0" ; then
echo "Argument parse error - did not find -- "
exit 1
fi
if test -z "${1}" ; then
echo "Did not find app to execute"
exit 2
fi
######################################################################
#
# Set the environment
#
######################################################################
export MCA_common_lam_cofs_my_vpid="${lam_myvpid}"
export MCA_common_lam_cofs_num_procs="${lam_numprocs}"
export MCA_common_lam_cofs_job_handle="${lam_jobhandle}"
if test ! -z "${lam_commdir}"; then
export MCA_common_lam_cofs_comm_dir="${lam_commdir}"
fi
######################################################################
#
# Spawn and run
#
######################################################################
exec $@ &
exit 0

212
src/tools/mpirun/mpirun Исполняемый файл
Просмотреть файл

@ -0,0 +1,212 @@
#!/bin/bash
#
# $HEADER$
#
# Quick and dirty hack of an mpirun to be used only with the cofs
# "RTE" (if you can call it that). Does not guarantee cleanup just
# yet (still trying to figure out how to make that one work..)
#
# On the other hand, it will get us to MPI_INIT faster than just about
# any other idea I have...
#
######################################################################
#
# Some basic defaults
#
######################################################################
lam_numprocs="1"
lam_hosts="localhost"
lam_debug=0
######################################################################
#
# Global variables
#
######################################################################
lam_hostfile=""
lam_jobhandle=""
lam_app_args=""
lam_mydir=""
lam_cwd="`pwd`"
# Get the dir where this script is
dir="`dirname $0`"
if test "$dir" = "."; then
lam_mydir=`pwd`
else
lam_mydir="$dir"
pushd $lam_mydir 2>&1 > /dev/null
lam_mydir="`pwd`"
popd 2>&1 > /dev/null
fi
unset dir
######################################################################
#
# Do argument parsing (not a function so I have the orig $*)
#
######################################################################
args_err=0
for i ; do
case "${i}" in
-np)
shift
lam_numprocs=${1}
shift
;;
-hostfile)
shift
lam_hostfile=${1}
shift
;;
-d)
shift
lam_debug=1
echo "Debugging output enabled"
;;
-h)
shift
args_err=1
;;
--)
shift
lam_app_args="$@"
;;
esac
done
if test "$args_err" != "0" ; then
echo "usage: mpirun [-np #] [-hostfile file] [-d]"
echo " -np # Start # processes across as many hosts as available"
echo " -hostfile file Read file for list of hosts to use for starting procs"
echo " -d Enable debugging in the mpirun script"
fi
######################################################################
#
# Debugging echo - only prints if debugging is enabled
#
######################################################################
debug_echo() {
if test "$lam_debug" != "0"; then
echo "$*"
fi
}
######################################################################
#
# start_proc
#
# Start a process on the given node. Pushes out required environment
# variables...
#
# ARGUMENTS:
# hostname
# vpid
# argv argv to start
#
######################################################################
start_proc() {
local rmt_hostname=$1 ; shift
local rmt_vpid=$1 ; shift
local argv="$*"
local rmt_boot="${lam_mydir}/mpiboot"
local cmd="ssh ${rmt_hostname} ${rmt_boot} -myvpid ${rmt_vpid}"
cmd="${cmd} -numprocs ${lam_numprocs} -jobhandle ${lam_jobhandle}"
cmd="${cmd} -pwd ${lam_cwd}"
if test ! -z "${MCA_common_lam_cofs_comm_dir}" ; then
cmd="${cmd} -commdir ${MCA_common_lam_cofs_comm_dir}"
fi
cmd="${cmd} -- ${argv}"
debug_echo "* ${cmd}"
${cmd}
}
######################################################################
#
# make_hosts_list
#
# make the lam_hosts list, if a hostfile was specified
#
######################################################################
make_hosts_list() {
if test -z "${lam_hostfile}" ; then
return 0
fi
if ! test -f "${lam_hostfile}" ; then
echo "Could not fine ${lam_hostfile}. Aborting"
exit 1
fi
lam_hosts=""
for i in `cat "${lam_hostfile}"` ; do
if test -z "${lam_hosts}" ; then
lam_hosts="${i}"
else
lam_hosts="${lam_hosts} ${i}"
fi
done
if test -z "${lam_hosts}" ; then
echo "Did not find any valid hostnames in ${lam_hostfile}. Aborting"
exit 1
fi
}
######################################################################
#
# launch procs
#
# fire up a bunch of procs...
#
######################################################################
launch_procs() {
local args="$*"
set -- ${lam_hosts}
local i
if test -z "${args}" ; then
echo "Did not find valid MPI app to start - being a coward and aborting."
exit 1
fi
for (( i=0 ; i < ${lam_numprocs} ; i++)) ; do
start_proc "${1}" "${i}" "${args}"
shift
if test -z "${1}" ; then
set -- ${lam_hosts}
fi
done
}
######################################################################
#
# Do the prep work
#
######################################################################
lam_jobhandle="pcm_cofs_job_handle_${$}_0"
######################################################################
#
# exit cleanly
#
######################################################################
make_hosts_list
launch_procs "${lam_app_args}"
echo ""
echo "Processes should be running. I'm going to exit now. Need to add sleeping"
echo ""
exit 0