5 DEFAULT_LOOPBACK_BANDWIDTH="498000000"
6 DEFAULT_LOOPBACK_LATENCY="0.000004"
7 DEFAULT_NETWORK_BANDWIDTH="$((26 * 1024 * 1024))"
8 DEFAULT_NETWORK_LATENCY="0.000005"
12 LOOPBACK_BANDWIDTH="${DEFAULT_LOOPBACK_BANDWIDTH}"
13 LOOPBACK_LATENCY="${DEFAULT_LOOPBACK_LATENCY}"
14 NETWORK_BANDWIDTH="${DEFAULT_NETWORK_BANDWIDTH}"
15 NETWORK_LATENCY="${DEFAULT_NETWORK_LATENCY}"
16 POWER="${DEFAULT_POWER}"
18 SIMOPTS="--cfg=maxmin/precision:1e-9 --cfg=network/model:SMPI --cfg=network/TCP_gamma:4194304"
20 #usage to print the way this script should be called
23 echo "$0 [-keep-temps]"
24 echo " [-np <numprocs>] -platform <xmldesc> -hostfile <hostfile> [-map] program [program-options]"
25 echo " [-keep-temps] # don't remove the generated files after execution"
26 echo " [-map] # display the machine on which each process rank is mapped"
27 echo " [-np <numprocs>] # use that amount of processes from the hostfile."
28 echo " # By default, all processes of the hostfile are used."
29 echo " [-trace] # activate tracing"
30 echo " [-trace-comment <comment>]# put a comment on the top of the trace file"
31 echo " [-trace-comment-file <file>] # put file contents on the top of the trace file as comment"
32 echo " [-trace-grouped] # group MPI processes by location"
33 echo " [-trace-resource] # trace resource utilization"
34 echo " [-trace-triva] # generate configuration for Triva's GraphView"
35 echo " [-trace-file <tracefile>] # name of the tracefile (simgrid_smpi.trace)"
36 echo "or (deprecated usage):"
37 echo "$0 [-keep-temps] [-np <numprocs>] [-bandwidth <bytes/sec>] [-latency <secs>] program [program-options]"
41 #check if we have at least one parameter
55 NETWORK_BANDWIDTH="$2"
64 if [ ! -f "${PLATFORM}" ]; then
65 echo "[$0] ** error: the file '${PLATFORM}' does not exist. Aborting."
72 if [ ! -f "${HOSTFILE}" ]; then
73 echo "[$0] ** error: the file '${HOSTFILE}' does not exist. Aborting."
94 "-trace-comment-file")
95 TRACE_COMMENT_FILE="$2"
110 TRACE_RESOURCE="true"
124 "-help" | "--help" | "-h")
132 SIMOPTS="$SIMOPTS ${1%%=*}=$OPT"
145 ##-----------------------------------
147 # Basic checks on the provided arguments
148 if [ -z "${EXEC}" ] ; then
149 echo "You must provide a program to execute."
154 if [ -z "${HOSTFILE}" ] ; then
155 echo "No hostfile specified."
160 # Don't use wc -l to compute it to avoid issues with trailing \n at EOF
161 hostfile_procs=`grep -c [a-zA-Z0-9] $HOSTFILE`
163 if [ -z "${NUMPROCS}" ] ; then
164 # Use the amount of processes in the hostfile as default value for the -np parameter
165 NUMPROCS=$hostfile_procs
169 if [ ${NUMPROCS} -gt ${hostfile_procs} ] ; then
170 echo "You requested to use ${NUMPROCS} processes, but there is only ${hostfile_procs} processes in your hostfile..." >&2
173 ##-------------------------------- DEFAULT or SPECIFIED PLATFORM --------------------------------------
174 if [ -z "${PLATFORM}" ]; then
175 PLATFORMTMP="$(mktemp tmpXXXXXX)"
177 cat > ${PLATFORMTMP} <<PLATFORMHEAD
178 <?xml version='1.0'?>
179 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
180 <platform version="3">
181 <AS id="AS0" routing="Full">
184 for (( i=${NUMPROCS}; $i ; i=$i-1 )) do
185 echo " <host id=\"host$i\" power=\"${POWER}\"/>" >> ${PLATFORMTMP}
186 echo " <link id=\"loop$i\" bandwidth=\"${LOOPBACK_BANDWIDTH}\" latency=\"${LOOPBACK_LATENCY}\"/>" >> ${PLATFORMTMP}
187 echo " <link id=\"link$i\" bandwidth=\"${NETWORK_BANDWIDTH}\" latency=\"${NETWORK_LATENCY}\"/>" >> ${PLATFORMTMP}
190 for (( i=${NUMPROCS}; $i ; i=$i-1 )) do
191 for (( j=${NUMPROCS}; $j ; j=$j-1 )) do
192 if [ $i -eq $j ]; then
193 echo " <route src=\"host$i\" dst=\"host$j\"><link_ctn id=\"loop$i\"/></route>" >> ${PLATFORMTMP}
195 echo " <route src=\"host$i\" dst=\"host$j\"><link_ctn id=\"link$i\"/><link_ctn id=\"link$j\"/></route>" >> ${PLATFORMTMP}
200 cat >> ${PLATFORMTMP} <<PLATFORMFOOT
206 PLATFORMTMP=${PLATFORM}
208 ##-------------------------------- end DEFAULT or SPECIFIED PLATFORM --------------------------------------
210 ##-------------------------------- DEFAULT APPLICATION --------------------------------------
211 APPLICATIONTMP="$(mktemp tmpXXXXXX)"
212 #APPLICATIONTMP="app.xml"
215 cat > ${APPLICATIONTMP} <<APPLICATIONHEAD
216 <?xml version='1.0'?>
217 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
218 <platform version="3">
221 ##---- cache hostnames of hostfile---------------
222 if [ -n "${HOSTFILE}" ] && [ -f ${HOSTFILE} ]; then
223 hostnames=(`cat ${HOSTFILE} | tr \\\n " "`)
224 NUMHOSTS=`cat ${HOSTFILE} | wc -l`
227 if [ ${EXEC} = "./smpi_replay" ]; then
229 if [ -n "${APP_TRACES}" ] && [ -f ${APP_TRACES} ]; then
230 hosttraces=(`cat ${APP_TRACES} | tr \\\n " "`)
231 NUMTRACES=`cat ${APP_TRACES} | wc -l`
235 ##----------------------------------------------------------
236 ## generate application.xml with hostnames from hostfile:
237 ## the name of host_i (1<=i<=p, where -np p) is the line i
238 ## in hostfile (where -hostfile hostfile), or "host$i" if
239 ## hostfile has less than i lines.
240 ##----------------------------------------------------------
242 HAVE_SEQ="`which seq 2>/dev/null`"
244 if [ -n "${HAVE_SEQ}" ]; then
245 SEQ=`${HAVE_SEQ} 0 $((${NUMPROCS}-1))`
248 while (( $cnt < ${NUMPROCS} )) ; do
254 ##---- generate <process> tags------------------------------
258 if [ -n "${HOSTFILE}" ]; then
259 j=$(( $i % ${NUMHOSTS} ))
261 ##---- optional display of ranks to process mapping
262 if [ -n "${MAPOPT}" ]; then
263 echo "[rank $i] -> ${hostnames[$j]}"
266 if [ -z "${hostnames[$j]}" ]; then
269 host="${hostnames[$j]}"
271 echo " <process host=\"${host}\" function=\"$i\"> <!-- function name used only for logging -->" >> ${APPLICATIONTMP}
272 echo " <argument value=\"$i\"/> <!-- rank -->" >> ${APPLICATIONTMP}
273 if [ ${EXEC} = "./smpi_replay" ]; then
274 if [ ${NUMTRACES} -gt 1 ]; then
275 echo " <argument value=\"${hosttraces[$j]}\"/>" >> ${APPLICATIONTMP}
277 echo " <argument value=\"${hosttraces[0]}\"/>" >> ${APPLICATIONTMP}
281 echo " <argument value=\"${ARG}\"/>" >> ${APPLICATIONTMP}
284 echo " </process>" >> ${APPLICATIONTMP}
287 cat >> ${APPLICATIONTMP} <<APPLICATIONFOOT
290 ##-------------------------------- end DEFAULT APPLICATION --------------------------------------
292 ##---------------------- SMPI TRACING OPTIONS ---------------------------------
293 if [ -n "${TRACE_ACTIVE}" ]; then
294 #define trace filename
295 if [ -z "${TRACE_FILENAME}" ]; then
296 TRACE_FILENAME="smpi_simgrid.trace"
298 TRACEOPTIONS="--cfg=tracing:1 --cfg=tracing/filename:${TRACE_FILENAME} --cfg=tracing/smpi:1"
300 if [ -n "${TRACE_COMMENT}" ]; then
301 TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/comment:${TRACE_COMMENT}"
304 if [ -n "${TRACE_COMMENT_FILE}" ]; then
305 TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/comment_file:${TRACE_COMMENT_FILE}"
308 if [ -n "${TRACE_GROUPED}" ]; then
309 TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/smpi/group:1"
312 if [ -n "${TRACE_RESOURCE}" ]; then
313 TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/categorized:1 --cfg=tracing/uncategorized:1"
316 if [ -n "${TRACE_TRIVA}" ]; then
317 TRACEOPTIONS="${TRACEOPTIONS} --cfg=triva/categorized:smpi_cat.plist --cfg=triva/uncategorized:smpi_uncat.plist"
320 ##---------------------- end SMPI TRACING OPTIONS ---------------------------------
322 export SMPI_GLOBAL_SIZE=${NUMPROCS}
323 if [ -n "${KEEP}" ] ; then
324 echo ${EXEC} ${SIMOPTS} ${TRACEOPTIONS} ${PLATFORMTMP} ${APPLICATIONTMP}
326 ${EXEC} ${SIMOPTS} ${TRACEOPTIONS} ${PLATFORMTMP} ${APPLICATIONTMP}
329 if [ -z "${KEEP}" ] ; then
330 if [ -z "${PLATFORM}" ]; then