Adapt metric for separate command buses.

This commit is contained in:
Lukas Steiner
2022-03-31 17:02:02 +02:00
parent e24ec133cc
commit 4346fc72cb

View File

@@ -39,24 +39,51 @@ def trace_length_in_ns(connection):
@metric
def command_bus_utilisation_in_percent(connection):
cursor = connection.cursor()
cursor.execute("""
SELECT
SUM(CommandLengths.Length)
FROM
Phases
INNER JOIN
CommandLengths
cursor.execute("""SELECT RowColumnCommandBus FROM GeneralInfo""")
rowColumnCommandBus = cursor.fetchone()[0]
if rowColumnCommandBus:
cursor.execute("""
SELECT SUM(CommandLengths.Length)
FROM Phases
INNER JOIN CommandLengths
ON Phases.PhaseName = CommandLengths.Command
""")
result = cursor.fetchone()[0]
WHERE PhaseName <> 'RD' AND PhaseName <> 'RDA' AND PhaseName <> 'WR' AND PhaseName <> 'WRA'
""")
rowBusUtil = cursor.fetchone()[0]
if rowBusUtil is None:
rowBusUtil = 0
cursor.execute("""
SELECT SUM(CommandLengths.Length)
FROM Phases
INNER JOIN CommandLengths
ON Phases.PhaseName = CommandLengths.Command
WHERE PhaseName = 'RD' OR PhaseName = 'RDA' OR PhaseName = 'WR' OR PhaseName = 'WRA'
""")
columnBusUtil = cursor.fetchone()[0]
if columnBusUtil is None:
columnBusUtil = 0
clk, _ = getClock(connection)
traceEnd = getTraceEndTime(connection)
rowBusOccupied = rowBusUtil * clk / traceEnd * 100
columnBusOccupied = columnBusUtil * clk / traceEnd * 100
return "row commands: {}, column commands: {}".format(rowBusOccupied, columnBusOccupied)
else:
cursor.execute("""
SELECT SUM(CommandLengths.Length)
FROM Phases
INNER JOIN CommandLengths
ON Phases.PhaseName = CommandLengths.Command
""")
util = cursor.fetchone()[0]
if (util is None):
util = 0
if (result is None):
result = 0
clk, _ = getClock(connection)
traceEnd = getTraceEndTime(connection)
cmdBusOccupied = result * clk
return cmdBusOccupied / traceEnd * 100
clk, _ = getClock(connection)
traceEnd = getTraceEndTime(connection)
commandBusOccupied = util * clk / traceEnd * 100
return ": {}".format(commandBusOccupied)
@metric
def average_response_latency_in_ns(connection):
@@ -1027,7 +1054,7 @@ def calculateMetrics(pathToTrace, selectedMetrics=[]):
nbanks = nbanks + 1
r = (name, float(v))
calculatedMetrics.append(r)
elif (metric.__name__ == "delayed_reasons"):
elif (metric.__name__ == "delayed_reasons" or metric.__name__ == "command_bus_utilisation_in_percent"):
values = mres.split(",")
for v in values:
name = mname + " (" + v.partition(":")[0].strip() + ")"