/[escript]/trunk/run-escript.in
ViewVC logotype

Annotation of /trunk/run-escript.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5092 - (hide annotations)
Mon Jul 7 00:47:44 2014 UTC (5 years, 1 month ago) by sshaw
Original Path: trunk/bin/run-escript
File size: 17319 byte(s)
fixing lack of thread binding for intel-based OpenMP, gcc unaffected
1 caltinay 4927 #!/usr/bin/env sh
2 jfenwick 2409
3     # Escript/Finley wrapper for python
4     # Sets LD_LIBRARY_PATH and PYTHONPATH and then runs either python or the MPI launcher
5    
6     #Extra paths can be configured about a page further down
7     #Search for EXTRA_PATH=""
8    
9 jfenwick 2568 #set to 1 if performing this is a standalone build and ../../pkg contains the relevant tools
10 caltinay 4362 STANDALONE=0
11 jfenwick 2409
12     #set to 1 if this is part of a packaged build (.deb) and files will be installed in standard locations
13     #rather than everything in a single directory
14     #Do not use this together with $STANDALONE
15     STDLOCATION=0
16    
17     #Now we find the location of this script
18     #Note that this location should be absolute but does not need to be unique
19     scriptdir=""
20 caltinay 4970 CURDIR=$(pwd)
21 jfenwick 2409
22     #Environment vars which control operations:
23     # ESCRIPT_NUM_NODES, ESCRIPT_NUM_PROCS, ESCRIPT_NUM_THREADS, ESCRIPT_HOSTFILE, ESCRIPT_CREATESTDFILES
24    
25 sshaw 5092 #set up thread binding if unset
26     if [ "$OMP_PROC_BIND" == "" ]; then
27     #Force OpenMP binding for Intel (and GCC, though GCC is on by default)
28     export OMP_PROC_BIND=true
29     fi
30     if [ "$KMP_AFFINITY" == "" ]; then
31     #Set the style of binding (overrides OMP_PROC_BIND in many cases)
32     export KMP_AFFINITY=verbose,compact
33     fi
34    
35 jfenwick 3047 HOSTFILE=/tmp/escript.$USER.$$
36     HOSTFILE2=/tmp/escript2.$USER.$$
37 jfenwick 2409
38     #Begin finding ESCRIPT_ROOT
39 caltinay 2806 if [ $STDLOCATION -ne 0 ]
40 jfenwick 2409 then
41 caltinay 4491 ESCRIPT_ROOT=/usr/lib/python-escript
42 jfenwick 2409 else
43 caltinay 4031 # We don't know the escript root so we need to work it out from the invocation
44     # Need to match if the name contains /
45 caltinay 4927 if $(echo $0|grep -q /)
46 jfenwick 2409 then
47     # We are not using the PATH to find the script
48 caltinay 4970 cd "$(dirname $0)"
49     scriptdir=$(pwd)
50 caltinay 3388 cd "$CURDIR"
51 jfenwick 2409 else
52 caltinay 4927 # name does not contain / therefore we are using
53 caltinay 4970 tscriptdir=$(which $0)
54 caltinay 3096 if [ $? -ne 0 ]
55 jfenwick 2409 then
56 caltinay 2806 echo "Error! Unable to determine script directory. Exiting."
57     exit 1
58 jfenwick 2409 fi
59 caltinay 4970 scriptdir=$(dirname $tscriptdir)
60 jfenwick 2409 fi
61    
62 caltinay 3388 cd "$scriptdir/.."
63 caltinay 4970 ESCRIPT_ROOT=$(pwd)
64 jfenwick 2409 cd ..
65 caltinay 4970 ESCRIPT_PARENT=$(pwd)
66 caltinay 3388 cd "$CURDIR"
67 jfenwick 2409
68     fi
69 caltinay 4031 ##### End finding ESCRIPT_ROOT ########
70 jfenwick 2409
71     PYTHON_MPI_NULL="$ESCRIPT_ROOT/lib/pythonMPI"
72     PYTHON_MPI_REDIRECT="$ESCRIPT_ROOT/lib/pythonMPIredirect"
73     PYTHON_CMD=python
74    
75     # if possible please express paths relative to $ESCRIPT_ROOT unless
76     # they are in an unrelated location
77    
78     EXTRA_DYLD_LIBRARY_PATH=""
79     EXTRA_PATH=$ESCRIPT_ROOT/bin
80     EXTRA_PYTHONPATH=$ESCRIPT_ROOT
81    
82 jfenwick 4078 if [ $STDLOCATION -eq 1 ]
83     then
84 caltinay 4491 EXTRA_LD_LIBRARY_PATH=/usr/lib/python-escript
85 jfenwick 4078 else
86     EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib
87     fi
88    
89    
90 caltinay 2806 if [ $STANDALONE -eq 1 ]
91 jfenwick 2409 then
92 jfenwick 3335 EXTRA_PATH=$ESCRIPT_PARENT/pkg/python/bin:$ESCRIPT_PARENT/pkg/scons/bin:$EXTRA_PATH
93 jfenwick 2530 EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/pkg/boost/lib:$ESCRIPT_PARENT/pkg/netcdf/lib/:$EXTRA_LD_LIBRARY_PATH
94 jfenwick 2541 EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH
95 jfenwick 2530 EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/pkg/python/lib:$EXTRA_LD_LIBRARY_PATH
96 jfenwick 2541 EXTRA_PYTHONPATH=$ESCRIPT_PARENT/pkg/numpy/lib/python2.6/site-packages:$ESCRIPT_PARENT/pkg/matplotlib/lib/python2.6/site-packages:$EXTRA_PYTHONPATH
97 jfenwick 2409 fi
98    
99 jfenwick 3335
100 jfenwick 4342 BUILDINFO_FILE="$ESCRIPT_ROOT/lib/buildvars"
101 jfenwick 4078 if [ "$STDLOCATION" = "1" ]
102     then
103 caltinay 4491 BUILDINFO_FILE=/usr/lib/python-escript/buildvars
104 jfenwick 4078 fi
105 jfenwick 4342 if [ ! -r "$BUILDINFO_FILE" ]; then
106 caltinay 4031 if [ "$1" = "-e" ]; then
107     echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
108     echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
109     echo "export PATH=$EXTRA_PATH:\$PATH"
110 caltinay 4970 if [ "$(uname)" = "Darwin" ]
111 caltinay 4031 then
112     echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
113 caltinay 4927 fi
114 jfenwick 3335 exit 0
115     fi
116     echo "Error! Unable to read escript build information. Exiting."
117     exit 1
118     fi
119    
120 caltinay 4031 get_buildvar () {
121 caltinay 4970 echo $(grep "^$1=" "$BUILDINFO_FILE" |cut -d= -f2)
122 jfenwick 3335 }
123    
124 caltinay 3096 #
125     # Add VisIt paths if required
126     #
127 caltinay 4970 WITH_VISIT=$(get_buildvar visit)
128 jfenwick 3259 if [ "$WITH_VISIT" = "1" ]; then
129 caltinay 4970 VISIT_BIN=$(which visit 2>/dev/null)
130 caltinay 3096 if [ $? -eq 0 ]; then
131 caltinay 4970 VISIT_PY_PATH=$($VISIT_BIN -env | grep LIBPATH | cut -d= -f2)
132 caltinay 3096 EXTRA_PYTHONPATH=$EXTRA_PYTHONPATH:$VISIT_PY_PATH
133     EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$VISIT_PY_PATH
134     elif [ ! -z $ESCRIPT_VERBOSE ]; then
135     echo "VisIt module enabled but VisIt not in path!"
136     fi
137     fi
138 jfenwick 2409
139     HELP_TEXT="
140 caltinay 4031 Usage: run-escript [options] script.py [arguments...]
141 jfenwick 2409 -n nn number of nodes to use
142 gross 3193 -p np number of MPI processes to spawn per node
143 jfenwick 2409 -t nt number of OpenMP threads to use
144     -f file name of MPI hostfile
145 caltinay 4031 -c print compile information for escript and exit
146 jfenwick 2409 -V print escript version and exit
147 caltinay 4927 -i interactive mode
148 jfenwick 2409 -b do not invoke python (run non-python programs)
149     -e print export statements for environment and exit
150     -o redirect output from MPI to files
151     -v print diagnostics
152 caltinay 4031 -x run in new xterm instance
153 caltinay 4506 -m tool run with valgrind {tool=m[emcheck]/c[allgrind]}
154 jfenwick 2409 script.py Your python script
155     arguments... The optional command-line arguments to your script
156     "
157    
158     if [ "$1" = "--help" ]; then
159     echo "$HELP_TEXT"
160     exit 0
161     fi
162 caltinay 4031 #==============================================================================
163 jfenwick 2409
164     # Parse the command-line options
165 caltinay 4506 while getopts 'bn:p:t:f:echim:oVvx' option
166 jfenwick 2409 do
167 caltinay 4031 case "$option" in
168     "b") DO_BINARY=y
169     ;;
170 caltinay 4506 "m") DO_VALGRIND=$OPTARG
171 caltinay 4483 ;;
172 caltinay 4031 "n") ESCRIPT_NUM_NODES=$OPTARG
173     ;;
174     "p") ESCRIPT_NUM_PROCS=$OPTARG
175     ;;
176     "t") ESCRIPT_NUM_THREADS=$OPTARG
177     ;;
178     "f") ESCRIPT_HOSTFILE=$OPTARG
179     ;;
180 jfenwick 4342 "c") cat "$BUILDINFO_FILE"
181 caltinay 4031 exit 0
182     ;;
183 caltinay 4970 "V") echo "escript-development(build "$(get_buildvar svn_revision)")"
184 caltinay 4031 exit 0
185     ;;
186     "h") echo "$HELP_TEXT"
187     exit 0
188     ;;
189     "i") DO_INTERACTIVE=y
190     ;;
191     "e") echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
192     echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
193     echo "export PATH=$EXTRA_PATH:\$PATH"
194 caltinay 4970 if [ "$(uname)" = "Darwin" ]
195 caltinay 4031 then
196     echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
197     fi
198     exit 0
199     ;;
200     "o") ESCRIPT_CREATESTDFILES=y
201     ;;
202     "v") ESCRIPT_VERBOSE=y
203     ;;
204     "x") DO_XTERM=y
205     ;;
206     ?) echo "$HELP_TEXT"
207     exit 1
208     ;;
209     esac
210 jfenwick 2409 done
211 caltinay 4970 shift $(($OPTIND - 1))
212 jfenwick 2409 #==============================================
213     #
214 caltinay 3178 # Read MPI_FLAVOUR and WITH_OPENMP from the buildvars
215 jfenwick 2409 #
216 caltinay 4970 MPI_FLAVOUR=$(get_buildvar mpi)
217     WITH_OPENMP=$(get_buildvar openmp)
218 jfenwick 2409
219 caltinay 2806 if [ ! -z $ESCRIPT_VERBOSE ]; then
220     echo "MPI flavour is $MPI_FLAVOUR."
221 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]; then echo "OpenMP enabled."; fi
222 caltinay 2806 fi
223    
224 jfenwick 2409 #
225     # extend path variables
226     #
227     export PATH=$EXTRA_PATH:$PATH
228     export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH
229     export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH
230     EXPORT_ENV="PATH,LD_LIBRARY_PATH,PYTHONPATH"
231 caltinay 4970 if [ "$(uname)" = "Darwin" ]
232 jfenwick 2409 then
233     export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH
234     EXPORT_ENV="$EXPORT_ENV,DYLD_LIBRARY_PATH"
235     fi
236 caltinay 4927 if [ ! -z $ESCRIPT_VERBOSE ]
237     then
238 jfenwick 2409 echo "PATH = $PATH "
239     echo "LD_LIBRARY_PATH = $LD_LIBRARY_PATH "
240     echo "PYTHONPATH = $PYTHONPATH "
241     if [ ! -z $DYLD_LIBRARY_PATH ]; then echo "DYLD_LIBRARY_PATH = $DYLD_LIBRARY_PATH "; fi
242     fi
243     #==============================================
244     #
245     # Ensure the variables have sensible values
246     #
247 caltinay 4927 if [ "$MPI_FLAVOUR" = "none" ]
248 jfenwick 2409 then
249 caltinay 4664 if [ ! -z "$ESCRIPT_NUM_NODES" ]; then
250     if [ $ESCRIPT_NUM_NODES -gt 1 ]; then
251     echo "Warning: MPI disabled but number of nodes set. Option ignored."
252     fi
253 jfenwick 2409 fi
254 caltinay 4664 if [ ! -z "$ESCRIPT_NUM_PROCS" ]; then
255     if [ $ESCRIPT_NUM_PROCS -gt 1 ]; then
256     echo "Warning: MPI disabled but number of processors per node set. Option ignored."
257     fi
258 jfenwick 2409 fi
259 jfenwick 4342 if [ ! -z "$ESCRIPT_HOSTFILE" ]
260 jfenwick 2409 then
261     echo "Warning: MPI disabled but host file is given. Option ignored."
262     fi
263     ESCRIPT_NUM_NODES=1
264     ESCRIPT_NUM_PROCS=1
265     else
266 jfenwick 3056 # use the PBS_NODEFILE if not otherwise specified
267 jfenwick 4342 if [ ! -z "$PBS_NODEFILE" ] && [ -z "$ESCRIPT_HOSTFILE" ]
268 jfenwick 3056 then
269 caltinay 3178 ESCRIPT_HOSTFILE=$PBS_NODEFILE
270 jfenwick 3056 fi
271    
272 caltinay 4927 if [ ! -z "$ESCRIPT_HOSTFILE" ]
273 jfenwick 2409 then
274 jfenwick 4342 if [ -f "$ESCRIPT_HOSTFILE" ]
275 jfenwick 2409 then
276 jfenwick 4342 cat "$ESCRIPT_HOSTFILE" | sort -u > $HOSTFILE
277 caltinay 4970 NUM_HOSTS=$(cat "$HOSTFILE" | wc -l)
278 caltinay 4927 if [ ! -z $ESCRIPT_NUM_NODES ]
279 jfenwick 2409 then
280     if [ $NUM_HOSTS -ne $ESCRIPT_NUM_NODES ]
281     then
282     echo "number of hosts selected in the host file $ESCRIPT_HOSTFILE needs to match the requested number of nodes $ESCRIPT_NUM_NODES."
283     exit 1
284     fi
285     else
286     ESCRIPT_NUM_NODES=$NUM_HOSTS
287     fi
288     else
289     echo "cannot find hostfile $ESCRIPT_HOSTFILE."
290     exit 1
291     fi
292     else
293     HOSTFILE=''
294     fi
295    
296     if [ -z $ESCRIPT_NUM_NODES ]
297     then
298 caltinay 3178 ESCRIPT_NUM_NODES=1
299 jfenwick 2409 fi
300    
301     if [ -z $ESCRIPT_NUM_PROCS ]
302     then
303 caltinay 3178 ESCRIPT_NUM_PROCS=1
304 jfenwick 2409 fi
305    
306 caltinay 2806 if [ ! -z $ESCRIPT_VERBOSE ]
307 caltinay 4927 then
308 caltinay 3178 echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "
309     echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "
310 jfenwick 2409 fi
311     fi
312    
313 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]
314 jfenwick 2409 then
315     if [ -z $ESCRIPT_NUM_THREADS ]
316     then
317     ESCRIPT_NUM_THREADS=$OMP_NUM_THREADS
318     if [ -z $ESCRIPT_NUM_THREADS ]
319     then
320     ESCRIPT_NUM_THREADS=1
321     fi
322     fi
323     if [ ! -z $ESCRIPT_VERBOSE ]
324     then
325     echo "ESCRIPT_NUM_THREADS is $ESCRIPT_NUM_THREADS."
326     fi
327     else
328 caltinay 4031 if [ ! -z $ESCRIPT_NUM_THREADS ] && [ $ESCRIPT_NUM_THREADS != 1 ]
329 jfenwick 2409 then
330     echo "Warning: OpenMP is disabled but number of threads requested is $ESCRIPT_NUM_THREADS!=1. Running without threads."
331     fi
332     ESCRIPT_NUM_THREADS=1
333     fi
334     #
335     # Now we compute total number of Processes
336     #
337 caltinay 4031 TOTPROC=$((ESCRIPT_NUM_NODES * ESCRIPT_NUM_PROCS))
338 caltinay 4927 if [ $? -ne 0 ] #Some compute error
339 caltinay 4031 then #This could happen if the args were not a number
340 caltinay 3178 echo "expression of total number of processors = $ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS is not numerical."
341     exit 1
342 jfenwick 2409 fi
343    
344     #
345     # Test to ensure people aren't trying to combine interactive and multi-process
346     #
347 caltinay 4058 if ([ ! -z $DO_INTERACTIVE ] || [ $# -eq 0 ]) && ([ $TOTPROC -gt 1 ])
348 jfenwick 2409 then
349 caltinay 3178 echo "Interactive mode cannot be used with more than one process"
350     exit 1
351 jfenwick 2409 fi
352    
353 caltinay 4927 if [ $TOTPROC -gt 1 ]
354 jfenwick 2409 then
355 caltinay 4322 if [ "$ESCRIPT_CREATESTDFILES" = "y" ]
356 caltinay 3178 then
357     PYTHON_MPI=$PYTHON_MPI_REDIRECT
358     else
359     PYTHON_MPI=$PYTHON_MPI_NULL
360     fi
361 jfenwick 2409 else
362     PYTHON_MPI=$PYTHON_MPI_NULL
363     fi
364 caltinay 4031 #==============================================================================
365 jfenwick 2409 # Must have at least one command-line arg: the python script
366     if [ $# -eq 0 ]
367     then
368 caltinay 4031 if [ ! -z $DO_BINARY ]
369 caltinay 3178 then
370     echo "No program to run was specified. Exiting."
371     exit 1
372     else
373 caltinay 4031 DO_INTERACTIVE=y
374 caltinay 3178 fi
375 jfenwick 2409 fi
376    
377 caltinay 4031 #==============================================================================
378 caltinay 4483
379 caltinay 4031 if [ ! -z $DO_XTERM ]
380 jfenwick 2409 then
381 caltinay 4031 EXEC_CMD="xterm -e"
382 jfenwick 2409 else
383 caltinay 4031 EXEC_CMD=""
384     fi
385    
386 caltinay 4483 if [ ! -z "$DO_VALGRIND" ]
387     then
388 caltinay 4970 VALGRIND_BIN=$(which valgrind 2>/dev/null)
389 caltinay 4483 if [ $? -eq 0 ]; then
390 caltinay 4506 LOGDIR=$ESCRIPT_ROOT/valgrind_logs
391 caltinay 4483 [ -d $LOGDIR ] || mkdir $LOGDIR
392 caltinay 4970 VG_TOOL=$(echo $DO_VALGRIND | awk '{ s=substr($0,1,1);print s;}')
393     if [ $VG_TOOL = "c" ];
394 caltinay 4506 then
395     # run callgrind
396     LOGFILE=${LOGDIR}/callgrind.%p.xml
397     VALGRIND="valgrind --tool=callgrind --callgrind-out-file=$LOGFILE"
398     EXEC_CMD="$EXEC_CMD $VALGRIND"
399     else
400     # run memcheck by default
401 caltinay 4970 LAST_N=$(ls -1 $LOGDIR|grep "^memcheck"|tail -1|cut -d. -f2)
402     NEW_N=$(printf "%04d" $((LAST_N + 1)))
403 caltinay 4506 LOGFILE=${LOGDIR}/memcheck.${NEW_N}.xml
404     VALGRIND="valgrind --tool=memcheck --xml=yes --show-reachable=yes --error-limit=no --gen-suppressions=all --suppressions=$ESCRIPT_ROOT/scripts/escript.supp --leak-check=full --xml-file=$LOGFILE"
405     EXEC_CMD="$EXEC_CMD $VALGRIND"
406     fi
407 caltinay 4483 else
408 caltinay 4506 echo "Execution with valgrind requested but valgrind not in path!"
409 caltinay 4483 exit 1
410     fi
411     fi
412    
413 caltinay 4031 if [ ! -z $DO_BINARY ]
414     then
415     EXEC_CMD="$EXEC_CMD $@"
416     else
417 caltinay 3178 # Check to see if the python version we were compiled with matches the
418     # one of PYTHON_CMD.
419 caltinay 4970 compfull=$(get_buildvar python_version)
420     compversion=$(echo $compfull | cut -d. -f1,2)
421     compmajor=$(echo $compfull | cut -d. -f1)
422 caltinay 4031 if [ "$PYTHON_CMD" = "python" ] # if people have customised the command they
423 jfenwick 3892 then # might not want us changing it
424     if [ "$compmajor" = "3" ]
425     then
426     PYTHON_CMD=python3
427     fi
428     fi
429 caltinay 4970 intversion=$($PYTHON_CMD -c 'from __future__ import print_function;import sys;print("%d.%d"%(sys.version_info[0], sys.version_info[1]))')
430 caltinay 3178 if [ "$compversion" != "$intversion" ]
431     then
432     echo "Python versions do not match. Escript was compiled for "$compversion"."
433     echo "Current version of Python appears to be "$intversion"."
434     exit 1
435     fi
436 caltinay 2806 if [ "$MPI_FLAVOUR" = "none" ]
437 jfenwick 2409 then
438 caltinay 4031 if [ ! -z $DO_INTERACTIVE ]
439 jfenwick 2409 then
440 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_CMD -i $@"
441 jfenwick 2409 else
442 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_CMD $@"
443 jfenwick 2409 fi
444     else
445 caltinay 4031 if [ ! -z $DO_INTERACTIVE ]
446 gross 2865 then
447 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_MPI -i $@"
448 gross 2865 else
449 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_MPI $@"
450 gross 2865 fi
451 jfenwick 2409 fi
452     fi
453     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Command to be executed is \"$EXEC_CMD\"."; fi
454 caltinay 4031 #==============================================================================
455 jfenwick 2409 #
456 caltinay 4031 # now we start to spawn things:
457 jfenwick 2409 #
458 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]
459 jfenwick 2409 then
460     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS
461     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"
462     fi
463     EXIT_CODE=1
464     #=============== no MPI ===================================
465 caltinay 4927 if [ "$MPI_FLAVOUR" = "none" ]
466 jfenwick 2409 then
467 caltinay 4927 $EXEC_CMD
468 jfenwick 2409 EXIT_CODE=$?
469     #=============== OpenMPI ===================================
470 caltinay 4927 elif [ "$MPI_FLAVOUR" = "OPENMPI" ]
471     then
472     EXPORT_ENV=$(echo $EXPORT_ENV|sed -e 's/,/ -x /g')
473     if [ ! -z "$HOSTFILE" ]
474 jfenwick 2409 then
475 caltinay 4970 HOST_LIST=$(sort -u "$HOSTFILE" | awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}')
476 caltinay 4927 CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV} --bynode --bind-to-none --host $HOST_LIST -np $TOTPROC $EXEC_CMD"
477 jfenwick 2409 else
478 caltinay 4927 CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV} --cpus-per-rank $ESCRIPT_NUM_THREADS -np $TOTPROC $EXEC_CMD"
479     fi
480 jfenwick 2409 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
481     $CMD
482     EXIT_CODE=$?
483    
484     #=============== Intel MPI ===================================
485 caltinay 2806 elif [ "$MPI_FLAVOUR" = "INTELMPI" ]
486 jfenwick 2409 then
487 gross 2510
488 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]
489 gross 2510 then
490     export I_MPI_PIN_DOMAIN=omp
491 caltinay 4927 EXPORT_ENV="$EXPORT_ENV,I_MPI_PIN_DOMAIN"
492 gross 2510 fi
493    
494 caltinay 4927 if [ ! -z "$HOSTFILE" ]
495 jfenwick 2409 then
496 sshaw 4993 CMD="mpirun -hostfile $HOSTFILE -n $TOTPROC -ppn $ESCRIPT_NUM_PROCS $EXEC_CMD"
497 gross 2866 else
498 sshaw 4993 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Empty hostfile, running on single node"; fi
499     CMD="mpirun -n 1 -ppn $ESCRIPT_NUM_PROCS $EXEC_CMD"
500 jfenwick 2409 fi
501     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
502     $CMD
503     EXIT_CODE=$?
504     #=============== SGI's MPIMPT ===================================
505 caltinay 2806 elif [ "$MPI_FLAVOUR" = "MPT" ]
506 jfenwick 2409 then
507     export MPI_NUM_MEMORY_REGIONS=0
508     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"
509 caltinay 4927 if [ ! -z "$HOSTFILE" ]
510 jfenwick 2409 then
511 caltinay 4970 HOST_LIST=$(awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}' "$HOSTFILE")
512 gross 2866 CMD="mpirun $HOST_LIST -np $ESCRIPT_NUM_PROCS $EXEC_CMD"
513 jfenwick 2409 else
514     CMD="mpirun -np $TOTPROC $EXEC_CMD"
515 caltinay 4927 fi
516 jfenwick 2409 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
517     $CMD
518     EXIT_CODE=$?
519     #=============== MPICH ===================================
520 caltinay 2806 elif [ "$MPI_FLAVOUR" = "MPICH" ]
521 jfenwick 2409 then
522 caltinay 4927 if [ ! -z "$HOSTFILE" ]
523 jfenwick 2409 then
524 jfenwick 4342 touch "$HOSTFILE2"
525 caltinay 4970 for i in $(seq $ESCRIPT_NUM_PROCS); do cat "$HOSTFILE" >> "$HOSTFILE2"; done
526 caltinay 4927 CMD="mpirun -machinefile \"$HOSTFILE2\" -np $TOTPROC $EXEC_CMD"
527 jfenwick 2409 else
528     CMD="mpirun -np $TOTPROC $EXEC_CMD"
529 caltinay 4927 fi
530 jfenwick 2409 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
531     $CMD
532     EXIT_CODE=$?
533     #=============== MPICH2 ===================================
534 caltinay 2806 elif [ "$MPI_FLAVOUR" = "MPICH2" ]
535 jfenwick 2409 then
536 caltinay 4927 if [ ! -z "$HOSTFILE" ]
537 jfenwick 2409 then
538 jfenwick 4342 mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f "$HOSTFILE"
539 caltinay 4927 if [ $? -ne 0 ]
540 jfenwick 2409 then
541 sshaw 4993 echo "mpdboot with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes failed."
542 jfenwick 2409 exit 1
543 caltinay 4927 else
544 sshaw 4973 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi
545 jfenwick 2409 fi
546 gross 2866 else
547 caltinay 4927 mpdboot -n 1 -r ssh
548     if [ $? -ne 0 ]
549 gross 2866 then
550     echo "mpdboot failed."
551     exit 1
552 caltinay 4927 else
553 gross 2866 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
554     fi
555 jfenwick 2409 fi
556     CMD="mpiexec -genvlist $EXPORT_ENV -np $TOTPROC $EXEC_CMD"
557     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
558     $CMD
559     EXIT_CODE=$?
560 gross 2866 mpdallexit
561     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
562 jfenwick 2409 else
563 caltinay 2806 echo "unknown MPI flavour '$MPI_FLAVOUR'."
564 jfenwick 2409 fi
565 caltinay 4970
566     if [ ! -z "$DO_VALGRIND" ]; then
567     echo "Valgrind log file written to ${LOGFILE}"
568     fi
569    
570 jfenwick 2409 exit $EXIT_CODE
571 caltinay 4031

Properties

Name Value
svn:executable *
svn:mergeinfo /branches/3.4/bin/run-escript:4453-4490 /branches/lapack2681/bin/escript:2682-2741 /branches/pasowrap/bin/run-escript:3661-3674 /branches/py3_attempt2/bin/run-escript:3871-3891 /branches/release3.4/bin/run-escript:4452 /branches/restext/bin/escript:2610-2624 /branches/ripleygmg_from_3668/bin/run-escript:3669-3791 /branches/stage3.0/bin/escript:2569-2590 /branches/symbolic_from_3470/bin/run-escript:3471-3974 /branches/symbolic_from_3470/ripley/test/python/bin/run-escript:3517-3974 /release/3.0/bin/escript:2591-2601 /trunk/ripley/test/python/bin/run-escript:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26