Power down related metrics properly displayed (issue#59)
The following metrics will be generated: - time in PDNA in ns - time in PDNA percent - time in PDNP in ns - time in PDNP percent - time in SREF in ns - time in SREF percent - time in power down states in ns - time in power down states percent Other changes: Avoid a crash that was generated for channels which no accesses performed by trace players. Now a message will be displayed explained that no metrics were generated due to the lack of accesses.
This commit is contained in:
@@ -31,13 +31,6 @@ def getNumberOfBanks(connection):
|
||||
return result[0]
|
||||
|
||||
|
||||
def getTraceLength(connection):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT TraceEnd FROM GeneralInfo")
|
||||
result = cursor.fetchone()
|
||||
return result[0]
|
||||
|
||||
|
||||
def getClock(connection):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT clk FROM GeneralInfo")
|
||||
@@ -79,7 +72,6 @@ def trace_length_in_ns(connection):
|
||||
def average_response_latency_in_ns(connection):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("""SELECT AVG(RESP.PHASEBEGIN - REQ.PHASEBEGIN)/1000 FROM PHASES REQ, PHASES RESP WHERE REQ.PHASENAME = 'REQ' AND RESP.PHASENAME='RESP' AND REQ.TRANSACT = RESP.TRANSACT """)
|
||||
|
||||
result = cursor.fetchone()
|
||||
return round(result[0], 1)
|
||||
|
||||
@@ -88,7 +80,6 @@ def average_response_latency_in_ns(connection):
|
||||
def trans_with_max_response_latency(connection):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(""" SELECT REQ.TRANSACT, max(RESP.PHASEBEGIN - REQ.PHASEBEGIN)/1000 FROM PHASES REQ, PHASES RESP WHERE REQ.PHASENAME = 'REQ' AND RESP.PHASENAME='RESP' AND REQ.TRANSACT = RESP.TRANSACT """)
|
||||
|
||||
result = cursor.fetchone()
|
||||
return result[0]
|
||||
|
||||
@@ -262,41 +253,72 @@ def accesses_per_activate(connection):
|
||||
|
||||
|
||||
@metric
|
||||
def timeInPowerStates(connection):
|
||||
totalTimeAllBanks = getTraceLength(connection) # *getNumberOfBanks(connection)
|
||||
def time_in_PDNA_in_ns(connection):
|
||||
cursor = connection.cursor()
|
||||
result = []
|
||||
|
||||
cursor.execute("SELECT SUM(PhaseEnd-PhaseBegin) from Phases where PhaseName = 'PDNA'")
|
||||
cursor.execute("SELECT SUM(PhaseEnd - PhaseBegin)/1000 from Phases where PhaseName = 'PDNA'")
|
||||
timeInPDNA = cursor.fetchone()
|
||||
totalTimeInPDNA = timeInPDNA[0]
|
||||
if (totalTimeInPDNA is None):
|
||||
totalTimeInPDNA = 0.0
|
||||
fractionInPDNA = totalTimeInPDNA*1.0/totalTimeAllBanks
|
||||
result.append(("Time in PDNA (%)", fractionInPDNA*100))
|
||||
print("{0} {1}".format(result[-1][0], result[-1][1]))
|
||||
return totalTimeInPDNA
|
||||
|
||||
cursor.execute("SELECT SUM(PhaseEnd-PhaseBegin) from Phases where PhaseName = 'PDNP'")
|
||||
|
||||
@metric
|
||||
def time_in_PDNA_percent(connection):
|
||||
totalTimeAllBanks = trace_length_in_ns(connection)
|
||||
return time_in_PDNA_in_ns(connection) * 1.0 / totalTimeAllBanks
|
||||
|
||||
|
||||
@metric
|
||||
def time_in_PDNP_in_ns(connection):
|
||||
cursor = connection.cursor()
|
||||
result = []
|
||||
cursor.execute("SELECT SUM(PhaseEnd - PhaseBegin)/1000 from Phases where PhaseName = 'PDNP'")
|
||||
timeInPDNP = cursor.fetchone()
|
||||
totalTimeInPDNP = timeInPDNP[0]
|
||||
if (totalTimeInPDNP is None):
|
||||
totalTimeInPDNP = 0.0
|
||||
fractionInPDNP = totalTimeInPDNP*1.0/totalTimeAllBanks
|
||||
result.append(("Time in PDNP (%)", fractionInPDNP*100))
|
||||
print("{0} {1}".format(result[-1][0], result[-1][1]))
|
||||
return totalTimeInPDNP
|
||||
|
||||
cursor.execute("SELECT SUM(PhaseEnd-PhaseBegin) from Phases where PhaseName = 'SREF'")
|
||||
|
||||
@metric
|
||||
def time_in_PDNP_percent(connection):
|
||||
totalTimeAllBanks = trace_length_in_ns(connection)
|
||||
return (time_in_PDNP_in_ns(connection) * 1.0 / totalTimeAllBanks) * 100
|
||||
|
||||
|
||||
@metric
|
||||
def time_in_SREF_in_ns(connection):
|
||||
cursor = connection.cursor()
|
||||
result = []
|
||||
cursor.execute("SELECT SUM(PhaseEnd - PhaseBegin)/1000 from Phases where PhaseName = 'SREF'")
|
||||
timeInSREF = cursor.fetchone()
|
||||
totalTimeInSREF = timeInSREF[0]
|
||||
if (totalTimeInSREF is None):
|
||||
totalTimeInSREF = 0.0
|
||||
fractionInSREF = totalTimeInSREF*1.0/totalTimeAllBanks
|
||||
result.append(("Time in SREF (%)", fractionInSREF*100))
|
||||
print("{0} {1}".format(result[-1][0], result[-1][1]))
|
||||
result.insert(0, ("Active time (%)", (1-fractionInPDNA-fractionInPDNP-fractionInSREF)*100))
|
||||
print("{0} {1}".format(result[0][0], result[0][1]))
|
||||
return totalTimeInSREF
|
||||
|
||||
return result
|
||||
|
||||
@metric
|
||||
def time_in_SREF_percent(connection):
|
||||
totalTimeAllBanks = trace_length_in_ns(connection)
|
||||
return (time_in_SREF_in_ns(connection) * 1.0 / totalTimeAllBanks) * 100
|
||||
|
||||
|
||||
@metric
|
||||
def time_in_power_down_states_in_ns(connection):
|
||||
totalTimeInPDNA = time_in_PDNA_in_ns(connection)
|
||||
totalTimeInPDNP = time_in_PDNP_in_ns(connection)
|
||||
totalTimeInSREF = time_in_SREF_in_ns(connection)
|
||||
totalTimePdnStates = totalTimeInPDNA + totalTimeInPDNP + totalTimeInSREF
|
||||
return totalTimePdnStates
|
||||
|
||||
|
||||
@metric
|
||||
def time_in_power_down_states_percent(connection):
|
||||
totalTimeAllBanks = trace_length_in_ns(connection)
|
||||
return (time_in_power_down_states_in_ns(connection) * 1.0 / totalTimeAllBanks) * 100
|
||||
|
||||
|
||||
def passRatio(connection):
|
||||
@@ -351,6 +373,8 @@ def calculateMetrics(pathToTrace):
|
||||
print("================================")
|
||||
print("Calculating metrics for {0}".format(pathToTrace))
|
||||
|
||||
print("Number of threads is {0}".format(len(getThreads(connection))))
|
||||
|
||||
if (len(getThreads(connection)) == 1):
|
||||
for metric in metrics:
|
||||
res = (metric.__name__.replace("_", " "), metric(connection))
|
||||
@@ -366,13 +390,11 @@ def calculateMetrics(pathToTrace):
|
||||
calculatedMetrics.extend(passRatio(connection))
|
||||
# refreshMissDecision(connection, calculatedMetrics)
|
||||
|
||||
# calculatedMetrics.extend(timeInPowerStates(connection))
|
||||
# print(calculatedMetrics[-1])
|
||||
# print(calculatedMetrics[-2])
|
||||
if (len(getThreads(connection)) == 0):
|
||||
res = ("No accesses were performed for this channel, number of metrics generated", 0.0)
|
||||
calculatedMetrics.append(res)
|
||||
|
||||
# refreshMissDecision(connection, calculatedMetrics)
|
||||
print(calculatedMetrics[-1])
|
||||
print(calculatedMetrics[-2])
|
||||
connection.close()
|
||||
return calculatedMetrics
|
||||
|
||||
|
||||
Reference in New Issue
Block a user