File: mpirun.ch_p4.in

package info (click to toggle)
mpich 1.1.0-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 22,116 kB
  • ctags: 27,349
  • sloc: ansic: 193,435; sh: 11,172; fortran: 6,545; makefile: 5,801; cpp: 5,020; tcl: 3,548; asm: 3,536; csh: 1,079; java: 614; perl: 183; awk: 168; sed: 70; f90: 62
file content (246 lines) | stat: -rwxr-xr-x 7,473 bytes parent folder | download | duplicates (2)
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#! /bin/sh
#
if [ -z "$MPIR_HOME" ] ; then 
    MPIR_HOME=#MPIR_HOME#
fi
if [ "$MPIR_HOME" = "#""MPIR_HOME""#" ] ; then
    MPIR_HOME=`pwd`/..
fi
if [ "#MPIRUN_BIN#" = "#""MPIRUN_BIN""#" ] ; then 
    MPIRUN_HOME=$MPIR_HOME/bin
else
    MPIRUN_HOME=$MPIR_HOME/#MPIRUN_BIN#
fi
if [ -z "$argsset" ] ; then
   . $MPIRUN_HOME/mpirun.args
   argsset=1
fi
#
if [ -n "$MPI_P4SSPORT" ] ; then
    if [ "$MPI_USEP4SSPORT" = "yes" -o "$MPI_USEP4SSPORT" = "YES" ] ; then
        p4ssport=$MPI_P4SSPORT
    fi
fi
# Make sure that the application is in the .p4apps file.  Note that 
# progname is already an absolute path
if [ -n "$p4ssport" ] ; then
    if [ -z "$HOME" ] ; then
	echo "Cannot determine location of home directory (in HOME)"
	exit 1
    fi
    if [ -r $HOME/.p4apps ] ; then
        grep $progname $HOME/.p4apps > /dev/null 2>&1
        if [ $? != 0 ] ; then 
	    echo "$progname" >> $HOME/.p4apps
            chmod 600 $HOME/.p4apps
	fi
    else
	echo "$progname" >> $HOME/.p4apps
        chmod 600 $HOME/.p4apps
    fi
    cmdLineArgs="$cmdLineArgs -p4ssport $p4ssport"
fi
#
# Construct the procgroup file
. $MPIRUN_HOME/mpirun.pg
# machinelist has the hosts
# archuselist has the architectures
# nprocuselist has the number of processors
#
# We use this form instead of "local 0" in-case the user is trying to
# select a second network whose names are not those returned by
# "hostname".  For example, a system with a DEC Gigiswitch, Myricom 
# network, or IP over the IBM SP2 switch (HPS).
prognamemain=$progname
if [ -z "$p4pgfile"  ] ; then
    p4pgfile="$PWD_TRIAL/PI$$"
    echo "Test" > $p4pgfile
    if [ ! -s $p4pgfile ] ; then
	# May not be able to write there.  Try the user's home directory
	p4pgfile=$HOME/PI$$
    else
	/bin/rm -rf $p4pgfile
    fi
    # cnt is the "index" into the list of machines
    procNum=1
#    archval=`echo $archuselist | cut -d' ' -f1`
    nprocval=`echo $nprocuselist | cut -d' ' -f1`
    # for the "local" entry, the number is the number of ADDITIONAL 
    # processes.
    if [ -z "$nprocval" ] ; then
	# just in case...
	nprocval=1
    fi
    nprocval=`expr $nprocval - 1`
    archval=$archlocal
    proginstance=`echo $progname | sed "s/%a/$archval/g"`
    prognamemain=$proginstance
    if [ $just_testing = 1 ] ; then
       echo "Procgroup file:"
       if [ $nolocal = 0 ] ; then
	    nprocval=0
	    echo "$MPI_HOST $nprocval $proginstance"
       else 
	    echo "$machinehead $nprocval $proginstance"
            procNum=2
       fi
    else
       if [ $nolocal = 0 ] ; then
	    if [ -z "$MPI_HOST" ] ; then
		echo "No value for MPI_HOST!"
	        echo "MPI_HOST is set either from your environment or by"
		echo "processing for an MPI machine type of ch_p4, ch_tcp, "
		echo "ch_nexus, or sgi_mp.  The machine type you used was $machine ."
		echo "Use the -machine <machinename> argument to select a "
		echo "specific machine type."
	        exit 1
	    fi
	    nprocval=0
	    echo "$MPI_HOST $nprocval $proginstance" > $p4pgfile
       else
	    echo "$machinehead $nprocval $proginstance" > $p4pgfile
            procNum=2
       fi
    fi
    cnt=1
    for machine in $machinelist ; do 
	if [ $procNum = 2 ] ; then 
	    procNum=1; cnt=`expr $cnt + 1`; continue ; 
	fi
	archval=`echo $archuselist | cut -d' ' -f$cnt`
	nprocval=`echo $nprocuselist | cut -d' ' -f$cnt`
	cnt=`expr $cnt + 1`
	proginstance=`echo $progname | sed "s/%a/$archval/g"`
	if [ $just_testing = 1 ] ; then
	    echo $machine $nprocval $proginstance
	else
	    echo $machine $nprocval $proginstance >> $p4pgfile
	fi
    done

    # make sure the procgroup file was written
    if [ $just_testing = 0 -a \! -r "$p4pgfile" ] ; then
        echo Failed to write "$p4pgfile".  Exiting.
        exit 1
    fi

    if [ $just_testing = 0 -a $mpirun_verbose = 1 ] ; then
      echo Created "$p4pgfile"
    fi
fi
#
# On nfs systems, it is possible that a recently created executable may 
# not be visible yet to other systems, causing problems when you attempt
# to start a job.  As a partial fix for this, we do a sync.  It would help,
# of course, if NFS worked correctly.
#
#SYNCLOC# > /dev/null 2>&1
#

#
# Handle debuggers
#
#startpgm="eval"
startpgm="$prognamemain $cmdLineArgs -p4pg $p4pgfile"
# The following could use the -stdin filename from mpirun, though
# it doesn't handle the problem of the created jobs.
#if [ -n "$stdinfile" ] ; then
# startpgm="$startpgm < $stdinfile"
#fi
if [ "$debugger" != "" ] ; then
    if [ "$debugger" = "totalview" ] ; then
        if [ "$TOTALVIEW" = "" ] ; then
	   TOTALVIEW="totalview"
        fi
        startpgm="$TOTALVIEW $prognamemain -a $cmdLineArgs -p4pg $p4pgfile -mpichtv"	        
    else
        dbgfile=$PWD_TRIAL/PId$$
        echo "Test" > $dbgfile
        if [ -s $dbgfile ] ; then
	    /bin/rm -f $dbgfile
        else
            dbgfile=$HOME/PId$$
        fi
        # If gdb has an equivalent, the documentation is well hidden.
        #  - .gdbinit - and the documentation IS well hidden.  Fortunately,
        # the .gbdinit file is read; gdb provides the -nx (instead of -x)
        # command if you don't want to read the default init file.
        if [ "$debugger" = "dbx" -a -r $HOME/.dbxinit ] ; then
	    cat $HOME/.dbxinit > $dbgfile
# DEC dbx requires
#    set stopall_on_step = 1
# for proper behavior
        fi
        # Regretably, xxgdb does NOT provide this argument (even though it
        # claims to).
    #    if [ "$debugger" = "xxgdb" -a -r $HOME/.gdbinit ] ; then
    #	cat $HOME/.gdbini > $dbgfile
    #    fi
        # handle USR1 pass for gdb; add an initial break 
        if [ "$debugger" = "gdb" -o "$debugger" = "xxgdb" -o \
	     "$debugger" = "ddd" ] ; then
	    echo "handle SIGUSR1 nostop pass" >> $dbgfile
	    echo "br MPI_Init" >> $dbgfile
	    echo "set args $cmdLineArgs -p4pg $p4pgfile" >> $dbgfile
	    echo "run" >> $dbgfile
        else 
            echo "ignore USR1" >> $dbgfile
            # This may not work, depending on when the symbol table is read.
            # An alternative is to use the startup file to load the 
            # program with "debug $prognamemain" ,followed with this, followed
	    # with run command args.
	    echo "debug $prognamemain" >> $dbgfile
   	    echo "stop in MPI_Init" >> $dbgfile
	    echo "run $cmdLineArgs -p4pg $p4pgfile" >> $dbgfile
        fi
    #	cat >> $dbgfile <<.
    ## Use this command to start your programm:
    #run  $cmdLineArgs -p4pg $p4pgfile
    #.
	    commandfile=`echo $commandfile | sed -e s@%f@$dbgfile@g`
	    startpgm="$debugger $commandfile $prognamemain"
    fi
fi
#
# Pass to the program that the device is ch_p4
#
MPIRUN_DEVICE="ch_p4"
export MPIRUN_DEVICE
#
# Build a suitable command for the whole thing
#
if [ $just_testing = 1 ] ; then
  doitall="echo"
else
  doitall=""
fi
#
# Add rsh'ery if requested
#
if [ $nolocal = 1 ] ; then
    doitall="$doitall $rshcmd $machinehead"
fi

$doitall $startpgm

#else
#  if [ $nolocal = 1 ] ; then
#    if [ "$debugger" != "" ] ; then
#	  $rshcmd $machinehead $debugger $commandfile $prognamemain
#    else
#	  $rshcmd $machinehead $prognamemain $cmdLineArgs -p4pg "$p4pgfile"
#    fi
#  else
#   if [ "$debugger" != "" ] ; then
#	    $debugger $commandfile $prognamemain
#    else
#	    $prognamemain $cmdLineArgs -p4pg "$p4pgfile"
#    fi
#  fi # nolocal
if [ $just_testing != 1 ] ; then
  if [ $leavePGFile = 1 ] ; then
	echo "P4 procgroup file is $p4pgfile."
  else
    /bin/rm "$p4pgfile"
  fi
fi #just testing