Fix a bug in command bus utilization metric and plot

This commit is contained in:
2022-02-10 15:00:52 +01:00
parent 88d988e0ca
commit 0f307257fe
2 changed files with 130 additions and 17 deletions

View File

@@ -51,7 +51,7 @@ def command_bus_utilisation_in_percent(connection):
result = cursor.fetchone()[0]
clk, _ = getClock(connection)
traceEnd = getTraceEndTime(connection)
cmdBusOccupied = result / clk * 1_000_000
cmdBusOccupied = result * clk
return cmdBusOccupied / traceEnd * 100
@metric

View File

@@ -84,11 +84,57 @@ def calculate_bandwidth_util(connection, windowSize, steps, queryFull, queryEnd,
def memory_utilisation_window_thread(connection, tracePath, steps, thread_ID):
# All possible cases of data transfers inside a time window
queryFull = """ SELECT sum(DataStrobeEnd - DataStrobeBegin) FROM transactions Where DataStrobeBegin >= ? and DataStrobeEnd <= ? and TThread = {0}""" # The data transfer begins and ends inside the time window
queryEnd = """ SELECT sum(DataStrobeEnd - ?) FROM transactions Where DataStrobeBegin < ? and DataStrobeEnd > ? and DataStrobeEnd <=? and TThread = {0}""" # Only the end of the data transfer is inside the time window
queryBegin = """ SELECT sum(? - DataStrobeBegin) FROM transactions Where DataStrobeBegin >= ? and DataStrobeBegin < ? and DataStrobeEnd > ? and TThread = {0}""" # Only the beginning of the data transfer is inside the time window
queryPart = """ SELECT DataStrobeBegin FROM transactions Where DataStrobeBegin <= ? and DataStrobeEnd >= ? and TThread = {0}""" # The data transfer occupies all the time window
## All possible cases of data transfers inside a time window:
# The data transfer begins and ends inside the time window
queryFull = """
SELECT
SUM(DataStrobeEnd - DataStrobeBegin)
FROM
transactions
WHERE
DataStrobeBegin >= ?
AND DataStrobeEnd <= ?
AND TThread = {0}
"""
# Only the end of the data transfer is inside the time window
queryEnd = """
SELECT
SUM(DataStrobeEnd - ? )
FROM
transactions
WHERE
DataStrobeBegin < ?
AND DataStrobeEnd > ?
AND DataStrobeEnd <=?
AND TThread = {0}
"""
# Only the beginning of the data transfer is inside the time window
queryBegin = """
SELECT
SUM( ? - DataStrobeBegin)
FROM
transactions
WHERE
DataStrobeBegin >= ?
AND DataStrobeBegin < ?
AND DataStrobeEnd > ?
AND TThread = {0}
"""
# The data transfer occupies all the time window
queryPart = """
SELECT
DataStrobeBegin
FROM
transactions
WHERE
DataStrobeBegin <= ?
AND DataStrobeEnd >= ?
AND TThread = {0}
"""
queryFull = queryFull.format(thread_ID)
queryEnd = queryEnd.format(thread_ID)
@@ -102,7 +148,7 @@ def memory_utilisation_window_thread(connection, tracePath, steps, thread_ID):
outputFileNameBWMatlab, basename = createOutputFilename(tracePath, 'memory_utilization_percent', 'thread_' + str(thread_ID) + '_', 'txt')
return bandwidthPercentage, bandwidth, outputFileNameBWMatlab
#@plot
@plot
def memory_utilisation_window(connection, tracePath, steps):
# This function determines the average memory bandwidth over time in
# percentage and in Gbit/s. The average bandwidth over time is done
@@ -119,11 +165,53 @@ def memory_utilisation_window(connection, tracePath, steps):
windowSize = getWindowSize(connection)
maxDataRate = maximum_data_rate(connection)
# 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
## All possible cases of data transfers inside a time window:
# The data transfer begins and ends inside the time window
queryFull = """
SELECT
SUM(DataStrobeEnd - DataStrobeBegin)
FROM
transactions
WHERE
DataStrobeBegin >= ?
AND DataStrobeEnd <= ?
"""
# Only the end of the data transfer is inside the time window
queryEnd = """
SELECT
SUM(DataStrobeEnd - ?)
FROM
transactions
WHERE
DataStrobeBegin < ?
AND DataStrobeEnd > ?
AND DataStrobeEnd <= ?
"""
# Only the beginning of the data transfer is inside the time window
queryBegin = """
SELECT
SUM(? - DataStrobeBegin)
FROM
transactions
WHERE
DataStrobeBegin >= ?
AND DataStrobeBegin < ?
AND DataStrobeEnd > ?
"""
# The data transfer occupies all the time window
queryPart = """
SELECT
DataStrobeBegin
FROM
transactions
WHERE
DataStrobeBegin <= ?
AND DataStrobeEnd >= ?
"""
bandwidthPercentage, bandwidth, maximumPercentage = calculate_bandwidth_util(connection, windowSize, steps, queryFull, queryEnd, queryBegin, queryPart)
@@ -347,19 +435,38 @@ def command_bus_utilisation_window(connection, tracePath, steps):
windowSize = getWindowSize(connection)
cursor = connection.cursor()
query = """
# Query that sums all lengths that are completely contained in the window
query_full = """
SELECT
SUM(CommandLengths.Length)
FROM
Phases
Phases,
GeneralInfo
INNER JOIN
CommandLengths
ON Phases.PhaseName = CommandLengths.Command
WHERE
Phases.PhaseBegin >= ?
AND Phases.PhaseBegin < ?
AND (Phases.PhaseBegin + (CommandLengths.Length * GeneralInfo.clk)) < ?
"""
# Gets the PhaseBegin of the command that reaches out of the window
# query_border = """
# SELECT
# Phases.PhaseBegin
# FROM
# Phases,
# GeneralInfo
# INNER JOIN
# CommandLengths
# ON Phases.PhaseName = CommandLengths.Command
# WHERE
# Phases.PhaseBegin >= ?
# AND Phases.PhaseBegin < ?
# AND (Phases.PhaseBegin + (CommandLengths.Length * GeneralInfo.clk)) >= ?
# """
outputFileName, basename = createOutputFilename(tracePath, 'command_bus_utilisation', '', 'pdf')
outputFile = "{0}\n\t".format(outputFileName)
@@ -376,13 +483,19 @@ def command_bus_utilisation_window(connection, tracePath, steps):
utilization = [None] * steps
for i in range(steps):
cursor.execute(query, (i * windowSize, (i + 1) * windowSize))
left_limit = i * windowSize
right_limit = (i + 1) * windowSize
cursor.execute(query_full, (left_limit, right_limit))
result = cursor.fetchone()[0]
cmdBusOccupied = result / clk * 1_000_000
cmdBusOccupied = result * clk
time[i] = ((i * windowSize) - (windowSize / 2)) / 1000 # ps to ns
utilization[i] = cmdBusOccupied / windowSize * 100
if (utilization[i] > 100):
print(left_limit, right_limit)
LatencyFigurePlot.plot(time, utilization, linewidth=0.5, label="Utilization")
LatencyFigurePlot.legend(loc="upper left")