Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Model parameters

  • Loading branch information...
commit 3f5163c11f9ccb9e48d1db25c83f3c5e7cf36ec3 1 parent ed576c0
@sbourdeauducq sbourdeauducq authored
Showing with 34 additions and 5 deletions.
  1. +34 −5 tools/memadr_stats.py
View
39 tools/memadr_stats.py
@@ -1,5 +1,22 @@
#!/usr/bin/python
+#
+# Parameters of the memory system
+#
+# log2 of the memory capacity, in bytes
+param_capacity = 27
+# log2 of the number of DRAM banks
+param_banks = 2
+# log2 of the size of a DRAM row, in 32-bit words
+param_rowsize = 10
+# burst length
+param_burstlength = 4
+# dead time, per transaction
+param_deadtime = 2
+# page miss penalty
+param_misspenalty = 6
+#
+
import sys
def extract_bits(n, start, count):
@@ -7,10 +24,10 @@ def extract_bits(n, start, count):
return (n & (mask << start)) >> start
def split_adr(adr):
- return extract_bits(adr, 12, 27-2-12+1), extract_bits(adr, 10, 2), extract_bits(adr, 0, 10)
+ return extract_bits(adr, param_rowsize+param_banks, param_capacity-2-param_rowsize-param_banks+1), extract_bits(adr, param_rowsize, param_banks), extract_bits(adr, 0, param_rowsize)
def count_page_hits(adrs):
- openrows = [0]*4
+ openrows = [0]*(2**param_banks)
page_hits = 0
for adr in adrs:
row, bank, col = split_adr(adr)
@@ -21,7 +38,7 @@ def count_page_hits(adrs):
def reorder(adrs, window_size):
window = []
- openrows = [0]*4
+ openrows = [0]*(2**param_banks)
def fetch_transaction():
for candidate in window:
row, bank, col = split_adr(candidate)
@@ -43,9 +60,19 @@ def fetch_transaction():
return out
def print_page_hits(p, adrs):
- print "%d, %d" % (p, 100*count_page_hits(adrs)/transaction_count)
+ hit_rate = float(count_page_hits(adrs))/float(transaction_count)
+ utilization = hit_rate*float(param_burstlength)/float(param_burstlength+param_deadtime) + (1.0-hit_rate)*float(param_burstlength)/float(param_deadtime+param_misspenalty+param_burstlength)
+ print "%d, %d, %d" % (p, 100*hit_rate, 100*utilization)
+
+print "======= DRAM model parameters ======="
+print "Memory capacity: %dMB" % ((2**param_capacity)/(1024*1024))
+print "DRAM banks: %d" % (2**param_banks)
+print "Row size: %d words (32-bit)" % (2**param_rowsize)
+print "Burst length: %d" % param_burstlength
+print "Dead time: %d" % param_deadtime
+print "Miss penalty: %d" % param_misspenalty
-print "Reading input..."
+print "======= Reading input... ======="
transaction_count = 0
unordered_adrs = []
for line in sys.stdin:
@@ -55,6 +82,8 @@ def print_page_hits(p, adrs):
print "...done."
print "Transaction count: %d" % transaction_count
+print "======= Full reordering ======="
+print "(window size, page hit rate, utilization)"
print_page_hits(1, unordered_adrs)
for window_size in [2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50, 100]:
reordered = reorder(unordered_adrs, window_size)
Please sign in to comment.
Something went wrong with that request. Please try again.