mirror of the now-defunct rocklinux.org
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.

127 lines
3.8 KiB

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