/[escript]/trunk/scripts/finley_wrapper_template
ViewVC logotype

Annotation of /trunk/scripts/finley_wrapper_template

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1909 - (hide annotations)
Thu Oct 23 01:47:50 2008 UTC (10 years, 10 months ago) by ksteube
File size: 2050 byte(s)
Updated the wrapper script to set MPI_NUM_MEMORY_REGIONS=0 to avoid
bug where truncated messages are sent in hybrid runs under MPT MPI

1 ksteube 1756 #!/bin/sh
2    
3 ksteube 1824 # Escript/Finley wrapper for python
4     # Sets LD_LIBRARY_PATH and PYTHONPATH and then runs either python or the MPI launcher
5    
6 ksteube 1756 HELP_TEXT="
7     Usage: escript [options] script.py [arguments...]
8     -O N Use N OpenMP threads (OMP_NUM_THREADS=N)
9     -M K Use K MPI processes
10 ksteube 1824 -l 'launcher' MPI launcher, usually -l 'mpirun -np' or -l 'mpiexec -n'
11 ksteube 1756 -L /path Prepend /path to library search path
12     -P /path Prepend /path to python module search path
13     script.py Your python script
14     arguments... The optional command-line arguments to your python script
15     "
16    
17     if [ "$1" = "--help" ]; then
18     echo "$HELP_TEXT"
19     exit 0
20     fi
21    
22     PYTHON_CMD="@@PYTHON_CMD@@"
23    
24     ESCRIPT_ROOT="@@ESCRIPT_ROOT@@"
25    
26 ksteube 1768 export LD_LIBRARY_PATH="@@LD_LIBRARY_PATH@@"
27 ksteube 1756
28 ksteube 1768 export PYTHONPATH="@@PYTHONPATH@@"
29 ksteube 1756
30 ksteube 1909 # Avoid bug in hybrid runs with MPT MPI
31     export MPI_NUM_MEMORY_REGIONS=0
32    
33 ksteube 1756 # Try to guess the MPI launcher (mpirun unless in PBS batch job in which case mpiexec)
34     mpi_launcher='mpirun -np'
35     if [ $?PBS_ENVIRONMENT ]; then
36     if [ "X_$PBS_ENVIRONMENT" = "X_PBS_BATCH" ]; then
37     mpi_launcher='mpiexec -n'
38     fi
39     fi
40    
41     PYTHON_MPI="$ESCRIPT_ROOT/lib/pythonMPI"
42     OMP_NUM_THREADS=1
43     MPI_NUM_PROCS=1
44    
45     # Parse the command-line options
46     while getopts 'L:P:O:M:l:' option
47     do
48     case "$option" in
49     "L") export LD_LIBRARY_PATH="$OPTARG:$LD_LIBRARY_PATH"
50     ;;
51     "P") export PYTHONPATH="$OPTARG:$PYTHONPATH"
52     ;;
53     "O") OMP_NUM_THREADS="$OPTARG"
54     ;;
55     "M") MPI_NUM_PROCS="$OPTARG"
56     ;;
57     "l") mpi_launcher="$OPTARG"
58     ;;
59     ?) echo "$HELP_TEXT"
60     exit 1
61     ;;
62     esac
63     done
64     shift `expr $OPTIND - 1`
65    
66     # Must have at least one command-line arg: the python script
67     if [ $# -eq 0 ]; then
68     echo "Missing python script"
69     echo "$HELP_TEXT"
70     exit 1
71     fi
72    
73     # Using OpenMP?
74     OMP_OPTIONS=''
75     if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.openmp" ]; then
76     PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"
77     OMP_OPTIONS="env OMP_NUM_THREADS=$OMP_NUM_THREADS"
78     fi
79    
80     # Using MPI?
81     if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.mpi" ]; then
82     PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"
83     fi
84    
85     set -x
86     $OMP_OPTIONS time $PYTHON_CMD "$@"
87    

  ViewVC Help
Powered by ViewVC 1.1.26