From 41dad5ce0073cdab081c14baf1a085688de13a98 Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Thu, 12 Apr 2018 13:47:48 +0200 Subject: [PATCH] Some more features for NN DRAM modeling --- DRAMSys/library/resources/resources.pri | 3 +- .../scripts/traceGenerationForNNTraining.pl | 31 ++++++++++ .../traceAnalyzer/scripts/dataExtractForNN.pl | 62 +++++++++++++++++++ DRAMSys/traceAnalyzer/scripts/scripts.pri | 1 + 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 DRAMSys/library/resources/scripts/traceGenerationForNNTraining.pl create mode 100755 DRAMSys/traceAnalyzer/scripts/dataExtractForNN.pl diff --git a/DRAMSys/library/resources/resources.pri b/DRAMSys/library/resources/resources.pri index cd77f0c8..0b015adf 100644 --- a/DRAMSys/library/resources/resources.pri +++ b/DRAMSys/library/resources/resources.pri @@ -172,4 +172,5 @@ DISTFILES += \ $$PWD/configs/simulator/lpddr4.xml \ $$PWD/simulations/lpddr4-single-device.xml \ $$PWD/configs/amconfigs/am_lpddr4.xml \ - $$PWD/configs/memspecs/MICRON_6Gb_LPDDR4-3200_NDA_NDA_NDA.xml + $$PWD/configs/memspecs/MICRON_6Gb_LPDDR4-3200_NDA_NDA_NDA.xml \ + $$PWD/scripts/traceGenerationForNNTraining.pl diff --git a/DRAMSys/library/resources/scripts/traceGenerationForNNTraining.pl b/DRAMSys/library/resources/scripts/traceGenerationForNNTraining.pl new file mode 100644 index 00000000..58a534bc --- /dev/null +++ b/DRAMSys/library/resources/scripts/traceGenerationForNNTraining.pl @@ -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)); + } +} + diff --git a/DRAMSys/traceAnalyzer/scripts/dataExtractForNN.pl b/DRAMSys/traceAnalyzer/scripts/dataExtractForNN.pl new file mode 100755 index 00000000..585ab601 --- /dev/null +++ b/DRAMSys/traceAnalyzer/scripts/dataExtractForNN.pl @@ -0,0 +1,62 @@ +#!/bin/perl -w +use DBI; +use Data::Dumper; +use warnings; +use strict; + +# In order to run this script you need to install: +# - cpan install DBI +# - cpan install DBD::SQLite + +my $dbfile = shift || die("No File"); +my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","",""); + +my $sth = $dbh->prepare("select t.ID, t.address, p.PhaseName, p.PhaseBegin, p.PhaseEnd + from Transactions t, Phases p + where t.ID = p.Transact + and (PhaseName='REQ' or PhaseName='RESP');"); + +$sth->execute(); + +my @score; +my @timelog; +my $counter = 0; +my $start = 0; + +print "address, delay\n"; + +while(my @row = $sth->fetchrow_array) +{ + my $id = $row[0]; + my $phase = $row[2]; + my $addr = $row[1]; + + if($phase eq "REQ") + { + $start = $row[4]; + $timelog[$counter] = $start; + } + elsif($phase eq "RESP") + { + my $end = $row[3]; + my $delay = $end - $start; + + #if($counter > 1) + #{ + #print relative time: + #print ($timelog[$counter] - $timelog[$counter-1]); + #print ", "; + #print address + print $addr; + print ", "; + #print delay + print $delay; + print "\n"; + #} + + #$counter++; + } +} + + + diff --git a/DRAMSys/traceAnalyzer/scripts/scripts.pri b/DRAMSys/traceAnalyzer/scripts/scripts.pri index 27affc4a..89815790 100644 --- a/DRAMSys/traceAnalyzer/scripts/scripts.pri +++ b/DRAMSys/traceAnalyzer/scripts/scripts.pri @@ -6,4 +6,5 @@ OTHER_FILES += scripts/metrics.py OTHER_FILES += scripts/tests.py OTHER_FILES += scripts/plots.py OTHER_FILES += scripts/sonification.pl +OTHER_FILES += scripts/dataExtractForNN.pl