Add time measurement with chrono.
This commit is contained in:
@@ -119,6 +119,8 @@ public:
|
||||
void loadSimConfig(Configuration &config, std::string simconfigUri);
|
||||
void loadMemSpec(Configuration &config, std::string memspecUri);
|
||||
void loadTemperatureSimConfig(Configuration &config, std::string simconfigUri);
|
||||
|
||||
int64_t duration = 0;
|
||||
};
|
||||
|
||||
#endif // CONFIGURATION_H
|
||||
|
||||
@@ -59,6 +59,8 @@
|
||||
#include "powerdown/PowerDownManagerStaggered.h"
|
||||
#include "powerdown/PowerDownManagerDummy.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
using namespace tlm;
|
||||
|
||||
Controller::Controller(sc_module_name name) :
|
||||
@@ -219,6 +221,8 @@ Controller::~Controller()
|
||||
|
||||
void Controller::controllerMethod()
|
||||
{
|
||||
auto begin = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// clear command buffer
|
||||
readyCommands.clear();
|
||||
|
||||
@@ -332,6 +336,9 @@ void Controller::controllerMethod()
|
||||
|
||||
if (timeForNextTrigger != sc_max_time())
|
||||
controllerEvent.notify(timeForNextTrigger - sc_time_stamp());
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
Configuration::getInstance().duration += std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count();
|
||||
}
|
||||
|
||||
tlm_sync_enum Controller::nb_transport_fw(tlm_generic_payload &trans,
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include "../common/AddressDecoder.h"
|
||||
#include "../configuration/Configuration.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
using namespace tlm;
|
||||
|
||||
Arbiter::Arbiter(sc_module_name name, std::string pathToAddressMapping) :
|
||||
@@ -125,6 +127,8 @@ unsigned int Arbiter::transport_dbg(int /*id*/, tlm::tlm_generic_payload &trans)
|
||||
|
||||
void Arbiter::peqCallback(tlm_generic_payload &payload, const tlm_phase &phase)
|
||||
{
|
||||
auto begin = std::chrono::high_resolution_clock::now();
|
||||
|
||||
unsigned int threadId = DramExtension::getExtension(payload).getThread().ID();
|
||||
unsigned int channelId = DramExtension::getExtension(payload).getChannel().ID();
|
||||
|
||||
@@ -226,6 +230,9 @@ void Arbiter::peqCallback(tlm_generic_payload &payload, const tlm_phase &phase)
|
||||
else
|
||||
SC_REPORT_FATAL(0,
|
||||
"Payload event queue in arbiter was triggered with unknown phase");
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
Configuration::getInstance().duration += std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count();
|
||||
}
|
||||
|
||||
void Arbiter::appendDramExtension(int socketId, tlm_generic_payload &payload)
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
|
||||
#include "TracePlayer.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
using namespace tlm;
|
||||
|
||||
TracePlayer::TracePlayer(sc_module_name name, TracePlayerListener *listener) :
|
||||
@@ -79,6 +81,8 @@ tlm_sync_enum TracePlayer::nb_transport_bw(tlm_generic_payload &payload,
|
||||
void TracePlayer::peqCallback(tlm_generic_payload &payload,
|
||||
const tlm_phase &phase)
|
||||
{
|
||||
auto begin = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if (phase == BEGIN_REQ) {
|
||||
sendToTarget(payload, phase, SC_ZERO_TIME);
|
||||
transactionsSent++;
|
||||
@@ -102,6 +106,9 @@ void TracePlayer::peqCallback(tlm_generic_payload &payload,
|
||||
} else {
|
||||
SC_REPORT_FATAL(0, "TracePlayer PEQ was triggered with unknown phase");
|
||||
}
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
Configuration::getInstance().duration += std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count();
|
||||
}
|
||||
|
||||
void TracePlayer::sendToTarget(tlm_generic_payload &payload, const tlm_phase &phase, const sc_time &delay)
|
||||
|
||||
@@ -140,6 +140,17 @@ int sc_main(int argc, char **argv)
|
||||
std::chrono::duration<double> elapsed = finish - start;
|
||||
std::cout << "Simulation took " + std::to_string(elapsed.count()) + " seconds." << std::endl;
|
||||
|
||||
int64_t total = std::chrono::duration_cast<std::chrono::nanoseconds>(finish - start).count();
|
||||
int64_t duration = Configuration::getInstance().duration;
|
||||
|
||||
std::cout << "Total: " << total << std::endl;
|
||||
std::cout << "Non-Kernel: " << duration << std::endl;
|
||||
std::cout << "Kernel: " << total - duration << std::endl;
|
||||
|
||||
std::cout << "Kernel %: " << ((double)(total - duration)) / total * 100 << std::endl;
|
||||
std::cout << "Non-Kernel %: " << ((double)duration) / total * 100 << std::endl;
|
||||
|
||||
|
||||
delete dramSys;
|
||||
for (auto player : players)
|
||||
delete player;
|
||||
|
||||
Reference in New Issue
Block a user