Intensive refactor of DRAMSys project structure and CMakeFiles
This commit is contained in:
64
resources/scripts/address_scrambler.pl
Normal file
64
resources/scripts/address_scrambler.pl
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
my $filename = shift || die;
|
||||
|
||||
open(FH, "$filename");
|
||||
|
||||
while(<FH>)
|
||||
{
|
||||
# Get all the data adress:
|
||||
$_ =~ /(\d+):\s+(\w+)\s+0x([\w\d]+)/;
|
||||
my $time = $1;
|
||||
my $command = $2;
|
||||
my $address = $3;
|
||||
my $new_address;
|
||||
|
||||
# Convert to binary:
|
||||
$address = sprintf( "%032b", hex( $address ) );
|
||||
|
||||
# example:
|
||||
# 31 0
|
||||
# 00000000000000000000000000000001
|
||||
# 00000000000000000000010000000000
|
||||
|
||||
# Swap adresses:
|
||||
$new_address = substr($address,31 - 31,1). # R 31
|
||||
substr($address,31 - 30,1). # R 30
|
||||
substr($address,31 - 29,1). # R 29
|
||||
substr($address,31 - 28,1). # R 28
|
||||
substr($address,31 - 27,1). # R 27
|
||||
substr($address,31 - 26,1). # R 26
|
||||
substr($address,31 - 25,1). # R 25
|
||||
substr($address,31 - 24,1). # R 24
|
||||
substr($address,31 - 23,1). # R 23
|
||||
substr($address,31 - 22,1). # R 22
|
||||
substr($address,31 - 21,1). # R 21
|
||||
substr($address,31 - 20,1). # R 20
|
||||
substr($address,31 - 19,1). # R 19
|
||||
substr($address,31 - 18,1). # R 18
|
||||
substr($address,31 - 17,1). # R 17
|
||||
substr($address,31 - 16,1). # R 16
|
||||
substr($address,31 - 8,1). # R 15
|
||||
substr($address,31 - 7,1). # R 14
|
||||
substr($address,31 - 6,1). # R 13
|
||||
substr($address,31 - 11,1). # B 12
|
||||
substr($address,31 - 9,1). # B 11
|
||||
substr($address,31 - 0,1). # B 10
|
||||
substr($address,31 - 15,1). # C 9
|
||||
substr($address,31 - 14,1). # C 8
|
||||
substr($address,31 - 13,1). # C 7
|
||||
substr($address,31 - 12,1). # C 6
|
||||
substr($address,31 - 10,1). # C 5
|
||||
substr($address,31 - 5,1). # C 4
|
||||
substr($address,31 - 4,1). # C 3
|
||||
substr($address,31 - 3,1). # C 2
|
||||
substr($address,31 - 2,1). # C 1
|
||||
substr($address,31 - 1,1); # C 0
|
||||
|
||||
$new_address = sprintf("%X", oct( "0b$new_address" ) );
|
||||
|
||||
print $time.":\t".$command."\t0x".$new_address."\n";
|
||||
}
|
||||
|
||||
378
resources/scripts/analyse_trace.pl
Normal file
378
resources/scripts/analyse_trace.pl
Normal file
@@ -0,0 +1,378 @@
|
||||
#!/usr/bin/perl
|
||||
use List::Util 'max';
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
my $filename = shift || die("Please provide a input STL file");
|
||||
|
||||
my $numberOfRows = 16384;
|
||||
my $numberOfBanks = 8;
|
||||
my $numberOfColumns = 1024;
|
||||
my $numberOfBytes = 8; # Byte Offset from e.g. DIMM
|
||||
|
||||
my $numberOfBits = 32;
|
||||
my $burstLength = 8;
|
||||
|
||||
my $addressCorrection = 1;
|
||||
|
||||
my $numberOfRowBits = log($numberOfRows)/log(2);
|
||||
my $numberOfBankBits = log($numberOfBanks)/log(2);
|
||||
my $numberOfColumnBits = log($numberOfColumns)/log(2);
|
||||
my $numberOfByteBits = log($numberOfBytes)/log(2);
|
||||
my $numberOfBurstBits = log($burstLength)/log(2);
|
||||
|
||||
print "Number of Address Bits:\t".$numberOfBits."\n\n";
|
||||
print "Number of Row Bits:\t".$numberOfRowBits."\n";
|
||||
print "Number of Bank Bits:\t".$numberOfBankBits."\n";
|
||||
print "Number of Col Bits:\t".$numberOfColumnBits."\n";
|
||||
print ">Burst Bits in Col:\t".$numberOfBurstBits."\n";
|
||||
print "Number of Byte Bits:\t".$numberOfByteBits."\n";
|
||||
|
||||
my $numberOfXBits = $numberOfBits - $numberOfRowBits - $numberOfBankBits - $numberOfColumnBits - $numberOfByteBits;
|
||||
|
||||
print "Number of Unused Bits:\t".$numberOfXBits."\n";
|
||||
print "\n";
|
||||
print "\n";
|
||||
|
||||
open(FH, "$filename");
|
||||
|
||||
my @activityCounter;
|
||||
my @mapping;
|
||||
|
||||
# Initialize:
|
||||
for(my $i = 0; $i < $numberOfBits; $i++)
|
||||
{
|
||||
$activityCounter[$i] = 0;
|
||||
}
|
||||
|
||||
for(my $i = $numberOfXBits-1; $i >= 0; $i--)
|
||||
{
|
||||
$mapping[$numberOfBits-($numberOfXBits-$i)] = "X".$i;
|
||||
}
|
||||
|
||||
my $old_address = "00000000000000000000000000000000";
|
||||
|
||||
while(<FH>)
|
||||
{
|
||||
# Get the adress:
|
||||
$_ =~ /\d+:\s+\w+\s+0x([\w\d]+)\s*[\d\w]*/;
|
||||
my $address = $1;
|
||||
$address = sprintf( "%0".$numberOfBits."b", hex( $address ) * $addressCorrection );
|
||||
|
||||
# $i = 0 :: most significant bit
|
||||
for(my $i = 0; $i < $numberOfBits; $i++)
|
||||
{
|
||||
my $new = substr($address, $i, 1);
|
||||
my $old = substr($old_address, $i, 1);
|
||||
|
||||
if($new ne $old)
|
||||
{
|
||||
$activityCounter[$numberOfBits-1-$i]++;
|
||||
}
|
||||
}
|
||||
|
||||
$old_address = $address;
|
||||
}
|
||||
|
||||
close(FH);
|
||||
|
||||
# Make Consistency Check:
|
||||
for(my $i = 0; $i < ($numberOfByteBits+$numberOfBankBits); $i++)
|
||||
{
|
||||
if($activityCounter[$i] != 0)
|
||||
{
|
||||
print "Bits of lower C part or Y have toggled, this should not happen\n";
|
||||
exit -1;
|
||||
}
|
||||
}
|
||||
|
||||
# Print bit numbers:
|
||||
print "Bits\t\t";
|
||||
for(my $i = $numberOfBits-1; $i >= 0; $i--)
|
||||
{
|
||||
print $i."\t";
|
||||
}
|
||||
|
||||
#Print Activity
|
||||
print "\nActivity\t";
|
||||
for(my $i = $numberOfBits-1; $i >= 0; $i--)
|
||||
{
|
||||
print $activityCounter[$i]."\t";
|
||||
}
|
||||
|
||||
#Print relative Activity
|
||||
print "\nPercent\t\t";
|
||||
my $sum = 0;
|
||||
my @percent;
|
||||
for(my $i = $numberOfBits-1; $i >= 0; $i--)
|
||||
{
|
||||
$sum = $sum + $activityCounter[$i];
|
||||
}
|
||||
|
||||
for(my $i = $numberOfBits-1; $i >= 0; $i--)
|
||||
{
|
||||
my $string = $activityCounter[$i]/$sum*100;
|
||||
$string = sprintf("%.2f", $string);
|
||||
$string =~ s/\./,/g;
|
||||
$percent[$i] = $string."%";
|
||||
$string .= "%\t";
|
||||
print $string;
|
||||
}
|
||||
|
||||
#Fix Byte Offset:
|
||||
for(my $i = 0; $i < $numberOfByteBits; $i++)
|
||||
{
|
||||
$activityCounter[$i] = -1;
|
||||
$mapping[$i] = "Y$i";
|
||||
}
|
||||
|
||||
#Fix Constant 0 Bits in Column due to Burstlength:
|
||||
for(my $i=0; $i < $numberOfBurstBits; $i++)
|
||||
{
|
||||
$activityCounter[$numberOfByteBits + $i] = -1;
|
||||
$mapping[$numberOfByteBits + $i] = "C$i";
|
||||
}
|
||||
|
||||
#Search Column Locations
|
||||
for(my $i = $numberOfBurstBits; $i < $numberOfColumnBits; $i++)
|
||||
{
|
||||
my $maximum = max(@activityCounter);
|
||||
my ($index) = grep $activityCounter[$_] == $maximum , 0.. $#activityCounter;
|
||||
$mapping[$index] = "C$i";
|
||||
$activityCounter[$index] = -1;
|
||||
}
|
||||
|
||||
#Search Bank Locations
|
||||
for(my $i = 0; $i < $numberOfBankBits; $i++)
|
||||
{
|
||||
my $maximum = max(@activityCounter);
|
||||
my ($index) = grep $activityCounter[$_] == $maximum , 0.. $#activityCounter;
|
||||
$mapping[$index] = "B$i";
|
||||
$activityCounter[$index] = -1;
|
||||
}
|
||||
|
||||
#Search Row Locations
|
||||
for(my $i = 0; $i < $numberOfRowBits; $i++)
|
||||
{
|
||||
my $maximum = max(@activityCounter);
|
||||
my ($index) = grep $activityCounter[$_] == $maximum , 0.. $#activityCounter;
|
||||
$mapping[$index] = "R$i";
|
||||
$activityCounter[$index] = -1;
|
||||
}
|
||||
|
||||
#Print final mapping
|
||||
my $header = '
|
||||
strict graph G
|
||||
{
|
||||
forcelabels=true;
|
||||
rankdir=LR;
|
||||
{
|
||||
graph [fontname = "courier"];
|
||||
node [shape=square, fontname="courier", fixedsize=true, width=0.85, height=0.85]
|
||||
edge [fontname = "courier"];
|
||||
';
|
||||
|
||||
for(my $i = $numberOfBits-1; $i >= 0; $i--)
|
||||
{
|
||||
$header .= " $i [pos=\"".($numberOfBits-1-$i).",0!\", xlp=\"-5,0\", label=\"$i\n".$percent[$i]."\" ]\n";
|
||||
}
|
||||
|
||||
my $pos = 0;
|
||||
for(my $i = $numberOfXBits-1; $i >= 0; $i--)
|
||||
{
|
||||
my $pos2 = $numberOfBits-$pos-1;
|
||||
$header .= " X$i [ label=\"$pos2\nX$i\" pos=\"$pos,-5!\"]\n";
|
||||
$pos++;
|
||||
}
|
||||
for(my $i = $numberOfBankBits-1; $i >= 0; $i--)
|
||||
{
|
||||
my $pos2 = $numberOfBits-$pos-1;
|
||||
$header .= " B$i [ label=\"$pos2\nB$i\" pos=\"$pos,-5!\"]\n";
|
||||
$pos++;
|
||||
}
|
||||
for(my $i = $numberOfRowBits-1; $i >= 0; $i--)
|
||||
{
|
||||
my $pos2 = $numberOfBits-$pos-1;
|
||||
$header .= " R$i [ label=\"$pos2\nR$i\" pos=\"$pos,-5!\"]\n";
|
||||
$pos++;
|
||||
}
|
||||
for(my $i = $numberOfColumnBits-1; $i >= 0; $i--)
|
||||
{
|
||||
my $pos2 = $numberOfBits-$pos-1;
|
||||
$header .= " C$i [ label=\"$pos2\nC$i\" pos=\"$pos,-5!\"]\n";
|
||||
$pos++;
|
||||
}
|
||||
for(my $i = $numberOfByteBits-1; $i >= 0; $i--)
|
||||
{
|
||||
my $pos2 = $numberOfBits-$pos-1;
|
||||
$header .= " Y$i [ label=\"$pos2\nY$i\" pos=\"$pos,-5!\"]\n";
|
||||
$pos++;
|
||||
}
|
||||
$header .= " }\n";
|
||||
|
||||
print "\nMapping\t\t";
|
||||
my $maximum = max(@activityCounter);
|
||||
for(my $i = $numberOfBits-1; $i >= 0; $i--)
|
||||
{
|
||||
if($mapping[$i] =~ /X\d/)
|
||||
{
|
||||
$header .= "$i -- ".$mapping[$i]." [ color=\"grey\"];\n";
|
||||
}
|
||||
elsif($mapping[$i] =~ /B\d/)
|
||||
{
|
||||
$header .= "$i -- ".$mapping[$i]." [ color=\"green\"];\n";
|
||||
}
|
||||
elsif($mapping[$i] =~ /R\d/)
|
||||
{
|
||||
$header .= "$i -- ".$mapping[$i]." [ color=\"blue\"];\n";
|
||||
}
|
||||
elsif($mapping[$i] =~ /C\d/)
|
||||
{
|
||||
$header .= "$i -- ".$mapping[$i]." [ color=\"red\"];\n";
|
||||
}
|
||||
elsif($mapping[$i] =~ /Y\d/)
|
||||
{
|
||||
$header .= "$i -- ".$mapping[$i]." [ color=\"grey\"];\n";
|
||||
}
|
||||
print $mapping[$i]."\t";
|
||||
}
|
||||
$header .= "}";
|
||||
print "\n";
|
||||
|
||||
#Generate Scrambled Trace:
|
||||
|
||||
#Generate Configuration for 32x32 MUX:
|
||||
# Assumption e.g. 32 bit:
|
||||
# B R C
|
||||
# X X B B B R R R R R R R R R R R R R R C C C C C C C C C C Y Y Y
|
||||
# 31 30 29 27 26 13 12 3 2 0
|
||||
# A B C D E F
|
||||
#
|
||||
#print "A:".($numberOfBits-1)."\n";
|
||||
#print "B:".($numberOfBits-$numberOfXBits-1)."\n";
|
||||
#print "C:".($numberOfBits-$numberOfXBits-$numberOfBankBits-1)."\n";
|
||||
#print "D:".($numberOfBits-$numberOfXBits-$numberOfBankBits-$numberOfRowBits-1)."\n";
|
||||
#print "E:".($numberOfBits-$numberOfXBits-$numberOfBankBits-$numberOfRowBits-$numberOfColumnBits-1)."\n";
|
||||
#print "F:".($numberOfBits-$numberOfXBits-$numberOfBankBits-$numberOfRowBits-$numberOfColumnBits-$numberOfByteBits)."\n";
|
||||
|
||||
my @confVectorDecimal;
|
||||
my @checkVector;
|
||||
my $XCounter = 0;
|
||||
my $rowCounter = 0;
|
||||
my $bankCounter = 0;
|
||||
my $columnCounter = 0;
|
||||
my $byteCounter = 0;
|
||||
|
||||
for(my $i = $numberOfBits-1; $i >= 0; $i--)
|
||||
{
|
||||
if($mapping[$i] =~ /X(\d+)/)
|
||||
{
|
||||
my $idx = $numberOfBits-$numberOfXBits+$1;
|
||||
#print "\$1=".$1." i=".$i." idx=".$idx." mapping=".$mapping[$i]."\n";
|
||||
$confVectorDecimal[$idx] = $i;
|
||||
$checkVector[$idx] = "X";
|
||||
}
|
||||
elsif($mapping[$i] =~ /B(\d+)/)
|
||||
{
|
||||
my $idx = $numberOfBits-$numberOfXBits-$numberOfBankBits+$1;
|
||||
#print "\$1=".$1." i=".$i." idx=".$idx." mapping=".$mapping[$i]."\n";
|
||||
$confVectorDecimal[$idx] = $i;
|
||||
$checkVector[$idx] = "B";
|
||||
}
|
||||
elsif($mapping[$i] =~ /R(\d+)/)
|
||||
{
|
||||
my $idx = $numberOfBits-$numberOfXBits-$numberOfBankBits-$numberOfRowBits+$1;
|
||||
#print "\$1=".$1." i=".$i." idx=".$idx." mapping=".$mapping[$i]."\n";
|
||||
$confVectorDecimal[$idx] = $i;
|
||||
$checkVector[$idx] = "R";
|
||||
}
|
||||
elsif($mapping[$i] =~ /C(\d+)/)
|
||||
{
|
||||
my $idx = $numberOfBits-$numberOfXBits-$numberOfBankBits-$numberOfRowBits-$numberOfColumnBits+$1;
|
||||
#print "\$1=".$1." i=".$i." idx=".$idx." mapping=".$mapping[$i]."\n";
|
||||
$confVectorDecimal[$idx] = $i;
|
||||
$checkVector[$idx] = "C";
|
||||
}
|
||||
elsif($mapping[$i] =~ /Y(\d+)/)
|
||||
{
|
||||
my $idx = $numberOfBits-$numberOfXBits-$numberOfBankBits-$numberOfRowBits-$numberOfColumnBits-$numberOfByteBits+$1;
|
||||
#print "\$1=".$1." i=".$i." idx=".$idx." mapping=".$mapping[$i]."\n";
|
||||
$confVectorDecimal[$idx] = $i;
|
||||
$checkVector[$idx] = "Y";
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
print "\n";
|
||||
print "Configuration Vector for the mapping ";
|
||||
for(my $m = $numberOfBits-1; $m >= 0; $m--)
|
||||
{
|
||||
print $checkVector[$m];
|
||||
}
|
||||
print ":\n\n";
|
||||
|
||||
for(my $m = $numberOfBits-1; $m >= 0; $m--)
|
||||
{
|
||||
#Debug:
|
||||
print "mux: $m\t-->\t".$confVectorDecimal[$m]."\n";
|
||||
}
|
||||
|
||||
print "\n";
|
||||
print "\n";
|
||||
|
||||
for(my $m = $numberOfBits-1; $m >= 0; $m--)
|
||||
{
|
||||
print sprintf( "%05b", $confVectorDecimal[$m] );
|
||||
}
|
||||
print "\n";
|
||||
print "\n";
|
||||
|
||||
# Generate Graph
|
||||
my $dotname;
|
||||
my $pdfname;
|
||||
my $stlname;
|
||||
|
||||
if($filename =~ /(.+)\.stl/)
|
||||
{
|
||||
$dotname = $1.".dot";
|
||||
$pdfname = $1.".pdf";
|
||||
$stlname = $1."_scram.stl";
|
||||
|
||||
open(FH,">$dotname");
|
||||
print FH $header;
|
||||
close(FH);
|
||||
system("neato -o $pdfname -Tpdf $dotname");
|
||||
}
|
||||
|
||||
|
||||
open(FH, "$filename");
|
||||
open(SH, ">$stlname");
|
||||
|
||||
while(<FH>)
|
||||
{
|
||||
# Get all the data adress:
|
||||
$_ =~ /(\d+):\s+(\w+)\s+0x([\w\d]+)/; # XXX
|
||||
my $time = $1;
|
||||
my $command = $2;
|
||||
my $address = $3;
|
||||
my $new_address;
|
||||
|
||||
# Convert to binary:
|
||||
$address = sprintf( "%032b", hex( $address ) );
|
||||
|
||||
# Swap adresses:
|
||||
$new_address = "";
|
||||
for(my $m = $numberOfBits-1; $m >= 0; $m--)
|
||||
{
|
||||
#print $confVectorDecimal[$m]."\n";
|
||||
$new_address .= substr($address,$numberOfBits-1-$confVectorDecimal[$m],1);
|
||||
}
|
||||
|
||||
# Convert to Hex:
|
||||
$new_address = sprintf("%X", oct( "0b$new_address" ) );
|
||||
|
||||
print SH $time.":\t".$command."\t0x".$new_address."\n";
|
||||
}
|
||||
|
||||
close(FH);
|
||||
close(SH);
|
||||
23
resources/scripts/generateTrace.py
Normal file
23
resources/scripts/generateTrace.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/python
|
||||
# This script generates an example trace for DDR3
|
||||
#
|
||||
#<addressmapping>
|
||||
# <channel from="128" to="128" /> <!-- only one channel -->
|
||||
# <bank from="27" to="29" />
|
||||
# <row from="13" to="26" /> 26 downto 13 --> 2^14 = 16384
|
||||
# <column from="3" to="12" /> Burstlength = 8 --> 8 down bits always zero --> 12 downto 3 --> 7 --> 2^7 = 128
|
||||
# <bytes from="0" to="2" /> 2^3 = 8
|
||||
#</addressmapping>
|
||||
|
||||
numberOfRows = 16384
|
||||
numberOfColumns = 128
|
||||
byteOffset = 64
|
||||
bankOffset = numberOfRows * numberOfColumns
|
||||
|
||||
# Write to Bank 0
|
||||
for x in range(0, bankOffset):
|
||||
print "{0:d}:\tread\t0x{1:X}".format(x,(x*byteOffset))
|
||||
|
||||
# Write to Bank 1
|
||||
for x in range(bankOffset, 2*bankOffset):
|
||||
print "{0:d}:\tread\t0x{1:X}".format(x,(x*byteOffset))
|
||||
34
resources/scripts/memoryHog.pl
Normal file
34
resources/scripts/memoryHog.pl
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/perl -w
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
open(LINEAR, "> ../traces/linear.stl");
|
||||
open(RANDOM, "> ../traces/random.stl");
|
||||
|
||||
my $length = shift || die ("please give length of traces");
|
||||
my $size = 0x40;
|
||||
|
||||
for(my $i=0; $i < $length; $i++)
|
||||
{
|
||||
my $r = int(rand($length));
|
||||
#print $r." ".($size*$r)."\n";
|
||||
|
||||
print LINEAR "$i: read ".sprintf("0x%x",($size*$i))."\n";
|
||||
print RANDOM "$i: read ".sprintf("0x%x",($size*$r))."\n";
|
||||
|
||||
#my $rw = int(rand(2))%2;
|
||||
#if($rw == 0)
|
||||
#{
|
||||
# print LINEAR "$i: read ".sprintf("0x%x",($size*$i))."\n";
|
||||
# print RANDOM "$i: read ".sprintf("0x%x",($size*$r))."\n";
|
||||
#}
|
||||
#else
|
||||
#{
|
||||
# print LINEAR "$i: write ".sprintf("0x%x",($size*$i))."\n";
|
||||
# print RANDOM "$i: write ".sprintf("0x%x",($size*$r))."\n";
|
||||
#}
|
||||
}
|
||||
|
||||
|
||||
close(LINEAR);
|
||||
close(RANDOM);
|
||||
34
resources/scripts/stride_detection.pl
Normal file
34
resources/scripts/stride_detection.pl
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/perl
|
||||
use List::Util 'max';
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
my $filename = shift || die("Please provide a input STL file");
|
||||
my $command = shift || die ("Pleas provide read/write");
|
||||
|
||||
open(FH, "$filename");
|
||||
|
||||
my $old_address = 0;
|
||||
my %histogram;
|
||||
my $command_occurance = 0;
|
||||
|
||||
while(<FH>)
|
||||
{
|
||||
# Get the adress:
|
||||
$_ =~ /\d+:\s+(\w+)\s+0x([\w\d]+)\s*[\d\w]*/;
|
||||
if($command eq $1)
|
||||
{
|
||||
my $address = hex($2);
|
||||
my $distance = $address - $old_address;
|
||||
$histogram{$distance} ++;
|
||||
$old_address = $address;
|
||||
$command_occurance++;
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $key ( keys %histogram)
|
||||
{
|
||||
my $percent = $histogram{$key}/$command_occurance;
|
||||
my $hexkey = sprintf( "%032b", abs($key) );
|
||||
print "0x".$hexkey." ".abs($key)." = ".$histogram{$key}." (".$percent.")\n";
|
||||
}
|
||||
31
resources/scripts/traceGenerationForNNTraining.pl
Normal file
31
resources/scripts/traceGenerationForNNTraining.pl
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
my $phaseLength = 100;
|
||||
my $phaseStatus = 0;
|
||||
my $max = 100000;
|
||||
my $base = 0;
|
||||
my $maxAddressExp = 26;
|
||||
my $maxAddress = 2**$maxAddressExp;
|
||||
|
||||
for(my $i = 0; $i < $max; $i++)
|
||||
{
|
||||
if($phaseStatus == 0) # Linear
|
||||
{
|
||||
my $addr = (($base << 6) + (($i % $phaseLength) << 6)) % $maxAddress;
|
||||
print "$i: read 0x".sprintf("%x", $addr)."\n";
|
||||
}
|
||||
else # Random
|
||||
{
|
||||
my $addr = (rand(2**($maxAddressExp-6))) << 6;
|
||||
print "$i: read 0x".sprintf("%x", $addr)."\n";
|
||||
}
|
||||
|
||||
if($i % 100 == 0 && $i != 0)
|
||||
{
|
||||
$phaseStatus = ($phaseStatus == 0) ? 1 : 0;
|
||||
$base = rand(2**($maxAddressExp-6));
|
||||
}
|
||||
}
|
||||
|
||||
137
resources/scripts/trace_gen.py
Normal file
137
resources/scripts/trace_gen.py
Normal file
@@ -0,0 +1,137 @@
|
||||
#! /usr/bin/env python3
|
||||
# vim: set fileencoding=utf-8
|
||||
|
||||
# Copyright (c) 2018, Technische Universität Kaiserslautern
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
|
||||
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Author: Éder F. Zulian
|
||||
|
||||
import ctypes
|
||||
|
||||
# A trace file is a pre-recorded file containing memory transactions. Each
|
||||
# memory transaction has a timestamp that tells the simulator when it shall
|
||||
# happen, a transaction type (read or write) and a memory address given in
|
||||
# hexadecimal.
|
||||
#
|
||||
# Here is an example syntax:
|
||||
#
|
||||
# ```
|
||||
# # Comment lines begin with #
|
||||
# # [clock-cyle]: [write|read] [hex-address]
|
||||
# 31: read 0x400140
|
||||
# 33: read 0x400160
|
||||
# 56: write 0x7fff8000
|
||||
# 81: read 0x400180
|
||||
# ```
|
||||
#
|
||||
# The timestamp corresponds to the time the request is to be issued and it is
|
||||
# given in cycles of the bus master device. Example: the device is a FPGA with
|
||||
# frequency 200 MHz (clock period of 5 ns). If the timestamp is 10 it means
|
||||
# that the request is to be issued when time is 50 ns.
|
||||
#
|
||||
|
||||
# The default values given as example assume the following address mapping:
|
||||
#
|
||||
# DIMM Characteristics:
|
||||
# Byte Offset (Y): 8 [0:2] (8-byte-wide memory module, i.e., 64-bit-wide data bus) -> 3 bit
|
||||
# Cols (C): 1K [3:12] (A0 - A9) -> 10 bit
|
||||
# Rows (R): 128K [13:29] (A0 - A16) -> 17 bit
|
||||
# Bank (B): 8 [30:32] (BA0 - BA2) -> 3 bit
|
||||
#
|
||||
# 3 3 3 | 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 | 1 1 1
|
||||
# 2 1 0 | 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 | 2 1 0 9 8 7 6 5 4 3 | 2 1 0
|
||||
# B B B | R R R R R R R R R R R R R R R R R | C C C C C C C C C C | Y Y Y
|
||||
#
|
||||
|
||||
# Transaction type (read or write)
|
||||
transaction = 'read'
|
||||
|
||||
# Channel information. If your address mapping does not have channel bits keep
|
||||
# it equal to 1 and set the shift to the extreme left of the address.
|
||||
num_ch = 1 # Number of channels
|
||||
ch_shift = 34 # Shift to reach the frist bit reserved for channels in the address
|
||||
ch_mask = 0x1 # Mask for all channel bits in the address
|
||||
|
||||
# Bank group information. If your address mapping does not have bank groups
|
||||
# keep it equal to 1 and set the shift to the extreme left of the address.
|
||||
num_bank_groups = 1 # Number of bank groups
|
||||
bgroup_shift = 33 # Shift to reach the frist bit reserved for bank groups in the address
|
||||
bgroup_mask = 0x1 # Mask for all bits in the address related to bank groups
|
||||
|
||||
# Bank information
|
||||
num_banks = 8 # Number of banks
|
||||
bank_shift = 30 # Shift to reach the frist bit reserved for banks in the address
|
||||
bank_mask = 0x7 # Mask for all bank bits in the address
|
||||
|
||||
# Row information
|
||||
num_rows = 128 * 1024 # Number of rows
|
||||
row_shift = 13 # Shift to reach the frist bit reserved for rows in the address
|
||||
row_mask = 0x1ffff # Mask for all row bits in the address
|
||||
|
||||
# Column information
|
||||
num_col = 1 * 1024 # Number of columns
|
||||
col_shift = 3 # Shift to reach the frist bit reserved for columns in the address
|
||||
col_mask = 0x3ff # Mask for all column bits in the address
|
||||
|
||||
# Burst length of 8 columns. 8 columns written/read per access (in 4 full
|
||||
# clock cycles of the memory bus).
|
||||
burst_len = 8
|
||||
|
||||
# Initial clock cycle
|
||||
clock_cycle = 0
|
||||
|
||||
# Clock cycle increment between two accesses
|
||||
clock_increment = 10
|
||||
|
||||
|
||||
def clear_bits(mask, shift, val):
|
||||
m = ctypes.c_uint64(~(mask << shift)).value
|
||||
return ctypes.c_uint64(val & m).value
|
||||
|
||||
|
||||
def set_bits(mask, shift, val, v):
|
||||
val = clear_bits(mask, shift, val)
|
||||
return ctypes.c_uint64(val | (v << shift)).value
|
||||
|
||||
|
||||
address = 0
|
||||
for ch in range(0, num_ch):
|
||||
address = set_bits(ch_mask, ch_shift, address, ch)
|
||||
for bg in range(0, num_bank_groups):
|
||||
address = set_bits(bgroup_mask, bgroup_shift, address, bg)
|
||||
for b in range(0, num_banks):
|
||||
address = set_bits(bank_mask, bank_shift, address, b)
|
||||
for row in range(0, num_rows):
|
||||
address = set_bits(row_mask, row_shift, address, row)
|
||||
for col in range(0, num_col, burst_len):
|
||||
address = set_bits(col_mask, col_shift, address, col)
|
||||
print('# clock cycle: {0:d} | {1} | address: 0x{2:010X} | channel: {3} | bank group: {4} | bank: {5} | row: {6} | column: {7}'.format(clock_cycle, transaction, address, ch, bg, b, row, col))
|
||||
print('{0:d}:\t{1}\t0x{2:010X}'.format(clock_cycle, transaction, address))
|
||||
clock_cycle = clock_cycle + clock_increment
|
||||
9
resources/scripts/video_rendering/Makefile
Normal file
9
resources/scripts/video_rendering/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
all:
|
||||
modulecmd bash load gnuplot/latest
|
||||
modulecmd bash load image-magick/latest
|
||||
./temperatur.pl
|
||||
movie:
|
||||
ffmpeg -start_number 00000000 -i ../out/%08d.jpg -vcodec mpeg4 ../out.avi
|
||||
|
||||
clean:
|
||||
rm *.out *.err
|
||||
135
resources/scripts/video_rendering/temperatur.job.pl
Normal file
135
resources/scripts/video_rendering/temperatur.job.pl
Normal file
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/perl -w
|
||||
use warnings;
|
||||
use strict;
|
||||
use File::Copy;
|
||||
|
||||
my $file = shift;
|
||||
my $id = shift;
|
||||
my $samples = shift;
|
||||
my $inputPath = "/gu2/jungma/thermal/in/out-backup";
|
||||
my $extractPath = "/gu2/jungma/thermal/tmp/$id";
|
||||
|
||||
print "Create TMP path... ";
|
||||
system("mkdir $extractPath");
|
||||
print " done\n";
|
||||
|
||||
print "Extract... ";
|
||||
system("tar -xf $inputPath/$file -C $extractPath");
|
||||
print " done\n";
|
||||
|
||||
print "Preprocessing... ";
|
||||
system("sed '1d' $extractPath/out/output_core_die_full.txt > $extractPath/die0.txt");
|
||||
system("sed '1d' $extractPath/out/output_mem_die_1_full.txt > $extractPath/die1.txt");
|
||||
system("sed '1d' $extractPath/out/output_mem_die_2_full.txt > $extractPath/die2.txt");
|
||||
system("sed '1d' $extractPath/out/output_mem_die_3_full.txt > $extractPath/die3.txt");
|
||||
system("sed '1d' $extractPath/out/output_mem_die_4_full.txt > $extractPath/die4.txt");
|
||||
print " done\n";
|
||||
|
||||
print "Gnuplot...";
|
||||
open( my $GP, '|-', 'gnuplot' );
|
||||
print $GP "
|
||||
reset
|
||||
set terminal pngcairo size 500,500 enhanced font 'Verdana,10'
|
||||
|
||||
set border linewidth 0
|
||||
unset key
|
||||
unset colorbox
|
||||
unset tics
|
||||
set lmargin screen 0.0
|
||||
set rmargin screen 1.0
|
||||
set tmargin screen 1.0
|
||||
set bmargin screen 0.0
|
||||
|
||||
set pm3d map
|
||||
set pm3d interpolate 2,2
|
||||
set cbrange [318.0:388.0]
|
||||
|
||||
#set palette rgbformulae 22,13,-31
|
||||
set palette defined ( 0 \"blue\", 3 \"green\", 4 \"yellow\", 5 \"red\", 6 \"black\" )
|
||||
|
||||
set output '$extractPath/die0.png'
|
||||
splot '$extractPath/die0.txt' matrix every ::1
|
||||
|
||||
set output '$extractPath/die1.png'
|
||||
splot '$extractPath/die1.txt' matrix every ::1
|
||||
|
||||
set output '$extractPath/die2.png'
|
||||
splot '$extractPath/die2.txt' matrix every ::1
|
||||
|
||||
set output '$extractPath/die3.png'
|
||||
splot '$extractPath/die3.txt' matrix every ::1
|
||||
|
||||
set output '$extractPath/die4.png'
|
||||
splot '$extractPath/die4.txt' matrix every ::1";
|
||||
close($GP);
|
||||
print " done\n";
|
||||
|
||||
print "Wait for files... ";
|
||||
while (1) { last if -e "$extractPath/die0.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die1.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die2.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die3.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die4.png"; print "."; sleep 1;}
|
||||
print " done\n";
|
||||
|
||||
print "Composite ...";
|
||||
system("composite -gravity center constants/thermal_model_core.png $extractPath/die0.png $extractPath/die0b.png");
|
||||
system("composite -gravity center constants/thermal_model_dram_0_1.png $extractPath/die1.png $extractPath/die1b.png");
|
||||
system("composite -gravity center constants/thermal_model_dram_2_3.png $extractPath/die2.png $extractPath/die2b.png");
|
||||
system("composite -gravity center constants/thermal_model_dram_4_5.png $extractPath/die3.png $extractPath/die3b.png");
|
||||
system("composite -gravity center constants/thermal_model_dram_6_7.png $extractPath/die4.png $extractPath/die4b.png");
|
||||
print " done\n";
|
||||
|
||||
print "Wait for files... ";
|
||||
while (1) { last if -e "$extractPath/die0b.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die1b.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die2b.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die3b.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die4b.png"; print "."; sleep 1;}
|
||||
print " done\n";
|
||||
|
||||
print "Convert ...";
|
||||
system("convert $extractPath/die0b.png -alpha set -background none -shear 0x-40 -rotate 60 +repage -crop 1048x485+0+205 $extractPath/die0c.png");
|
||||
system("convert $extractPath/die1b.png -alpha set -background none -shear 0x-40 -rotate 60 +repage -crop 1048x485+0+205 $extractPath/die1c.png");
|
||||
system("convert $extractPath/die2b.png -alpha set -background none -shear 0x-40 -rotate 60 +repage -crop 1048x485+0+205 $extractPath/die2c.png");
|
||||
system("convert $extractPath/die3b.png -alpha set -background none -shear 0x-40 -rotate 60 +repage -crop 1048x485+0+205 $extractPath/die3c.png");
|
||||
system("convert $extractPath/die4b.png -alpha set -background none -shear 0x-40 -rotate 60 +repage -crop 1048x485+0+205 $extractPath/die4c.png");
|
||||
print " done\n";
|
||||
|
||||
print "Wait for files... ";
|
||||
while (1) { last if -e "$extractPath/die0c.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die1c.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die2c.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die3c.png"; print "."; sleep 1;}
|
||||
while (1) { last if -e "$extractPath/die4c.png"; print "."; sleep 1;}
|
||||
print " done\n";
|
||||
|
||||
my $outFileName = sprintf("%08d", $id);
|
||||
|
||||
print "Produce Output ...";
|
||||
system("convert -size 1048x1680 xc:black $extractPath/die0c.png -geometry +0+1200 -composite $extractPath/die1c.png -geometry +0+900 -composite $extractPath/die2c.png -geometry +0+600 -composite $extractPath/die3c.png -geometry +0+300 -composite $extractPath/die4c.png -composite $extractPath/a$outFileName.jpg");
|
||||
|
||||
while (1) { last if -e "$extractPath/a$outFileName.jpg"; print "."; sleep 1;}
|
||||
system("convert $extractPath/a$outFileName.jpg -pointsize 80 -fill white -gravity northeast -draw \"text 20,20 '".$samples."ms'\" $extractPath/b$outFileName.jpg");
|
||||
|
||||
while (1) { last if -e "$extractPath/b$outFileName.jpg"; print "."; sleep 1;}
|
||||
system("convert $extractPath/b$outFileName.jpg constants/legend/legend4.png +append ../out/$outFileName.jpg");
|
||||
|
||||
print " done\n";
|
||||
|
||||
print "Produce Samples ...";
|
||||
for(my $i = 0; $i < $samples-1; $i++)
|
||||
{
|
||||
$id++;
|
||||
my $outFileNameCopy = sprintf("%08d", $id);
|
||||
copy("../out/$outFileName.jpg","../out/$outFileNameCopy.jpg");
|
||||
}
|
||||
print " done\n";
|
||||
|
||||
# cleanup
|
||||
print "Cleanup ... ";
|
||||
while (1) { last if -e "/gu2/jungma/thermal/out/$outFileName.jpg"; print "."; sleep 1;}
|
||||
system("rm -rf $extractPath");
|
||||
print " done\n";
|
||||
|
||||
##ffmpeg -start_number 00000000 -i %08d.jpg -vcodec mpeg4 test.avi
|
||||
67
resources/scripts/video_rendering/temperatur.pl
Normal file
67
resources/scripts/video_rendering/temperatur.pl
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/perl -w
|
||||
use warnings;
|
||||
use strict;
|
||||
use List::Util qw( min max );
|
||||
|
||||
#/Volumes/Etana_tmp2/tmp_sadri/backup/sep_16/log_smartbench_traces_50_cpu_1650_mhz_100_mhz_dram_100_mhz_sampling8X_bankwise_on_test/out-backup
|
||||
my $inputPath = "../in/out-backup";
|
||||
my $extractPath = "../tmp";
|
||||
my $samplingFile = "../in/sampling";
|
||||
|
||||
# Read the input file names and store it in an array
|
||||
opendir (DIR, $inputPath) or die $!;
|
||||
|
||||
my @files;
|
||||
my @sortetFiles;
|
||||
|
||||
while (my $file = readdir(DIR))
|
||||
{
|
||||
push(@files, $file);
|
||||
}
|
||||
|
||||
@sortetFiles = sort @files;
|
||||
|
||||
|
||||
print "Cleanup\n";
|
||||
system("rm -rf *.err *.out");
|
||||
system("rm -rf ../tmp/*");
|
||||
print "Load modules\n";
|
||||
|
||||
|
||||
# Estimate sampeling numbers
|
||||
|
||||
open(SF,$samplingFile);
|
||||
|
||||
my @refreshRates;
|
||||
|
||||
while(<SF>)
|
||||
{
|
||||
$_ =~ /(\d+)\.0/;
|
||||
my $rate = $1;
|
||||
push(@refreshRates, $rate);
|
||||
}
|
||||
|
||||
print "Max. Rate:".max(@refreshRates)."\n";
|
||||
print "Min. Rate:".min(@refreshRates)."\n";
|
||||
|
||||
my $counter = 0;
|
||||
my $i = 0;
|
||||
# For each data package start one job!
|
||||
foreach(@sortetFiles)
|
||||
{
|
||||
my $file = $_;
|
||||
|
||||
if($file =~ /(\d+)-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)\.tgz/)
|
||||
{
|
||||
my $samples = $refreshRates[$i];
|
||||
system("bsub -W 00:05 ./temperatur.job.pl $file $counter $samples");
|
||||
$counter+=$samples;
|
||||
$i++;
|
||||
#if($i == 100)
|
||||
#{
|
||||
# last;
|
||||
#}
|
||||
}
|
||||
}
|
||||
|
||||
##ffmpeg -start_number 00000000 -i %08d.jpg -vcodec mpeg4 test.avi
|
||||
Reference in New Issue
Block a user