1 | if [ -d /opt/oar/current/bin/ ] |
---|
2 | then |
---|
3 | export PATH=${PATH}:/opt/oar/current/bin/ |
---|
4 | export MANPATH=${MANPATH}:/opt/oar/current/man/ |
---|
5 | |
---|
6 | # OpenMPI connector |
---|
7 | export OMPI_MCA_plm_rsh_agent=oarsh |
---|
8 | |
---|
9 | # MPI NodeFile on second interface eth1 |
---|
10 | OAR_MSG_NODEFILE=${OAR_NODEFILE}-msg |
---|
11 | [ -e "${OAR_MSG_NODEFILE}" ] && export OAR_MSG_NODEFILE |
---|
12 | |
---|
13 | function oar_fixldpath () { |
---|
14 | if [ -n "${LD_LIBRARY_PATH:+x}" ] |
---|
15 | then |
---|
16 | for ldpath in $(for lib in $(/sbin/ldconfig -p | awk 'BEGIN { FS = "=> " } ; {print $2}'); do dirname ${lib}; done | sort -u) |
---|
17 | do |
---|
18 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ldpath}" |
---|
19 | done |
---|
20 | fi |
---|
21 | } |
---|
22 | declare -fx oar_fixldpath |
---|
23 | |
---|
24 | function oar_mpirun () { |
---|
25 | local exists_np='' |
---|
26 | local exists_mf='' |
---|
27 | local exists_vb='' |
---|
28 | |
---|
29 | for opt in $* |
---|
30 | do |
---|
31 | [ "${opt}" == "-np" ] && exists_np='y' |
---|
32 | [ "${opt}" == "-machinefile" ] && exists_mf='y' |
---|
33 | [ "${opt}" == "--machinefile" ] && exists_mf='y' |
---|
34 | [ "${opt}" == "-hostfile" ] && exists_mf='y' |
---|
35 | [ "${opt}" == "--hostfile" ] && exists_mf='y' |
---|
36 | [ "${opt}" == "--host" ] && exists_mf='y' |
---|
37 | [ "${opt}" == "-host" ] && exists_mf='y' |
---|
38 | [ "${opt}" == "-H" ] && exists_mf='y' |
---|
39 | [ "${opt}" == "--verbose" ] && exists_vb='y' |
---|
40 | [ "${opt}" == "-v" ] && exists_vb='y' |
---|
41 | [ "${opt}" == "--" ] && break |
---|
42 | done |
---|
43 | |
---|
44 | [ -n "${VERBOSE:+x}" ] && exists_vb='y' |
---|
45 | |
---|
46 | local mpi_option='' |
---|
47 | |
---|
48 | # NODEFILE to use. By default specialized one |
---|
49 | local nodefile="${OAR_NODE_FILE}" |
---|
50 | [ -n "${OAR_MSG_NODEFILE:+x}" -a -e "${OAR_MSG_NODEFILE}" ] && nodefile="${OAR_MSG_NODEFILE}" |
---|
51 | if [ -z ${exists_mf} ] |
---|
52 | then |
---|
53 | [ -e "${nodefile}" ] && mpi_option="-machinefile ${nodefile} ${mpi_option}" |
---|
54 | fi |
---|
55 | |
---|
56 | # Number of MPI parallel run. By default MAX. |
---|
57 | local nbcpus='' |
---|
58 | [ -e "${nodefile}" ] && nbcpus=$(cat ${nodefile} | wc -l) |
---|
59 | [ -n "${OAR_NP:+x}" ] && nbcpus=${OAR_NP} |
---|
60 | if [ -z ${exists_np} ] |
---|
61 | then |
---|
62 | [ -z ${nbcpus} ] || mpi_option="-np ${nbcpus} ${mpi_option}" |
---|
63 | fi |
---|
64 | |
---|
65 | # VARIABLE to define in other MPI parallel run |
---|
66 | for varenv in $(env \ |
---|
67 | | grep "^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" \ |
---|
68 | | egrep -v "^USER=|^TERM=|^OAR|^SGE_|^LS_COLORS=\ |
---|
69 | |^ENV=|^BASH_ENV=|^HOSTNAME=|^LOGNAME=|^MAIL=\ |
---|
70 | |^MANPATH=|^OMPI_MCA_plm_rsh_agent=|^PWD=\ |
---|
71 | |^SHELL=|^SSH_|^SUDO_COMMAND=|^HOME=|^DISPLAY=\ |
---|
72 | |^SHLVL=" \ |
---|
73 | | cut -f 1 -d '=' \ |
---|
74 | | sort ) |
---|
75 | do |
---|
76 | mpi_option="${mpi_option} -x ${varenv}" |
---|
77 | done |
---|
78 | |
---|
79 | # Special case of LD_LIBRARY_PATH and system path |
---|
80 | local ld_path="${LD_LIBRARY_PATH}" |
---|
81 | oar_fixldpath |
---|
82 | |
---|
83 | [ ! -z ${exists_vb} ] && echo mpirun ${mpi_option} $* |
---|
84 | mpirun ${mpi_option} $* |
---|
85 | [ ! -z ${ld_path} ] && LD_LIBRARY_PATH="${ld_path}" |
---|
86 | } |
---|
87 | declare -fx oar_mpirun |
---|
88 | |
---|
89 | function oar_envmpirun () { |
---|
90 | local exists_np='' |
---|
91 | local exists_mf='' |
---|
92 | local exists_vb='' |
---|
93 | |
---|
94 | for opt in $* |
---|
95 | do |
---|
96 | [ "${opt}" == "-np" ] && exists_np='y' |
---|
97 | [ "${opt}" == "-machinefile" ] && exists_mf='y' |
---|
98 | [ "${opt}" == "--machinefile" ] && exists_mf='y' |
---|
99 | [ "${opt}" == "-hostfile" ] && exists_mf='y' |
---|
100 | [ "${opt}" == "--hostfile" ] && exists_mf='y' |
---|
101 | [ "${opt}" == "--host" ] && exists_mf='y' |
---|
102 | [ "${opt}" == "-host" ] && exists_mf='y' |
---|
103 | [ "${opt}" == "-H" ] && exists_mf='y' |
---|
104 | [ "${opt}" == "--verbose" ] && exists_vb='y' |
---|
105 | [ "${opt}" == "-v" ] && exists_vb='y' |
---|
106 | [ "${opt}" == "--" ] && break |
---|
107 | done |
---|
108 | |
---|
109 | [ -n "${VERBOSE:+x}" ] && exists_vb='y' |
---|
110 | |
---|
111 | local mpi_option='' |
---|
112 | |
---|
113 | # NODEFILE to use. By default specialized one |
---|
114 | local nodefile="${OAR_NODE_FILE}" |
---|
115 | [ -n "${OAR_MSG_NODEFILE:+x}" -a -e "${OAR_MSG_NODEFILE}" ] && nodefile="${OAR_MSG_NODEFILE}" |
---|
116 | if [ -z ${exists_mf} ] |
---|
117 | then |
---|
118 | [ -e "${nodefile}" ] && mpi_option="-machinefile ${nodefile} ${mpi_option}" |
---|
119 | fi |
---|
120 | |
---|
121 | # Number of MPI parallel run. By default MAX. |
---|
122 | local nbcpus='' |
---|
123 | [ -e "${nodefile}" ] && nbcpus=$(cat ${nodefile} | wc -l) |
---|
124 | [ -n "${OAR_NP:+x}" ] && nbcpus=${OAR_NP} |
---|
125 | if [ -z ${exists_np} ] |
---|
126 | then |
---|
127 | [ -z ${nbcpus} ] || mpi_option="-np ${nbcpus} ${mpi_option}" |
---|
128 | fi |
---|
129 | |
---|
130 | # Change login remote shell |
---|
131 | local rsh_agent="${OMPI_MCA_plm_rsh_agent}" |
---|
132 | if [ "${OMPI_MCA_plm_rsh_agent}" == "oarsh" ] |
---|
133 | then |
---|
134 | OMPI_MCA_plm_rsh_agent="oar-envsh" |
---|
135 | fi |
---|
136 | |
---|
137 | [ ! -z ${exists_vb} ] && echo mpirun ${mpi_option} $* |
---|
138 | mpirun ${mpi_option} $* |
---|
139 | [ ! -z ${rsh_agent} ] && OMPI_MCA_plm_rsh_agent="${rsh_agent}" |
---|
140 | } |
---|
141 | declare -fx oar_envmpirun |
---|
142 | |
---|
143 | if [ -n "$PS1" -a -n "${OAR_JOB_WALLTIME_SECONDS}" ] |
---|
144 | then |
---|
145 | ( sleep $(( ${OAR_JOB_WALLTIME_SECONDS} - (10*60) )); \ |
---|
146 | echo; echo; echo "Close interactive session in 10min"; echo; \ |
---|
147 | sleep 0.2; printf \\a; \ |
---|
148 | sleep 0.2; printf \\a; \ |
---|
149 | sleep 0.2; printf \\a; \ |
---|
150 | sleep 8m; \ |
---|
151 | echo; echo; echo "Close interactive session in 2min"; echo; \ |
---|
152 | sleep 0.2; printf \\a; \ |
---|
153 | sleep 0.2; printf \\a; \ |
---|
154 | sleep 0.2; printf \\a; \ |
---|
155 | sleep 0.2; printf \\a; \ |
---|
156 | sleep 0.2; printf \\a; \ |
---|
157 | ) & |
---|
158 | fi |
---|
159 | |
---|
160 | fi |
---|
161 | |
---|
162 | return |
---|
163 | |
---|
164 | ################################################################ |
---|
165 | # Documentation in POD format (like Perl) |
---|
166 | ################################################################ |
---|
167 | |
---|
168 | =head1 NAME |
---|
169 | |
---|
170 | oar_mpirun oar_envmpirun - OAR wrapper to launch mpi |
---|
171 | |
---|
172 | =head1 SYNOPSIS |
---|
173 | |
---|
174 | oar_mpirun command |
---|
175 | oar_envmpirun command |
---|
176 | |
---|
177 | |
---|
178 | =head1 DESCRIPTION |
---|
179 | |
---|
180 | When you need to do MPI over a cluster, |
---|
181 | you need to fix your environnement used by your code on every node. |
---|
182 | |
---|
183 | |
---|
184 | |
---|
185 | =head1 SEE ALSO |
---|
186 | |
---|
187 | oarsub |
---|
188 | |
---|
189 | =head1 AUTHORS |
---|
190 | |
---|
191 | Written by Gabriel Moreau, Grenoble - France |
---|
192 | |
---|
193 | =head1 LICENSE AND COPYRIGHT |
---|
194 | |
---|
195 | GPL version 2 or later |
---|
196 | |
---|
197 | Copyright (C) 2011-2013 Gabriel Moreau / LEGI - CNRS UMR 5519 - France |
---|