diff --git a/DRAMSys/analyzer/scripts/plots.py b/DRAMSys/analyzer/scripts/plots.py index c161140d..d09bc31f 100755 --- a/DRAMSys/analyzer/scripts/plots.py +++ b/DRAMSys/analyzer/scripts/plots.py @@ -22,52 +22,48 @@ def memory_utilisation_window(connection, tracePath): # Besides, extracting the data from the memory specs, it is feasible to calculate the maximum data rate of the memory and then determine the bandwidth in Gbit/s. # The bandwidth data are then plotted in two graphics. - steps = 1000 cursor = connection.cursor() - cursor.execute(""" SELECT max(DataStrobeEnd) FROM Transactions """) - total = cursor.fetchone() - windowSize = ceil(float(total[0])/float(steps)) - if (windowSize == 0): - windowSize = 1 - # print(steps) + cursor.execute(""" SELECT max(time) FROM Power """) + maxTime = cursor.fetchone() + cursor.execute(""" SELECT min(time) FROM Power where time > 0 """) + windowSize = cursor.fetchone()[0] + steps = ceil(float(maxTime[0])/float(windowSize)) # 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 maxDataRate = maximum_data_rate(connection) - # print(width) - # print(clk) - # print(rate) - bandwidthPercentage = [0] * steps - bandwidth = [0] * steps + bandwidthPercentage = [0] * (steps+1) + bandwidth = [0] * (steps+1) + bandwidthPercentage[0] = 0 + bandwidth[0] = 0 for i in range(steps): - # print(i) - bandwidthPercentage[i] = 0 + bandwidthPercentage[i+1] = 0 cursor.execute(queryPart, (i*windowSize, (i+1)*windowSize)) result = cursor.fetchone() if(result is None): cursor.execute(queryFull, (i*windowSize, (i+1)*windowSize)) result = cursor.fetchone() if(result[0] is not None): - bandwidthPercentage[i] += int(result[0]) + bandwidthPercentage[i+1] += int(result[0]) # print(bandwidthPercentage[i]) cursor.execute(queryEnd, (i*windowSize, i*windowSize, i*windowSize, (i+1)*windowSize)) result = cursor.fetchone() if(result[0] is not None): - bandwidthPercentage[i] += int(result[0]) + bandwidthPercentage[i+1] += int(result[0]) # print(bandwidthPercentage[i]) cursor.execute(queryBegin, ((i+1)*windowSize, i*windowSize, (i+1)*windowSize, (i+1)*windowSize)) result = cursor.fetchone() if(result[0] is not None): - bandwidthPercentage[i] += int(result[0]) + bandwidthPercentage[i+1] += int(result[0]) # print(bandwidthPercentage[i]) else: - bandwidthPercentage[i] = windowSize + bandwidthPercentage[i+1] = windowSize # print(bandwidthPercentage[i]) - bandwidthPercentage[i] = float(bandwidthPercentage[i]/windowSize) - bandwidth[i] = float(bandwidthPercentage[i])*float(maxDataRate)/1024 - bandwidthPercentage[i] *= 100 + bandwidthPercentage[i+1] = float(bandwidthPercentage[i+1]/windowSize) + bandwidth[i+1] = float(bandwidthPercentage[i+1])*float(maxDataRate)/1024 + bandwidthPercentage[i+1] *= 100 name = ntpath.basename(tracePath) basename, extension = os.path.splitext(name) @@ -79,8 +75,7 @@ def memory_utilisation_window(connection, tracePath): import numpy as np from matplotlib.backends.backend_pdf import PdfPages - time = np.arange(0, steps*windowSize, windowSize) - + time = np.arange(0, (steps+1)*windowSize, windowSize) plt.figure() subplotIndex = 211 @@ -110,13 +105,13 @@ def power_window(connection, tracePath): cursor = connection.cursor() cursor.execute(""" SELECT max(time) FROM Power """) maxTime = cursor.fetchone() - cursor.execute(""" SELECT min(time) FROM Power WHERE time > 0""") - windowSize = cursor.fetchone() - steps = ceil(float(maxTime[0])/float(windowSize[0])) + cursor.execute(""" SELECT min(time) FROM Power where time > 0 """) + windowSize = cursor.fetchone()[0] + steps = ceil(float(maxTime[0])/float(windowSize)) cursor.execute(""" SELECT * FROM Power """) - time = [0] * steps - power = [0] * steps - for i in range(steps): + time = [0] * (steps+1) + power = [0] * (steps+1) + for i in range((steps+1)): result = cursor.fetchone() time[i] = float(result[0]) * 1000000000 # convertion of seconds to nanoseconds power[i] = float(result[1]) # values are stored in mW diff --git a/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp b/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp index 60bf4a55..acb5c4f1 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp @@ -324,9 +324,8 @@ void ConfigurationLoader::loadWideIO(Configuration& config, XMLElement* memspec) //MemTimings XMLElement* timings = memspec->FirstChildElement("memtimingspec"); double clkMhz = queryDoubleParameter(timings, "clkMhz"); - sc_time clk = sc_time(1 / clkMhz, SC_US); - config.memSpec.clk = clk; - + config.memSpec.clk = FrequencyToClk(clkMhz); + sc_time clk = config.memSpec.clk; config.memSpec.tRP = clk * queryUIntParameter(timings, "RP"); config.memSpec.tRAS = clk * queryUIntParameter(timings, "RAS"); config.memSpec.tRC = clk * queryUIntParameter(timings, "RC"); @@ -385,4 +384,3 @@ void ConfigurationLoader::loadWideIO(Configuration& config, XMLElement* memspec) config.memSpec.vDD = queryDoubleParameter(powers, "vdd"); config.memSpec.vDD2 = queryDoubleParameter(powers, "vdd2"); } -