adressmappings
This commit is contained in:
@@ -32,6 +32,12 @@ def getTraceLength(connection):
|
||||
result = cursor.fetchone()
|
||||
return result[0]
|
||||
|
||||
def getClock(connection):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT clk FROM GeneralInfo")
|
||||
result = cursor.fetchone()
|
||||
return result[0]
|
||||
|
||||
@metric
|
||||
def average_response_latency_in_ns(connection):
|
||||
cursor = connection.cursor()
|
||||
@@ -41,8 +47,6 @@ def average_response_latency_in_ns(connection):
|
||||
result = cursor.fetchone()
|
||||
return round(result[0],1)
|
||||
|
||||
|
||||
|
||||
def refreshMissDecision(connection,calculatedMetrics):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("""SELECT phases.ID,PhaseBegin,PhaseEnd,TBank FROM Phases INNER JOIN transactions on transactions.id = phases.transact WHERE PhaseName='AUTO_REFRESH' """)
|
||||
@@ -76,51 +80,18 @@ def refreshMissDecision(connection,calculatedMetrics):
|
||||
totalDecisios = totalDecisios + 1
|
||||
if(earliestReq[0] != earliestResp[0]):
|
||||
missDecisions = missDecisions + 1
|
||||
print("earliest Req: {0}| earliest Res: {1}".format(earliestReq[0], earliestResp[0]))
|
||||
#print("earliest Req: {0}| earliest Res: {1}".format(earliestReq[0], earliestResp[0]))
|
||||
end
|
||||
|
||||
|
||||
|
||||
if(totalDecisios != 0):
|
||||
calculatedMetrics.append(("Total Missdecisions", missDecisions))
|
||||
#calculatedMetrics.append(("Total Missdecisions", missDecisions))
|
||||
calculatedMetrics.append(("Relative Missdecisions", 1.0*missDecisions/totalDecisios))
|
||||
else:
|
||||
calculatedMetrics.append(("Total Missdecisions", 0))
|
||||
calculatedMetrics.append(("Relative Missdecisions", 0))
|
||||
|
||||
# @metric
|
||||
# def median_response_latency_in_ns(connection):
|
||||
# cursor = connection.cursor()
|
||||
# cursor.execute("""SELECT median(PhaseBegin-timeOfGeneration)/1000 FROM transactions INNER JOIN Phases
|
||||
# ON phases.transact = transactions.ID WHERE PhaseName='RESP' """)
|
||||
# result = cursor.fetchone()
|
||||
# return round(result[0],1)
|
||||
|
||||
# @metric
|
||||
# def max_response_latency_in_ns(connection):
|
||||
# cursor = connection.cursor()
|
||||
# cursor.execute("""SELECT max(PhaseBegin-timeOfGeneration)/1000 FROM transactions INNER JOIN Phases
|
||||
# ON phases.transact = transactions.ID WHERE PhaseName='RESP' """)
|
||||
# result = cursor.fetchone()
|
||||
# return round(result[0],1)
|
||||
|
||||
# @metric
|
||||
# def min_response_latency_in_ns(connection):
|
||||
# cursor = connection.cursor()
|
||||
# cursor.execute("""SELECT min(PhaseBegin-timeOfGeneration)/1000 FROM transactions INNER JOIN Phases
|
||||
# ON phases.transact = transactions.ID WHERE PhaseName='RESP' """)
|
||||
# result = cursor.fetchone()
|
||||
# return round(result[0],1)
|
||||
|
||||
# @metric
|
||||
# def stdDev_response_latency_in_ns(connection):
|
||||
# cursor = connection.cursor()
|
||||
# cursor.execute("""SELECT stdev(PhaseBegin-timeOfGeneration)/1000 FROM transactions INNER JOIN Phases
|
||||
# ON phases.transact = transactions.ID WHERE PhaseName='RESP' """)
|
||||
# result = cursor.fetchone()
|
||||
# return round(result[0],1)
|
||||
|
||||
|
||||
@threadMetric
|
||||
def average_response_latency_in_ns(connection, thread):
|
||||
cursor = connection.cursor()
|
||||
@@ -131,22 +102,37 @@ def average_response_latency_in_ns(connection, thread):
|
||||
result = cursor.fetchone()
|
||||
return round(result[0],1)
|
||||
|
||||
# @threadMetric
|
||||
# def median_response_latency_in_ns(connection, thread):
|
||||
# cursor = connection.cursor()
|
||||
# query = """SELECT median(PhaseBegin-timeOfGeneration)/1000 FROM transactions INNER JOIN Phases
|
||||
# ON phases.transact = transactions.ID WHERE PhaseName='RESP' AND TThread = :Thread """
|
||||
def addStallTime(times,begin,end):
|
||||
time = begin
|
||||
while time <= end:
|
||||
if(time in times):
|
||||
times[time] = times[time] + 1
|
||||
else:
|
||||
times[time] = 1
|
||||
time = time + 1
|
||||
|
||||
# cursor.execute(query, {"Thread": thread})
|
||||
# result = cursor.fetchone()
|
||||
# return round(result[0],1)
|
||||
#@threadMetric
|
||||
def paralellism(connection, thread):
|
||||
cursor = connection.cursor()
|
||||
stalltimes = {}
|
||||
query = """SELECT transactions.ID,MIN(phaseBegin)/:clk,MAX(phaseEnd)/:clk
|
||||
from phases inner join transactions on phases.transact=transactions.id
|
||||
where phaseName Not in ('REQ','RESP') and tthread=:Thread group by transactions.ID """
|
||||
|
||||
# @metric
|
||||
# def number_of_activates(connection):
|
||||
# cursor = connection.cursor()
|
||||
# cursor.execute("SELECT COUNT(*) FROM Phases WHERE PhaseName = 'ACT'")
|
||||
# result = cursor.fetchone()
|
||||
# return result[0]
|
||||
cursor.execute(query, {"Thread": thread, "clk" : getClock(connection)})
|
||||
for currentRow in cursor:
|
||||
addStallTime(stalltimes,currentRow[1],currentRow[2])
|
||||
para = 0
|
||||
for time in stalltimes:
|
||||
para = para + stalltimes[time]
|
||||
return round(para/len(stalltimes),2)
|
||||
|
||||
@metric
|
||||
def number_of_activates(connection):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT COUNT(*) FROM Phases WHERE PhaseName = 'ACT'")
|
||||
result = cursor.fetchone()
|
||||
return result[0]
|
||||
|
||||
# @metric
|
||||
# def number_of_precharges(connection):
|
||||
@@ -155,12 +141,12 @@ def average_response_latency_in_ns(connection, thread):
|
||||
# result = cursor.fetchone()
|
||||
# return result[0]
|
||||
|
||||
# @metric
|
||||
# def accesses_per_activate(connection):
|
||||
# cursor = connection.cursor()
|
||||
# cursor.execute("SELECT COUNT(*) FROM Phases WHERE PhaseName IN ('REQ')")
|
||||
# result = cursor.fetchone()
|
||||
# return round(result[0]*1.0/number_of_activates(connection),1)
|
||||
@metric
|
||||
def accesses_per_activate(connection):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT COUNT(*) FROM Phases WHERE PhaseName IN ('REQ')")
|
||||
result = cursor.fetchone()
|
||||
return round(result[0]*1.0/number_of_activates(connection),1)
|
||||
|
||||
def timeInPowerStates(connection):
|
||||
totalTimeAllBanks = getTraceLength(connection)*getNumberOfBanks(connection)
|
||||
@@ -247,33 +233,31 @@ def passRatio(connection):
|
||||
|
||||
def calculateMetrics(pathToTrace):
|
||||
connection = sqlite3.connect(pathToTrace)
|
||||
#connection.create_aggregate("median", 1, pystaggrelite3.median)
|
||||
#connection.create_aggregate("stdev", 1, pystaggrelite3.stdev)
|
||||
|
||||
calculatedMetrics = []
|
||||
|
||||
print("================================")
|
||||
print("Calculating metrics for {0}".format(pathToTrace))
|
||||
|
||||
|
||||
for metric in metrics:
|
||||
res = (metric.__name__.replace("_"," "), metric(connection))
|
||||
print("{0}: {1}".format(res[0],res[1]))
|
||||
calculatedMetrics.append(res)
|
||||
|
||||
for thread in getThreads(connection):
|
||||
for metric in threadMetrics:
|
||||
res = ("Thread " + str(thread) + " " + metric.__name__.replace("_"," "), metric(connection, thread))
|
||||
if(len(getThreads(connection))==1):
|
||||
for metric in metrics:
|
||||
res = (metric.__name__.replace("_"," "), metric(connection))
|
||||
print("{0}: {1}".format(res[0],res[1]))
|
||||
calculatedMetrics.append(res)
|
||||
|
||||
calculatedMetrics.append(("test",0))
|
||||
#calculatedMetrics.extend(passRatio(connection))
|
||||
if(len(getThreads(connection))>1):
|
||||
# for thread in getThreads(connection):
|
||||
# for metric in threadMetrics:
|
||||
# res = ("Thread " + str(thread) + " " + metric.__name__.replace("_"," "), metric(connection, thread))
|
||||
# print("{0}: {1}".format(res[0],res[1]))
|
||||
# calculatedMetrics.append(res)
|
||||
calculatedMetrics.extend(passRatio(connection))
|
||||
#refreshMissDecision(connection, calculatedMetrics)
|
||||
|
||||
#calculatedMetrics.extend(timeInPowerStates(connection))
|
||||
#print(calculatedMetrics[-1])
|
||||
#print(calculatedMetrics[-2])
|
||||
|
||||
refreshMissDecision(connection, calculatedMetrics)
|
||||
print(calculatedMetrics[-1])
|
||||
print(calculatedMetrics[-2])
|
||||
connection.close()
|
||||
return calculatedMetrics
|
||||
|
||||
|
||||
Reference in New Issue
Block a user