Bandwidth Over Time Graphics and Absolute Bandwidth as Text

This commit is contained in:
Felipe Salerno Prado
2016-02-23 16:29:30 +01:00
parent 647130df32
commit 2b99e82cff

View File

@@ -1,6 +1,7 @@
import sys
import sqlite3
from memUtil import *
from math import *
metrics = []
threadMetrics = []
@@ -114,6 +115,104 @@ def memory_utilisation_percent_new(connection):
idle = memory_idle(connection)
return (active/(total-idle))*100
@metric
def memory_utilisation_new(connection):
#This function calculates the memory utilisation in Gbit/s considering the memory_utilisation_percent_new function result.
memory_utilisation_window_new(connection)
maxDataRate = maximum_data_rate(connection)
memoryPercent = memory_utilisation_percent_new(connection)
return (memoryPercent/100)*(maxDataRate/1024)
def memory_utilisation_window_new(connection):
#This function determines the average memory bandwidth over time in percentage and in Gbit/s.
#The average bandwidth over time is done dividing the time into windows of the same length and getting the average bandwidth in each window.
#Through the data from the database, DataStrobeEnd and DataStrobeBegin, it is possible to assess when a data transfer begins or ends.
#Hence, it is possible to ckeck when a data transfer happens and if it occupies or is inside a time window. Then, it is possible to determine the average bandwidth in percentage.
#Besides, extracting the data from the memory specs, it is possible to calculate the maximum data rate of the memory and then determine the bandwidth in Gbit/s.
#The bandwidth data are then plotted in two graphics.
windowSize = 1000000
cursor = connection.cursor()
cursor.execute(""" SELECT max(DataStrobeEnd) FROM Transactions """)
total = cursor.fetchone()
steps = ceil(float(total[0])/float(windowSize))
#print(steps)
#All possible cases of data transfers inside a time window
queryFull= """ SELECT sum(DataStrobeEnd - DataStrobeBegin) FROM transactions Where DataStrobeBegin > ? and DataStrobeEnd < ?""" #The data transfer begins and ends inside the time window
queryEnd= """ SELECT sum(DataStrobeEnd - ?) FROM transactions Where DataStrobeBegin < ? and DataStrobeEnd > ? and DataStrobeEnd <=?""" #Only the end of the data transfer is inside the time window
queryBegin= """ SELECT sum(? - DataStrobeBegin) FROM transactions Where DataStrobeBegin >= ? and DataStrobeBegin < ? and DataStrobeEnd > ?""" #Only the beginning of the data transfer is inside the time window
queryPart = """ SELECT DataStrobeBegin FROM transactions Where DataStrobeBegin <= ? and DataStrobeEnd >= ?""" #The data transfer occupies all the time window
maxDataRate = maximum_data_rate(connection)
#print(width)
#print(clk)
#print(rate)
bandwidthPercentage = [0] * steps
bandwidth = [0] * steps
for i in range(steps):
#print(i)
bandwidthPercentage[i] = 0
cursor.execute(queryPart, (i*windowSize, (i+1)*windowSize))
result = cursor.fetchone()
if(result is None):
cursor.execute(queryFull, (i*windowSize, (i+1)*windowSize))
result = cursor.fetchone()
if(result[0] is not None):
bandwidthPercentage[i] += int(result[0])
#print(bandwidthPercentage[i])
cursor.execute(queryEnd, (i*windowSize,i*windowSize,i*windowSize,(i+1)*windowSize))
result = cursor.fetchone()
if(result[0] is not None):
bandwidthPercentage[i] += int(result[0])
#print(bandwidthPercentage[i])
cursor.execute(queryBegin, ((i+1)*windowSize, i*windowSize, (i+1)*windowSize, (i+1)*windowSize))
result = cursor.fetchone()
if(result[0] is not None):
bandwidthPercentage[i] += int(result[0])
#print(bandwidthPercentage[i])
else:
bandwidthPercentage[i] = windowSize
#print(bandwidthPercentage[i])
bandwidthPercentage[i] = float(bandwidthPercentage[i]/windowSize)
bandwidth[i] = float(bandwidthPercentage[i])*float(maxDataRate)/1024
bandwidthPercentage[i] *= 100
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
time = np.arange(0,steps*windowSize,windowSize)
plt.figure(1)
plt.plot(time/1000,bandwidthPercentage)
plt.xlabel('Time (ns)')
plt.ylabel('Bandwidth (%)')
plt.ylim(0,120)
plt.grid(True)
windowPercentage = PdfPages('windowPercentage.pdf')
windowPercentage.savefig()
windowPercentage.close()
plt.figure(2)
plt.plot(time/1000,bandwidth)
plt.xlabel('Time (ns)')
plt.ylabel('Bandwidth (Gbit/s)')
plt.grid(True)
window = PdfPages('window.pdf')
window.savefig()
window.close()
def maximum_data_rate(connection):
memspec = MemSpec(connection)
memoryType = memspec.getValue("memoryType")
if (memoryType.find("DDR") != -1):
width = 64
else:
if (memoryType.find("WIDEIO") != -1):
width = memspec.getValue("width")
clk = memspec.getValue("clkMhz")
rate = memspec.getValue("dataRate")
maxDataRate = float(clk)*float(width)*float(rate)
return maxDataRate
@metric
def memory_utilisation_percent_old(connection):
@@ -330,7 +429,6 @@ def time_in_power_down_states_percent(connection):
totalTimeAllBanks = trace_length_in_ns(connection) * getNumberOfBanks(connection)
return (time_in_power_down_states_in_ns(connection) * 1.0 / totalTimeAllBanks) * 100
def passRatio(connection):
numberOfPassWins = {}