@ -1,120 +0,0 @@ |
|||
#!/bin/bash |
|||
# --- SDE-COPYRIGHT-NOTE-BEGIN --- |
|||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|||
# |
|||
# Filename: scripts/Create-ParaSim |
|||
# Copyright (C) 2006 The OpenSDE Project |
|||
# Copyright (C) 2004 - 2006 The T2 SDE Project |
|||
# Copyright (C) 1998 - 2003 Clifford Wolf |
|||
# |
|||
# More information can be found in the files COPYING and README. |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; version 2 of the License. A copy of the |
|||
# GNU General Public License can be found in the file COPYING. |
|||
# --- SDE-COPYRIGHT-NOTE-END --- |
|||
|
|||
config=default |
|||
jobs="" ; x11=0 |
|||
|
|||
while [ "$1" ] ; do |
|||
case "$1" in |
|||
-cfg) config=$2 ; shift ; shift ;; |
|||
-jobs) jobs=$2 ; shift ; shift ;; |
|||
-x11) x11=1 ; shift ;; |
|||
*) echo "Usage: $0 [ -cfg config ] [ -x11 ]" \ |
|||
"[ -jobs 1,4,8 ]" |
|||
exit 1 ;; |
|||
esac |
|||
done |
|||
|
|||
. lib/parse-config |
|||
|
|||
dir=src.parasim.$(cksum config/$config/packages | cut -f1 -d' ') |
|||
echo "Building parasim in $dir." |
|||
|
|||
if [ "$jobs" ] ; then |
|||
maxjobs=0 |
|||
for x in $( echo $jobs | tr , ' ' ) ; do |
|||
[ $maxjobs -lt $x ] && maxjobs=$x |
|||
if [ ! -f "$dir/parasim_$x.dat" ] ; then |
|||
rm -rf $dir/logs_$x |
|||
perl scripts/parasim2.pl $dir $config $x |
|||
else |
|||
echo "Using cached data in $dir/parasim_$x.dat." |
|||
fi |
|||
done |
|||
{ |
|||
jobstotal=$( echo `wc -l < $dir/parasim_$maxjobs.dat` ) |
|||
echo 'set data style lines' |
|||
echo 'set title "T2 Parallel Build' \ |
|||
'Simulation ('$jobstotal' Jobs Total)"' |
|||
echo 'set xlabel "Hours (on reference hardware)"' |
|||
echo 'set ylabel "Parallel Jobs"' |
|||
echo "plot [0:*] [0:$(( $maxjobs + 1 ))] \\" |
|||
next="" |
|||
for x in $( echo $jobs | tr , ' ' ) ; do |
|||
tm=$( tail -n 1 $dir/parasim_$x.dat | cut -f1 | \ |
|||
awk -F. '{ printf("%02d:%02d\n", |
|||
$1, 60*("0." $2)); }' ) |
|||
echo -en "$next" ; next=', \\\n' |
|||
echo -n " \"parasim_$x.dat\" title \"Build with" \ |
|||
"$x parallel jobs ($tm)\" with steps lw 3" |
|||
done |
|||
} > $dir/parasim_$jobs.gnuplot |
|||
|
|||
cmd="perl scripts/parasim3.pl" |
|||
for x in $( echo $jobs | tr , ' ' ) |
|||
do cmd="$cmd $dir/parasim_$x.dat" ; done |
|||
eval "$cmd" > $dir/parasim_$jobs.txt |
|||
|
|||
if [ "$x11" = 1 ] ; then |
|||
cd $dir ; gnuplot -persist parasim_$jobs.gnuplot |
|||
else |
|||
cat $dir/parasim_$jobs.txt |
|||
fi |
|||
exit |
|||
fi |
|||
|
|||
mkdir -p $dir/logs |
|||
|
|||
if [ ! -f $dir/parasim.dat ] ; then |
|||
echo -n "Simulation running ..." |
|||
rm -rf $dir/logs $dir/parasim.new |
|||
mkdir -p $dir/logs |
|||
while |
|||
./scripts/Create-PkgQueue -cfg $config \ |
|||
-logdir $dir/logs | sort -r -n -k2 > $dir/queue.txt |
|||
[ -s $dir/queue.txt ] |
|||
do |
|||
next="`head -n 1 $dir/queue.txt`" ; set $next |
|||
qid="$1-$6" ; touch $dir/logs/$qid.log |
|||
|
|||
printf "%5d %5d %-30s %s\n" $(wc -l < $dir/queue.txt) \ |
|||
$2 $qid "$( cut -f1,7 -d' ' $dir/queue.txt | \ |
|||
tail -n +2 | tr '\n ' ' -' )" >> $dir/parasim.new |
|||
|
|||
echo -n . |
|||
done |
|||
mv $dir/parasim.new $dir/parasim.dat |
|||
echo |
|||
else |
|||
echo "Using cached data in $dir/parasim.dat." |
|||
fi |
|||
|
|||
jobstotal=$( echo `wc -l < $dir/parasim.dat` ) |
|||
cat > $dir/parasim.gnuplot <<- EOT |
|||
set title "T2 Parallel Build Simulation ($jobstotal Jobs Total)" |
|||
set xlabel "Number of Jobs build so far" |
|||
set ylabel "Possible Parallel Jobs" |
|||
plot 'parasim.dat' using 1 title "Parallel Jobs" with steps lw 3 |
|||
EOT |
|||
|
|||
perl scripts/parasim1.pl $dir/parasim.dat 0 > $dir/parasim.txt |
|||
|
|||
if [ "$x11" = 1 ] ; then |
|||
cd $dir ; gnuplot -persist parasim.gnuplot |
|||
else |
|||
cat $dir/parasim.txt |
|||
fi |
@ -1,77 +0,0 @@ |
|||
#!/usr/bin/perl |
|||
# |
|||
# --- T2-COPYRIGHT-NOTE-BEGIN --- |
|||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|||
# |
|||
# T2 SDE: scripts/parasim1.pl |
|||
# Copyright (C) 2004 - 2006 The T2 SDE Project |
|||
# Copyright (C) 1998 - 2003 Clifford Wolf |
|||
# |
|||
# More information can be found in the files COPYING and README. |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; version 2 of the License. A copy of the |
|||
# GNU General Public License can be found in the file COPYING. |
|||
# --- T2-COPYRIGHT-NOTE-END --- |
|||
|
|||
my $size_x=70; |
|||
my $size_y=17; |
|||
|
|||
my @data_val; |
|||
my @data_nr; |
|||
my $max_x = 0; |
|||
my $max_y = 0; |
|||
|
|||
my ($x, $y); |
|||
|
|||
open(F, $ARGV[0]) || die $!; |
|||
while (<F>) { |
|||
@_ = split /\s+/; |
|||
$max_x++; |
|||
$max_y=$_[1] if $_[1] > $max_y; |
|||
} |
|||
close F; |
|||
|
|||
open(F, $ARGV[0]) || die $!; |
|||
for ($x=0; <F>; $x++) { |
|||
@_ = split /\s+/; |
|||
$_ = int(($x*$size_x) / $max_x); |
|||
|
|||
$data_val[$_] = 0 unless defined $data_val[$_]; |
|||
$data_nr[$_] = 0 unless defined $data_nr[$_]; |
|||
|
|||
$data_val[$_] += $_[1]; |
|||
$data_nr[$_]++; |
|||
} |
|||
close(F); |
|||
|
|||
$max_y=$ARGV[1] if $ARGV[1] > 0; |
|||
|
|||
my @leftlabel=qw/. . P a r a l l e l . J o b s . ./; |
|||
|
|||
print "\n ----+----------------------------------------" . |
|||
"------------------------------+\n"; |
|||
|
|||
for ($y=$size_y; $y>0; $y--) { |
|||
if ($y == $size_y) { printf(" %3d |", $max_y); } |
|||
elsif ($y == 1) { print " 1 |"; } |
|||
else { |
|||
print " ", ($leftlabel[$size_y - $y] ne '.' ? |
|||
$leftlabel[$size_y - $y] : ' '), " |"; |
|||
} |
|||
|
|||
for ($x=0; $x<$size_x; $x++) { |
|||
$_ = ($data_val[$x]*$size_y*2 / $data_nr[$x]) / $max_y; |
|||
if ($_ >= $y*2-1) { print ":"; } |
|||
elsif ($_ >= $y*2-2) { print "."; } |
|||
else { print " "; } |
|||
} |
|||
print "|\n"; |
|||
} |
|||
|
|||
print " ----+----------------------------------------" . |
|||
"------------------------------+\n"; |
|||
|
|||
printf(" | 1 Number of Jobs build so far " . |
|||
" %5d |\n\n", $max_x); |
@ -1,79 +0,0 @@ |
|||
#!/bin/perl |
|||
# |
|||
# --- T2-COPYRIGHT-NOTE-BEGIN --- |
|||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|||
# |
|||
# T2 SDE: scripts/parasim2.pl |
|||
# Copyright (C) 2004 - 2006 The T2 SDE Project |
|||
# Copyright (C) 1998 - 2003 Clifford Wolf |
|||
# |
|||
# More information can be found in the files COPYING and README. |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; version 2 of the License. A copy of the |
|||
# GNU General Public License can be found in the file COPYING. |
|||
# --- T2-COPYRIGHT-NOTE-END --- |
|||
|
|||
use strict; |
|||
use English; |
|||
|
|||
my $logdir = $ARGV[0]; |
|||
my $config = $ARGV[1]; |
|||
my $id = $ARGV[2]; |
|||
|
|||
my $freejobs = $id; |
|||
my $runningjobs = 0; |
|||
my $now = 0; |
|||
|
|||
my %jobs; |
|||
my $qid; |
|||
|
|||
system("mkdir -p $logdir/logs_$id"); |
|||
|
|||
open(LOG, "> $logdir/parasim_$id.log") || die $!; |
|||
open(DAT, "> $logdir/parasim_$id.new") || die $!; |
|||
|
|||
$|=1; print "Running simulation for $id parallel jobs ..."; |
|||
|
|||
while (1) { |
|||
printf LOG "%10d: %d jobs currently running (%d idle)\n", |
|||
$now, $runningjobs, $freejobs; |
|||
printf DAT "%f\t$runningjobs\t%s\n", |
|||
$now / 360000, join(" ", keys %jobs); |
|||
print "."; |
|||
|
|||
foreach $qid (keys %jobs) { |
|||
next if $jobs{$qid} > $now; |
|||
printf LOG "%10d: Finished job $qid.\n", $now; |
|||
system("rm -f $logdir/logs_$id/$qid.* ; " . |
|||
"touch $logdir/logs_$id/$qid.log"); |
|||
$freejobs++; $runningjobs--; delete $jobs{$qid}; |
|||
} |
|||
|
|||
open(Q, "./scripts/Create-PkgQueue -cfg $config " . |
|||
"-logdir $logdir/logs_$id | sort -r -n -k2 |") || die $!; |
|||
while ($_=<Q> and $freejobs > 0) { |
|||
@_ = split /\s+/; $qid="$_[0]-$_[5]"; |
|||
s/^.*\s(\S+)\s*$/$1/; $_++; |
|||
printf LOG "%10d: Creating new job $qid " . |
|||
"(pri $_[1], tm $_).\n", $now; |
|||
system("rm -f $logdir/logs_$id/$qid.* ; " . |
|||
"touch $logdir/logs_$id/$qid.out"); |
|||
$jobs{$qid} = $now + $_; |
|||
$freejobs--; $runningjobs++; |
|||
} |
|||
close(Q); |
|||
|
|||
$_=-1; |
|||
foreach $qid (keys %jobs) { |
|||
$_=$jobs{$qid} if $_ == -1 or $_ > $jobs{$qid}; |
|||
} |
|||
if ($_ == -1) { last; } else { $now=$_; } |
|||
} |
|||
|
|||
printf DAT "%f\t0\n", $now / 360000; |
|||
print "\nSimulated build for $id parallel jobs finished.\n\n"; |
|||
|
|||
close LOG; close DAT; |
|||
system("mv $logdir/parasim_$id.new $logdir/parasim_$id.dat"); |
@ -1,90 +0,0 @@ |
|||
#!/usr/bin/perl |
|||
# |
|||
# --- T2-COPYRIGHT-NOTE-BEGIN --- |
|||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|||
# |
|||
# T2 SDE: scripts/parasim3.pl |
|||
# Copyright (C) 2004 - 2006 The T2 SDE Project |
|||
# Copyright (C) 1998 - 2003 Clifford Wolf |
|||
# |
|||
# More information can be found in the files COPYING and README. |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; version 2 of the License. A copy of the |
|||
# GNU General Public License can be found in the file COPYING. |
|||
# --- T2-COPYRIGHT-NOTE-END --- |
|||
|
|||
my ($size_x, $max_x) = (68, 0); |
|||
my $size_y=int( 16 / ($#ARGV+1) ); |
|||
my $file; |
|||
|
|||
foreach $file (@ARGV) { |
|||
open(F, $file) || die $!; |
|||
while (<F>) { |
|||
@_ = split /\s+/; |
|||
$_[0]=int($_[0] * 100); |
|||
$max_x=$_[0] if $_[0] > $max_x; |
|||
} |
|||
close F; |
|||
} |
|||
|
|||
print "\n -----+-----------------------------------" . |
|||
"---------------------------------+\n"; |
|||
|
|||
foreach $file (reverse @ARGV) { |
|||
my @data_val; |
|||
my @data_nr; |
|||
my $max_y = 0; |
|||
|
|||
my ($x, $newx, $y); |
|||
|
|||
open(F, $file) || die $!; |
|||
while (<F>) { |
|||
@_ = split /\s+/; |
|||
$max_y=$_[1] if $_[1] > $max_y; |
|||
} |
|||
close F; |
|||
|
|||
open(F, $file) || die $!; |
|||
for ($x=0; <F>; ) { |
|||
@_ = split /\s+/; |
|||
for ($newx=int($_[0] * 100); $x <= $newx; $x++) { |
|||
$_ = int(($x*$size_x) / $max_x); |
|||
|
|||
$data_val[$_] = 0 unless defined $data_val[$_]; |
|||
$data_nr[$_] = 0 unless defined $data_nr[$_]; |
|||
|
|||
$data_val[$_] += $_[1]; |
|||
$data_nr[$_]++; |
|||
} |
|||
} |
|||
close(F); |
|||
|
|||
for ($y=$size_y; $y>0; $y--) { |
|||
if ($y == $size_y) { printf(" %3d |", $max_y); } |
|||
elsif ($y == 1) { print " 1 |"; } |
|||
else { print " |"; } |
|||
|
|||
for ($x=0; $x<$size_x; $x++) { |
|||
if (defined $data_val[$x]) { |
|||
$_ = ($data_val[$x]*$size_y*2 / |
|||
$data_nr[$x]) / $max_y; |
|||
if ($_ >= $y*2-1) { print ":"; } |
|||
elsif ($_ >= $y*2-2) { print "."; } |
|||
else { print " "; } |
|||
} else { |
|||
print " "; |
|||
} |
|||
} |
|||
print "|\n"; |
|||
} |
|||
|
|||
print " -----+-----------------------------------" . |
|||
"---------------------------------+\n"; |
|||
} |
|||
|
|||
printf " Jobs | 00:00 Time " . |
|||
" %02d:%02d |\n\n", |
|||
$max_x / 100, ($max_x * 0.6 ) % 60; |
|||
|