Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
some of the action checking code didn't work right, so I removed it.
[simgrid.git] / src / smpi / smpirun.in
1 #!/bin/sh
2 DEFAULT_LOOPBACK_BANDWIDTH="498000000"
3 DEFAULT_LOOPBACK_LATENCY="0.000004"
4 DEFAULT_NETWORK_BANDWIDTH="$((26 * 1024 * 1024))"
5 DEFAULT_NETWORK_LATENCY="0.000005"
6 DEFAULT_NUMPROCS="4"
7 DEFAULT_POWER="100"
8
9 LOOPBACK_BANDWIDTH="${DEFAULT_LOOPBACK_BANDWIDTH}"
10 LOOPBACK_LATENCY="${DEFAULT_LOOPBACK_LATENCY}"
11 NETWORK_BANDWIDTH="${DEFAULT_NETWORK_BANDWIDTH}"
12 NETWORK_LATENCY="${DEFAULT_NETWORK_LATENCY}"
13 NUMPROCS="${DEFAULT_NUMPROCS}"
14 POWER="${DEFAULT_POWER}"
15
16 while true; do
17   case "$1" in
18    "-np")
19       NUMPROCS="$2"
20       shift 2
21     ;;
22    "-bandwidth")
23       NETWORK_BANDWIDTH="$2"
24       shift 2
25     ;;
26    "-latency")
27       NETWORK_LATENCY="$2"
28       shift 2
29     ;;
30     *)
31       break
32     ;;
33   esac
34 done
35
36 EXEC="$1"
37 shift
38
39 PLATFORMTMP="$(mktemp tmpXXXXXX)"
40 #PLATFORMTMP="pla.xml"
41
42 cat > ${PLATFORMTMP} <<PLATFORMHEAD
43 <?xml version='1.0'?>
44 <!DOCTYPE platform SYSTEM "simgrid.dtd">
45 <platform version="2">
46 PLATFORMHEAD
47
48 for (( i=${NUMPROCS}; $i ; i=$i-1 )) do
49   echo "  <host id=\"host$i\" power=\"${POWER}\"/>" >> ${PLATFORMTMP}
50   echo "  <link id=\"loop$i\" bandwidth=\"${LOOPBACK_BANDWIDTH}\" latency=\"${LOOPBACK_LATENCY}\"/>" >> ${PLATFORMTMP}
51   echo "  <link id=\"link$i\" bandwidth=\"${NETWORK_BANDWIDTH}\" latency=\"${NETWORK_LATENCY}\"/>" >> ${PLATFORMTMP}
52 done
53
54 for (( i=${NUMPROCS}; $i ; i=$i-1 )) do
55   for (( j=${NUMPROCS}; $j ; j=$j-1 )) do
56     if [ $i -eq $j ]; then
57       echo "  <route src=\"host$i\" dst=\"host$j\"><link:ctn id=\"loop$i\"/></route>" >> ${PLATFORMTMP}
58     else
59       echo "  <route src=\"host$i\" dst=\"host$j\"><link:ctn id=\"link$i\"/><link:ctn id=\"link$j\"/></route>" >> ${PLATFORMTMP}
60     fi
61   done
62 done
63
64 cat >> ${PLATFORMTMP} <<PLATFORMFOOT
65 </platform>
66 PLATFORMFOOT
67
68 APPLICATIONTMP="$(mktemp tmpXXXXXX)"
69 #APPLICATIONTMP="app.xml"
70
71 cat > ${APPLICATIONTMP} <<APPLICATIONHEAD
72 <?xml version='1.0'?>
73 <!DOCTYPE platform SYSTEM "simgrid.dtd">
74 <platform version="2">
75 APPLICATIONHEAD
76
77 for (( i=${NUMPROCS}; $i ; i=$i-1 )) do
78   echo "  <process host=\"host$i\" function=\"smpi_simulated_main\">" >> ${APPLICATIONTMP}
79   for ARG in $*; do
80     echo "    <argument value=\"${ARG}\"/>" >> ${APPLICATIONTMP}
81   done
82   echo "  </process>" >> ${APPLICATIONTMP}
83 done
84
85 for (( i=${NUMPROCS}; $i ; i=$i-1 )) do
86   echo "  <process host=\"host$i\" function=\"smpi_sender\"/>" >> ${APPLICATIONTMP}
87   echo "  <process host=\"host$i\" function=\"smpi_receiver\"/>" >> ${APPLICATIONTMP}
88 done
89
90 cat >> ${APPLICATIONTMP} <<APPLICATIONFOOT
91 </platform>
92 APPLICATIONFOOT
93
94 ${EXEC} ${PLATFORMTMP} ${APPLICATIONTMP}
95 rm ${PLATFORMTMP} ${APPLICATIONTMP}