OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
3.4 KiB

  1. #!/bin/bash
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: scripts/Create-ParaSim
  6. # Copyright (C) 2006 The OpenSDE Project
  7. # Copyright (C) 2004 - 2006 The T2 SDE Project
  8. # Copyright (C) 1998 - 2003 Clifford Wolf
  9. #
  10. # More information can be found in the files COPYING and README.
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; version 2 of the License. A copy of the
  15. # GNU General Public License can be found in the file COPYING.
  16. # --- SDE-COPYRIGHT-NOTE-END ---
  17. config=default
  18. jobs="" ; x11=0
  19. while [ "$1" ] ; do
  20. case "$1" in
  21. -cfg) config=$2 ; shift ; shift ;;
  22. -jobs) jobs=$2 ; shift ; shift ;;
  23. -x11) x11=1 ; shift ;;
  24. *) echo "Usage: $0 [ -cfg config ] [ -x11 ]" \
  25. "[ -jobs 1,4,8 ]"
  26. exit 1 ;;
  27. esac
  28. done
  29. . lib/parse-config
  30. dir=src.parasim.$(cksum config/$config/packages | cut -f1 -d' ')
  31. echo "Building parasim in $dir."
  32. if [ "$jobs" ] ; then
  33. maxjobs=0
  34. for x in $( echo $jobs | tr , ' ' ) ; do
  35. [ $maxjobs -lt $x ] && maxjobs=$x
  36. if [ ! -f "$dir/parasim_$x.dat" ] ; then
  37. rm -rf $dir/logs_$x
  38. perl scripts/parasim2.pl $dir $config $x
  39. else
  40. echo "Using cached data in $dir/parasim_$x.dat."
  41. fi
  42. done
  43. {
  44. jobstotal=$( echo `wc -l < $dir/parasim_$maxjobs.dat` )
  45. echo 'set data style lines'
  46. echo 'set title "T2 Parallel Build' \
  47. 'Simulation ('$jobstotal' Jobs Total)"'
  48. echo 'set xlabel "Hours (on reference hardware)"'
  49. echo 'set ylabel "Parallel Jobs"'
  50. echo "plot [0:*] [0:$(( $maxjobs + 1 ))] \\"
  51. next=""
  52. for x in $( echo $jobs | tr , ' ' ) ; do
  53. tm=$( tail -n 1 $dir/parasim_$x.dat | cut -f1 | \
  54. awk -F. '{ printf("%02d:%02d\n",
  55. $1, 60*("0." $2)); }' )
  56. echo -en "$next" ; next=', \\\n'
  57. echo -n " \"parasim_$x.dat\" title \"Build with" \
  58. "$x parallel jobs ($tm)\" with steps lw 3"
  59. done
  60. } > $dir/parasim_$jobs.gnuplot
  61. cmd="perl scripts/parasim3.pl"
  62. for x in $( echo $jobs | tr , ' ' )
  63. do cmd="$cmd $dir/parasim_$x.dat" ; done
  64. eval "$cmd" > $dir/parasim_$jobs.txt
  65. if [ "$x11" = 1 ] ; then
  66. cd $dir ; gnuplot -persist parasim_$jobs.gnuplot
  67. else
  68. cat $dir/parasim_$jobs.txt
  69. fi
  70. exit
  71. fi
  72. mkdir -p $dir/logs
  73. if [ ! -f $dir/parasim.dat ] ; then
  74. echo -n "Simulation running ..."
  75. rm -rf $dir/logs $dir/parasim.new
  76. mkdir -p $dir/logs
  77. while
  78. ./scripts/Create-PkgQueue -cfg $config \
  79. -logdir $dir/logs | sort -r -n -k2 > $dir/queue.txt
  80. [ -s $dir/queue.txt ]
  81. do
  82. next="`head -n 1 $dir/queue.txt`" ; set $next
  83. qid="$1-$6" ; touch $dir/logs/$qid.log
  84. printf "%5d %5d %-30s %s\n" $(wc -l < $dir/queue.txt) \
  85. $2 $qid "$( cut -f1,7 -d' ' $dir/queue.txt | \
  86. tail -n +2 | tr '\n ' ' -' )" >> $dir/parasim.new
  87. echo -n .
  88. done
  89. mv $dir/parasim.new $dir/parasim.dat
  90. echo
  91. else
  92. echo "Using cached data in $dir/parasim.dat."
  93. fi
  94. jobstotal=$( echo `wc -l < $dir/parasim.dat` )
  95. cat > $dir/parasim.gnuplot <<- EOT
  96. set title "T2 Parallel Build Simulation ($jobstotal Jobs Total)"
  97. set xlabel "Number of Jobs build so far"
  98. set ylabel "Possible Parallel Jobs"
  99. plot 'parasim.dat' using 1 title "Parallel Jobs" with steps lw 3
  100. EOT
  101. perl scripts/parasim1.pl $dir/parasim.dat 0 > $dir/parasim.txt
  102. if [ "$x11" = 1 ] ; then
  103. cd $dir ; gnuplot -persist parasim.gnuplot
  104. else
  105. cat $dir/parasim.txt
  106. fi