changed simulation manager
This commit is contained in:
@@ -17,9 +17,11 @@ CREATE TABLE GeneralInfo(
|
||||
NumberOfTransactions INTEGER,
|
||||
TraceEnd INTEGER,
|
||||
NumberOfBanks INTEGER,
|
||||
Description TEXT,
|
||||
clk INTEGER,
|
||||
UnitOfTime TEXT
|
||||
UnitOfTime TEXT,
|
||||
Memconfig TEXT,
|
||||
Memspec TEXT,
|
||||
Traces TEXt
|
||||
);
|
||||
|
||||
|
||||
@@ -47,6 +49,7 @@ CREATE TABLE Transactions(
|
||||
TThread INTEGER,
|
||||
TChannel INTEGER,
|
||||
TBank INTEGER,
|
||||
TBankgroup INTEGER,
|
||||
TRow INTEGER,
|
||||
TColumn INTEGER,
|
||||
Command TEXT,
|
||||
|
||||
@@ -41,8 +41,6 @@ void TlmRecorder::recordPhase(tlm::tlm_generic_payload& trans, tlm::tlm_phase ph
|
||||
if (currentTransactionsInSystem.count(&trans) == 0)
|
||||
introduceNewTransactionToSystem(time, trans);
|
||||
|
||||
unsigned int id = currentTransactionsInSystem[&trans];
|
||||
|
||||
string phaseName = phaseNameToString(phase);
|
||||
string phaseBeginPrefix = "BEGIN_";
|
||||
string phaseEndPrefix = "END_";
|
||||
@@ -73,7 +71,7 @@ void TlmRecorder::recordDebugMessage(std::string message, sc_time time)
|
||||
|
||||
void TlmRecorder::createTables(string pathToURI)
|
||||
{
|
||||
string initial = getFileContents(pathToURI);
|
||||
string initial = loadTextFileContents(pathToURI);
|
||||
executeSqlCommand(initial);
|
||||
}
|
||||
|
||||
@@ -89,7 +87,7 @@ void TlmRecorder::setUpTransactionTerminatingPhases()
|
||||
void TlmRecorder::prepareSqlStatements()
|
||||
{
|
||||
insertTransactionString =
|
||||
"INSERT INTO Transactions VALUES (:id,:rangeID,:address,:burstlength,:thread,:channel,:bank,:row,:column,:command,:dataStrobeBegin,:dataStrobeEnd)";
|
||||
"INSERT INTO Transactions VALUES (:id,:rangeID,:address,:burstlength,:thread,:channel,:bank,:bankgroup,:row,:column,:command,:dataStrobeBegin,:dataStrobeEnd)";
|
||||
insertRangeString = "INSERT INTO Ranges VALUES (:id,:begin,:end)";
|
||||
updateRangeString = "UPDATE Ranges SET End = :end WHERE ID = :id";
|
||||
updateDataStrobeString = "UPDATE Transactions SET DataStrobeBegin = :begin, DataStrobeEnd = :end WHERE ID = :id";
|
||||
@@ -99,7 +97,8 @@ void TlmRecorder::prepareSqlStatements()
|
||||
updatePhaseString =
|
||||
"UPDATE Phases SET PhaseEnd = :end WHERE Transact = :trans AND PhaseName = :name";
|
||||
insertGeneralInfoString =
|
||||
"INSERT INTO GeneralInfo (NumberOfTransactions,TraceEnd,NumberOfBanks,description,clk,UnitOfTime) Values (:numberOfTransactions,:end,:numberOfBanks,:description,:clk,:unitOfTime)";
|
||||
"INSERT INTO GeneralInfo (NumberOfTransactions,TraceEnd,NumberOfBanks,clk,UnitOfTime,Memconfig,Memspec,Traces) Values "
|
||||
"(:numberOfTransactions,:end,:numberOfBanks,:clk,:unitOfTime,:memconfig,:memspec,:traces)";
|
||||
insertDebugMessageString = "INSERT INTO DebugMessages (Time,Message) Values (:time,:message)";
|
||||
|
||||
sqlite3_prepare(db, insertTransactionString.c_str(), -1, &insertTransactionStatement, 0);
|
||||
@@ -134,9 +133,11 @@ void TlmRecorder::insertGeneralInfo()
|
||||
sqlite3_bind_int64(insertGeneralInfoStatement, 2, recordingEndTime.value());
|
||||
sqlite3_bind_int(insertGeneralInfoStatement, 3,
|
||||
core::Configuration::getInstance().NumberOfBanks);
|
||||
sqlite3_bind_text(insertGeneralInfoStatement, 4, "", 0, NULL);
|
||||
sqlite3_bind_int(insertGeneralInfoStatement, 5, core::Configuration::getInstance().Timings.clk.value());
|
||||
sqlite3_bind_text(insertGeneralInfoStatement, 6, "PS", 2, NULL);
|
||||
sqlite3_bind_int(insertGeneralInfoStatement, 4, core::Configuration::getInstance().Timings.clk.value());
|
||||
sqlite3_bind_text(insertGeneralInfoStatement, 5, "PS", 2, NULL);
|
||||
sqlite3_bind_text(insertGeneralInfoStatement, 6, memconfig.c_str(), memconfig.length(), NULL);
|
||||
sqlite3_bind_text(insertGeneralInfoStatement, 7, memspec.c_str(), memspec.length(), NULL);
|
||||
sqlite3_bind_text(insertGeneralInfoStatement, 8, traces.c_str(), traces.length(), NULL);
|
||||
executeSqlStatement(insertGeneralInfoStatement);
|
||||
}
|
||||
void TlmRecorder::insertTransactionInDB(unsigned int id, tlm::tlm_generic_payload& trans)
|
||||
@@ -145,17 +146,17 @@ void TlmRecorder::insertTransactionInDB(unsigned int id, tlm::tlm_generic_payloa
|
||||
sqlite3_bind_int(insertTransactionStatement, 2, id);
|
||||
sqlite3_bind_int(insertTransactionStatement, 3, trans.get_address());
|
||||
sqlite3_bind_int(insertTransactionStatement, 4, trans.get_streaming_width());
|
||||
sqlite3_bind_text(insertTransactionStatement, 10,
|
||||
trans.get_command() == tlm::TLM_READ_COMMAND ? "R" : "W", 1, 0);
|
||||
|
||||
|
||||
const DramExtension& extension = DramExtension::getExtension(trans);
|
||||
sqlite3_bind_int(insertTransactionStatement, 5, extension.getThread().ID());
|
||||
sqlite3_bind_int(insertTransactionStatement, 6, extension.getChannel().ID());
|
||||
sqlite3_bind_int(insertTransactionStatement, 7, extension.getBank().ID());
|
||||
sqlite3_bind_int(insertTransactionStatement, 8, extension.getRow().ID());
|
||||
sqlite3_bind_int(insertTransactionStatement, 9, extension.getColumn().ID());
|
||||
sqlite3_bind_int(insertTransactionStatement, 10, 0);
|
||||
sqlite3_bind_int(insertTransactionStatement, 8, extension.getBankGroup().ID());
|
||||
sqlite3_bind_int(insertTransactionStatement, 9, extension.getRow().ID());
|
||||
sqlite3_bind_int(insertTransactionStatement, 10, extension.getColumn().ID());
|
||||
sqlite3_bind_int(insertTransactionStatement, 11, 0);
|
||||
sqlite3_bind_int(insertTransactionStatement, 12, 0);
|
||||
|
||||
executeSqlStatement(insertTransactionStatement);
|
||||
}
|
||||
@@ -244,25 +245,7 @@ void TlmRecorder::executeSqlCommand(string command)
|
||||
|
||||
printDebugMessage("Database created successfully");
|
||||
}
|
||||
string TlmRecorder::getFileContents(string filename)
|
||||
{
|
||||
ifstream in(filename.c_str(), ios::in | ios::binary);
|
||||
if (in)
|
||||
{
|
||||
string contents;
|
||||
in.seekg(0, ios::end);
|
||||
contents.resize(in.tellg());
|
||||
in.seekg(0, ios::beg);
|
||||
in.read(&contents[0], contents.size());
|
||||
in.close();
|
||||
return (contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
reportFatal("Error in TraceRecorder", "Could not load sql script from " + filename);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TlmRecorder::printDebugMessage(std::string message)
|
||||
{
|
||||
|
||||
@@ -30,12 +30,14 @@ public:
|
||||
void recordDebugMessage(std::string message, sc_time time);
|
||||
void updateDataStrobe(const sc_time& begin, const sc_time& end, tlm::tlm_generic_payload& trans);
|
||||
void closeConnection();
|
||||
|
||||
void recordMemconfig(string memconfig){this->memconfig = memconfig;}
|
||||
void recordMemspec(string memspec){this->memspec = memspec;}
|
||||
void recordTracenames(string traces){this->traces = traces;}
|
||||
private:
|
||||
std::string memconfig,memspec,traces;
|
||||
TlmRecorder();
|
||||
~TlmRecorder();
|
||||
|
||||
std::string getFileContents(std::string filename);
|
||||
|
||||
void executeSqlCommand(std::string command);
|
||||
void executeSqlStatement(sqlite3_stmt* statement);
|
||||
@@ -59,6 +61,7 @@ private:
|
||||
map<tlm::tlm_generic_payload*, unsigned int> currentTransactionsInSystem;
|
||||
unsigned int transactionIDCounter;
|
||||
sc_time recordingEndTime;
|
||||
|
||||
std::vector<tlm::tlm_phase> transactionTerminatingPhases;
|
||||
sqlite3 *db;
|
||||
sqlite3_stmt *insertTransactionStatement, *insertRangeStatement, *updateRangeStatement,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Utils.h"
|
||||
#include <string>
|
||||
#include <tlm.h>
|
||||
#include <fstream>
|
||||
|
||||
using namespace std;
|
||||
using namespace tinyxml2;
|
||||
@@ -10,7 +11,6 @@ void reportFatal(std::string sender, std::string message)
|
||||
SC_REPORT_FATAL(sender.c_str(), message.c_str());
|
||||
}
|
||||
|
||||
|
||||
std::string phaseNameToString(tlm::tlm_phase phase)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@@ -19,7 +19,8 @@ std::string phaseNameToString(tlm::tlm_phase phase)
|
||||
return str;
|
||||
}
|
||||
|
||||
unsigned int queryUIntParameter(XMLElement* node, string name) {
|
||||
unsigned int queryUIntParameter(XMLElement* node, string name)
|
||||
{
|
||||
int result;
|
||||
XMLElement* element;
|
||||
for (element = node->FirstChildElement("parameter"); element != NULL;
|
||||
@@ -34,7 +35,7 @@ unsigned int queryUIntParameter(XMLElement* node, string name) {
|
||||
}
|
||||
}
|
||||
|
||||
reportFatal("Query XML","Parameter '" + name +"' does not exist.");
|
||||
reportFatal("Query XML", "Parameter '" + name + "' does not exist.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -52,7 +53,8 @@ bool parameterExists(tinyxml2::XMLElement* node, std::string name)
|
||||
return false;
|
||||
}
|
||||
|
||||
double queryDoubleParameter(XMLElement* node, string name) {
|
||||
double queryDoubleParameter(XMLElement* node, string name)
|
||||
{
|
||||
double result;
|
||||
XMLElement* element;
|
||||
for (element = node->FirstChildElement("parameter"); element != NULL;
|
||||
@@ -67,11 +69,12 @@ double queryDoubleParameter(XMLElement* node, string name) {
|
||||
}
|
||||
}
|
||||
|
||||
reportFatal("Query XML","Parameter '" + name +"' does not exist.");
|
||||
reportFatal("Query XML", "Parameter '" + name + "' does not exist.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool queryBoolParameter(XMLElement* node, string name) {
|
||||
bool queryBoolParameter(XMLElement* node, string name)
|
||||
{
|
||||
bool result;
|
||||
XMLElement* element;
|
||||
for (element = node->FirstChildElement("parameter"); element != NULL;
|
||||
@@ -86,11 +89,12 @@ bool queryBoolParameter(XMLElement* node, string name) {
|
||||
}
|
||||
}
|
||||
|
||||
reportFatal("Query XML","Parameter '" + name +"' does not exist.");
|
||||
reportFatal("Query XML", "Parameter '" + name + "' does not exist.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
string queryStringParameter(XMLElement* node, string name) {
|
||||
string queryStringParameter(XMLElement* node, string name)
|
||||
{
|
||||
XMLElement* element;
|
||||
for (element = node->FirstChildElement("parameter"); element != NULL;
|
||||
element = element->NextSiblingElement("parameter"))
|
||||
@@ -101,7 +105,7 @@ string queryStringParameter(XMLElement* node, string name) {
|
||||
}
|
||||
}
|
||||
|
||||
reportFatal("Query XML","Parameter '" + name +"' does not exist.");
|
||||
reportFatal("Query XML", "Parameter '" + name + "' does not exist.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -109,8 +113,29 @@ void loadXML(string uri, XMLDocument& doc)
|
||||
{
|
||||
XMLError error = doc.LoadFile(uri.c_str());
|
||||
|
||||
if (error) {
|
||||
if (error)
|
||||
{
|
||||
reportFatal("Configuration", "Error loading xml from: " + uri);
|
||||
}
|
||||
}
|
||||
|
||||
string loadTextFileContents(string filename)
|
||||
{
|
||||
|
||||
ifstream in(filename.c_str(), ios::in | ios::binary);
|
||||
if (in)
|
||||
{
|
||||
string contents;
|
||||
in.seekg(0, ios::end);
|
||||
contents.resize(in.tellg());
|
||||
in.seekg(0, ios::beg);
|
||||
in.read(&contents[0], contents.size());
|
||||
in.close();
|
||||
return (contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
reportFatal("Error loading file", "Could not load textfile from " + filename);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ bool isIn(const T& value, const std::vector<T>& collection)
|
||||
void reportFatal(std::string sender, std::string message);
|
||||
std::string phaseNameToString(tlm::tlm_phase phase);
|
||||
|
||||
std::string loadTextFileContents(std::string filename);
|
||||
void loadXML(std::string uri, tinyxml2::XMLDocument& doc);
|
||||
|
||||
bool parameterExists(tinyxml2::XMLElement* node, std::string name);
|
||||
|
||||
@@ -67,7 +67,7 @@ BankGroup getBankGroup(Bank bank)
|
||||
|
||||
for (unsigned int bank = 0; bank < Configuration::getInstance().NumberOfBanks; bank++)
|
||||
{
|
||||
unsigned int group = bank / Configuration::getInstance().NumberOfBankGroups;
|
||||
unsigned int group = bank % Configuration::getInstance().NumberOfBankGroups;
|
||||
bankgroups.insert(std::pair<Bank, BankGroup>(Bank(bank), BankGroup(group)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,17 +30,15 @@ Simulation::Simulation(sc_module_name name, string pathToResources, string trace
|
||||
Configuration::memconfigUri = pathToResources + string("configs/memconfigs/") + setup.memconfig;
|
||||
Configuration::memspecUri = pathToResources + string("configs/memspecs/") + setup.memspec;
|
||||
|
||||
TlmRecorder::getInstance().recordTracenames(devices[0].trace + "," + devices[1].trace);
|
||||
TlmRecorder::getInstance().recordMemspec(Configuration::memspecUri);
|
||||
TlmRecorder::getInstance().recordMemconfig(loadTextFileContents(Configuration::memconfigUri));
|
||||
|
||||
//setup dram
|
||||
dram = new Dram<>("dram");
|
||||
arbiter = new Arbiter<numberOfTracePlayers, 128>("arbiter");
|
||||
controller = new Controller<>("controller");
|
||||
|
||||
//setup devices
|
||||
for(auto& d : devices)
|
||||
{
|
||||
if(d.burstLength == 0)
|
||||
d.burstLength = 8;
|
||||
}
|
||||
|
||||
player1 = new TracePlayer<>("player1", pathToResources + string("traces/") + devices[0].trace,
|
||||
devices[0].burstLength, this);
|
||||
|
||||
@@ -29,7 +29,7 @@ struct DramSetup
|
||||
struct Device
|
||||
{
|
||||
Device():trace("empty.stl"), burstLength(0){}
|
||||
Device(std::string trace, unsigned int burstLength = 0) : trace(trace), burstLength(burstLength)
|
||||
Device(std::string trace, unsigned int burstLength = 4) : trace(trace), burstLength(burstLength)
|
||||
{
|
||||
}
|
||||
std::string trace;
|
||||
|
||||
@@ -25,8 +25,6 @@ string pathOfFile(string file)
|
||||
return file.substr(0, file.find_last_of('/'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void startTraceAnalyzer(string traceName)
|
||||
{
|
||||
string p = getenv("trace");
|
||||
@@ -50,49 +48,48 @@ bool runSimulation(string resources, string traceName, DramSetup setup, vector<D
|
||||
|
||||
bool batchTraces(DramSetup setup, vector<pair<string, string>> tracePairs)
|
||||
{
|
||||
int id =0;
|
||||
for(pair<string, string> pair : tracePairs)
|
||||
int id = 0;
|
||||
for (pair<string, string> pair : tracePairs)
|
||||
{
|
||||
id++;
|
||||
string traceName = "batch" + to_string(id) + ".tdb";
|
||||
if(runSimulation(resources, traceName, setup, { Device(pair.first), Device(pair.second) }))
|
||||
return true;//kill child
|
||||
string traceName = "traceBatch" + to_string(id) + ".tdb";
|
||||
if (runSimulation(resources, traceName, setup, { Device(pair.first), Device(pair.second) }))
|
||||
return true; //kill child
|
||||
}
|
||||
}
|
||||
|
||||
bool batchSetups(pair<string, string >tracePair, vector<DramSetup> setups)
|
||||
bool batchSetups(pair<string, string> tracePair, vector<DramSetup> setups)
|
||||
{
|
||||
int id =0;
|
||||
for(auto& setup : setups)
|
||||
int id = 0;
|
||||
for (auto& setup : setups)
|
||||
{
|
||||
id++;
|
||||
string traceName = "batch0" + to_string(id) + ".tdb";
|
||||
if(runSimulation(resources, traceName, setup, { Device(tracePair.first), Device(tracePair.second) }))
|
||||
return true;//kill child
|
||||
string traceName = "setupBatch" + to_string(id) + ".tdb";
|
||||
if (runSimulation(resources, traceName, setup,
|
||||
{ Device(tracePair.first), Device(tracePair.second) }))
|
||||
return true; //kill child
|
||||
}
|
||||
}
|
||||
int sc_main(int argc, char **argv)
|
||||
{
|
||||
sc_set_time_resolution(1, SC_PS);
|
||||
|
||||
resources = pathOfFile(argv[0]) + string("/../resources/");
|
||||
|
||||
|
||||
DramSetup setup;
|
||||
setup.memconfig = "memconfig.xml";
|
||||
//setup.memspec = "MICRON_4Gb_DDR4-1866_8bit_A.xml";
|
||||
setup.memspec = "MatzesWideIO.xml";
|
||||
|
||||
DramSetup setup2;
|
||||
setup2.memconfig = "memconfig.xml";
|
||||
setup2.memspec = "MICRON_4Gb_DDR4-1866_8bit_A.xml";
|
||||
resources = pathOfFile(argv[0]) + string("/../resources/");
|
||||
|
||||
DramSetup setup;
|
||||
setup.memconfig = "memconfig.xml";
|
||||
setup.memspec = "MICRON_4Gb_DDR4-1866_8bit_A.xml";
|
||||
//setup.memspec = "MatzesWideIO.xml";
|
||||
|
||||
vector<pair<string, string>> tracePairs;
|
||||
tracePairs.push_back(pair<string, string>("trace.stl", "empty.stl"));
|
||||
tracePairs.push_back(pair<string, string>("trace2.stl", "empty.stl"));
|
||||
//batchTraces(setup, tracePairs);
|
||||
batchSetups(tracePairs[0], {setup, setup2});
|
||||
tracePairs.push_back(pair<string, string>("chstone-mips_32.stl", "chstone-motion_32.stl"));
|
||||
|
||||
batchTraces(setup, tracePairs);
|
||||
|
||||
// DramSetup setup2;
|
||||
// setup2.memconfig = "memconfig.xml";
|
||||
// setup2.memspec = "MICRON_4Gb_DDR4-1866_8bit_A.xml";
|
||||
//batchSetups(tracePairs[0], { setup, setup2 });
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user