Merge branch 'fix_pyhton_scripts' into 'develop'
Numerous fixes for Python scripts See merge request ems/astdm/modeling.dram/dram.sys.5!52
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -27,3 +27,4 @@ DRAMSys/docs/doxygen
|
||||
cmake-build*
|
||||
.idea
|
||||
.cache
|
||||
.env
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (c) 2021, RPTU Kaiserslautern-Landau
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
|
||||
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Authors:
|
||||
# Derek Christ
|
||||
|
||||
import importlib.util
|
||||
|
||||
def checkTqdm():
|
||||
if (spec := importlib.util.find_spec("tqdm")) is not None:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def checkVcd():
|
||||
if (spec := importlib.util.find_spec("vcd")) is not None:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def checkVcdExport():
|
||||
return checkVcd() and checkTqdm()
|
||||
@@ -57,7 +57,7 @@ def getNumberOfTransactions(dbconnection):
|
||||
|
||||
def getTraceEndTime(dbconnection):
|
||||
cursor = dbconnection.cursor()
|
||||
cursor.execute("SELECT TraceEnd FROM GeneralInfo")
|
||||
cursor.execute("SELECT MAX(PhaseEnd) FROM Phases")
|
||||
result = cursor.fetchone()
|
||||
return result[0]
|
||||
|
||||
@@ -162,6 +162,6 @@ def get_total_time_in_phase(connection, phase):
|
||||
|
||||
def getCommandLengthForPhase(connection, phase):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT " + phase + " FROM CommandLengths")
|
||||
cursor.execute(f"SELECT Length FROM CommandLengths WHERE Command=\"{phase}\"")
|
||||
length = cursor.fetchone()
|
||||
return length[0]
|
||||
|
||||
@@ -760,9 +760,7 @@ def bank_overlap_ratio(connection):
|
||||
banksPerGroup = int(numberOfBanks / numberOfBankGroups)
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT TraceEnd FROM GeneralInfo")
|
||||
traceEndTMP = cursor.fetchone()
|
||||
traceEnd = int(traceEndTMP[0] / clk)
|
||||
traceEnd = getTraceEndTime(connection)
|
||||
trace = []
|
||||
|
||||
cursor.execute("""
|
||||
|
||||
@@ -621,8 +621,7 @@ def generatePlots(pathToTrace):
|
||||
if(windowSize == 0):
|
||||
outputFiles = "No output file created. Check WindowSize and EnableWindowing configs."
|
||||
else:
|
||||
cursor.execute(" SELECT TraceEnd FROM GeneralInfo ")
|
||||
traceEnd = float(cursor.fetchone()[0])
|
||||
traceEnd = getTraceEndTime(connection)
|
||||
steps = int(ceil(traceEnd/windowSize))
|
||||
for p in plots:
|
||||
outputFiles += p(connection, pathToTrace, steps)
|
||||
|
||||
@@ -79,12 +79,10 @@ class Event():
|
||||
self.value = value
|
||||
|
||||
class Transaction():
|
||||
def __init__(self, rank, bankgroup, bank, dataStrobeBegin, dataStrobeEnd, command):
|
||||
def __init__(self, rank, bankgroup, bank, command):
|
||||
self.rank = rank
|
||||
self.bankgroup = bankgroup
|
||||
self.bank = bank
|
||||
self.dataStrobeBegin = dataStrobeBegin
|
||||
self.dataStrobeEnd = dataStrobeEnd
|
||||
self.command = command
|
||||
|
||||
class Granularity(enum.Enum):
|
||||
@@ -141,7 +139,7 @@ def getUnitOfTime(connection):
|
||||
|
||||
def getLastTimestamp(connection):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT DataStrobeEnd FROM Transactions ORDER BY DataStrobeEnd DESC LIMIT 1")
|
||||
cursor.execute("SELECT DataStrobeEnd FROM Phases ORDER BY DataStrobeEnd DESC LIMIT 1")
|
||||
|
||||
return cursor.fetchone()[0]
|
||||
|
||||
@@ -189,7 +187,7 @@ def getDataBusEvents(connection, eventDict, windowRange):
|
||||
beginWindow, endWindow = windowRange
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT ID, DataStrobeBegin, DataStrobeEnd, Command FROM Transactions " +
|
||||
cursor.execute("SELECT Transactions.ID, DataStrobeBegin, DataStrobeEnd, Command FROM Phases INNER JOIN Transactions ON Transactions.ID=Phases.Transact " +
|
||||
"WHERE DataStrobeBegin BETWEEN " + str(beginWindow) + " AND " + str(endWindow) +
|
||||
" AND DataStrobeEnd BETWEEN " + str(beginWindow) + " AND " + str(endWindow))
|
||||
|
||||
@@ -319,17 +317,17 @@ def getTransactions(connection, transactionDict, transactionRange):
|
||||
minTransaction, maxTransaction = transactionRange
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT ID, TRank, TBankgroup, TBank, DataStrobeBegin, DataStrobeEnd, Command FROM Transactions" +
|
||||
" WHERE ID BETWEEN " + str(minTransaction) + " AND " + str(maxTransaction))
|
||||
cursor.execute("SELECT Transactions.ID, Rank, Bankgroup, Bank, Command FROM Transactions INNER JOIN Phases ON Transactions.ID=Phases.Transact" +
|
||||
" WHERE Transactions.ID BETWEEN " + str(minTransaction) + " AND " + str(maxTransaction))
|
||||
|
||||
for transactionId, rank, bankgroup, bank, dataStrobeBegin, dataStrobeEnd, command in cursor.fetchall():
|
||||
for transactionId, rank, bankgroup, bank, command in cursor.fetchall():
|
||||
(ranks, bankgroups, banks) = getRanksBankgroupsBanks(connection)
|
||||
|
||||
rank = rank % ranks
|
||||
bankgroup = bankgroup % bankgroups
|
||||
bank = bank % banks
|
||||
|
||||
currentTransaction = Transaction(rank, bankgroup, bank, dataStrobeBegin, dataStrobeEnd, command)
|
||||
currentTransaction = Transaction(rank, bankgroup, bank, command)
|
||||
transactionDict[transactionId] = currentTransaction
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user