diff --git a/DRAMSys/traceAnalyzer/CMakeLists.txt b/DRAMSys/traceAnalyzer/CMakeLists.txt index fdff7577..5f00b471 100644 --- a/DRAMSys/traceAnalyzer/CMakeLists.txt +++ b/DRAMSys/traceAnalyzer/CMakeLists.txt @@ -103,8 +103,10 @@ add_executable(TraceAnalyzer businessObjects/commentmodel.cpp businessObjects/dependencymodels.cpp + businessObjects/dramTimeDependencies/common/common.cpp businessObjects/dramTimeDependencies/dbEntries/DDR3dbphaseentry.cpp - businessObjects/dramTimeDependencies/deviceDependencies/activatewindowpoolcontroller.cpp + businessObjects/dramTimeDependencies/deviceDependencies/poolcontroller.cpp + businessObjects/dramTimeDependencies/deviceDependencies/poolcontrollermap.cpp businessObjects/dramTimeDependencies/deviceDependencies/dramtimedependenciesIF.cpp businessObjects/dramTimeDependencies/deviceDependencies/DDR3TimeDependencies.cpp businessObjects/dramTimeDependencies/configurations/configurationfactory.cpp diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/common/common.cpp b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/common/common.cpp new file mode 100644 index 00000000..856ca631 --- /dev/null +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/common/common.cpp @@ -0,0 +1,10 @@ + +#include "common.h" + +bool QStringsComparator::operator()(const QString& s1, const QString& s2) { + return s1.compare(s2) < 0; +} + +bool QStringsComparator::compareQStrings(const QString& s1, const QString& s2) { + return s1.compare(s2) < 0; +} diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/common/common.h b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/common/common.h index e0edd71d..689da366 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/common/common.h +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/common/common.h @@ -39,6 +39,7 @@ #include #include +#include #include #include #include diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/configurations/configurationIF.cpp b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/configurations/configurationIF.cpp index a2fb31e5..35c96028 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/configurations/configurationIF.cpp +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/configurations/configurationIF.cpp @@ -15,11 +15,11 @@ DependencyMap ConfigurationIF::getDependencies(std::vector& commands) c return mDeviceDeps->getDependencies(commands); } -ActivateWindowPoolController ConfigurationIF::getAWPools() const { +PoolControllerMap ConfigurationIF::getPools() const { if (!mDeviceDeps) throw std::invalid_argument("Invalid DRAMTimeDependenciesIF object in 'ConfigurationIF::getAWPools'."); - return mDeviceDeps->getAWPools(); + return mDeviceDeps->getPools(); } const QString ConfigurationIF::getDeviceName(const TraceDB& tdb) { diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/configurations/configurationIF.h b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/configurations/configurationIF.h index 26563123..38595563 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/configurations/configurationIF.h +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/configurations/configurationIF.h @@ -16,7 +16,7 @@ class ConfigurationIF { // Delegated methods const uint getClk() const; DependencyMap getDependencies(std::vector& commands) const; - ActivateWindowPoolController getAWPools() const; + PoolControllerMap getPools() const; static const QString getDeviceName(const TraceDB& tdb); diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/DDR3TimeDependencies.cpp b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/DDR3TimeDependencies.cpp index a30f6d2c..143ce25f 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/DDR3TimeDependencies.cpp +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/DDR3TimeDependencies.cpp @@ -45,7 +45,7 @@ void DDR3TimeDependencies::mInitializeValues() { burstLength = mMemspecJson["memarchitecturespec"].toObject()["burstLength"].toInt(); dataRate = mMemspecJson["memarchitecturespec"].toObject()["dataRate"].toInt(); - mPoolSizes.insert({"FAW", 4}); + mPools.insert({"FAW", {4, {"ACT"}}}); tRP = tCK * mMemspecJson["memtimingspec"].toObject()["RP"].toInt(); tRAS = tCK * mMemspecJson["memtimingspec"].toObject()["RAS"].toInt(); diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/dramtimedependenciesIF.cpp b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/dramtimedependenciesIF.cpp index 133b5655..0528d8d6 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/dramtimedependenciesIF.cpp +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/dramtimedependenciesIF.cpp @@ -69,8 +69,8 @@ DRAMTimeDependenciesIF::getDependencies(std::vector& dependencyFilter) return dependenciesMap; } -ActivateWindowPoolController DRAMTimeDependenciesIF::getAWPools() const { - return ActivateWindowPoolController(mPoolSizes); +PoolControllerMap DRAMTimeDependenciesIF::getPools() const { + return PoolControllerMap(mPools); } void DRAMTimeDependenciesIF::mFilterDependencyList(std::vector& dependencyList, const std::vector& dependencyFilter) const { @@ -172,11 +172,3 @@ uint DRAMTimeDependenciesIF::mFindVectorMaximum(const std::vectortimeValue; } - -bool QStringsComparator::operator()(const QString& s1, const QString& s2) { - return s1.compare(s2) < 0; -} - -bool QStringsComparator::compareQStrings(const QString& s1, const QString& s2) { - return s1.compare(s2) < 0; -} diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/dramtimedependenciesIF.h b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/dramtimedependenciesIF.h index 512000b9..40709f7d 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/dramtimedependenciesIF.h +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/dramtimedependenciesIF.h @@ -37,7 +37,7 @@ #include "data/tracedb.h" #include "businessObjects/dramTimeDependencies/common/common.h" -#include "activatewindowpoolcontroller.h" +#include "poolcontrollermap.h" class DRAMTimeDependenciesIF { public: @@ -48,7 +48,7 @@ public: const uint getClk() const { return tCK; } - ActivateWindowPoolController getAWPools() const; + PoolControllerMap getPools() const; protected: void mFilterDependencyList(std::vector& dependencyList, const std::vector& dependencyFilter) const; @@ -65,7 +65,7 @@ protected: uint tCK = 0; - std::map mPoolSizes; + std::map mPools; }; diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontroller.cpp b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontroller.cpp new file mode 100644 index 00000000..b86d5aef --- /dev/null +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontroller.cpp @@ -0,0 +1,47 @@ + +#include "poolcontroller.h" +#include + +PoolController::PoolController(const uint poolSize, const std::vector& dependencies) +: mDependencies(mAuxSortInput(dependencies)) +{ + mPoolSize = poolSize; + +} + +void PoolController::clear() { + mPool.clear(); + mCount = 0; + +} + +void PoolController::push(DBDependencyEntry dep) { + mPool.push_back(dep); + mCount++; + +} + +void PoolController::increment() { + mCount++; +} + +void PoolController::merge(std::vector& depEntries) { + if(mCount >= mPoolSize) { + depEntries.insert( depEntries.end(), mPool.begin(), mPool.end() ); + } +} + +bool PoolController::isDependency(const QString& phaseName) { + return std::binary_search( + mDependencies.begin(), + mDependencies.end(), + phaseName, + QStringsComparator::compareQStrings + ); +} + +std::vector PoolController::mAuxSortInput(std::vector vec) { + std::sort(vec.begin(), vec.end(), QStringsComparator::compareQStrings); + + return vec; +} \ No newline at end of file diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontroller.h b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontroller.h new file mode 100644 index 00000000..7a6cf713 --- /dev/null +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontroller.h @@ -0,0 +1,26 @@ + +#pragma once + +#include "businessObjects/dramTimeDependencies/common/common.h" + +class PoolController { +public: + PoolController(const uint poolSize, const std::vector& dependencies); + ~PoolController() = default; + + void clear(); + void push(DBDependencyEntry); + void increment(); + void merge(std::vector& depEntries); + + bool isDependency(const QString& phaseName); + +protected: + const std::vector mDependencies; + std::vector mPool; + uint mCount = 0; + uint mPoolSize = 0; + +protected: + static std::vector mAuxSortInput(std::vector vec); +}; diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/activatewindowpoolcontroller.cpp b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontrollermap.cpp similarity index 67% rename from DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/activatewindowpoolcontroller.cpp rename to DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontrollermap.cpp index e8961b4a..a16dd6c6 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/activatewindowpoolcontroller.cpp +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontrollermap.cpp @@ -33,52 +33,53 @@ * Iron Prando da Silva */ -#include "activatewindowpoolcontroller.h" - -ActivateWindowPoolController::ActivateWindowPoolController(const std::map& poolSizes) { - mPoolSizes = poolSizes; - - for (const auto& p : poolSizes) { - mPools.insert({p.first, {}}); - mCounts.insert({p.first, 0}); - mPools[p.first].reserve(32); - } +#include "poolcontrollermap.h" +PoolControllerMap::PoolControllerMap(const std::map& pools) { + mPools = pools; } -void ActivateWindowPoolController::clear() { +void PoolControllerMap::clear() { for (auto& p : mPools) { p.second.clear(); - mCounts[p.first] = 0; } } -void ActivateWindowPoolController::push(const QString& poolName, DBDependencyEntry dep) { +void PoolControllerMap::push(const QString& poolName, DBDependencyEntry dep) { auto pool = mPools.find(poolName); if (pool != mPools.end()) { - pool->second.push_back(dep); - mCounts[poolName]++; + pool->second.push(dep); } else { // TODO throw? } } -void ActivateWindowPoolController::increment(const QString& poolName) { +void PoolControllerMap::increment(const QString& poolName) { auto pool = mPools.find(poolName); if (pool != mPools.end()) { - mCounts[poolName]++; + pool->second.increment(); } else { // TODO throw? } } -void ActivateWindowPoolController::merge(std::vector& depEntries) { - for (const auto& p : mPools) { - if(mCounts[p.first] >= mPoolSizes[p.first]) { - depEntries.insert( depEntries.end(), p.second.begin(), p.second.end() ); - } +void PoolControllerMap::merge(std::vector& depEntries) { + for (auto& p : mPools) { + p.second.merge(depEntries); + } +} + +bool PoolControllerMap::isDependency(const QString& poolName, const QString& phaseName) { + auto pool = mPools.find(poolName); + if (pool != mPools.end()) { + return pool->second.isDependency(phaseName); + + } else { + // TODO throw? + return false; + } } diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/activatewindowpoolcontroller.h b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontrollermap.h similarity index 80% rename from DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/activatewindowpoolcontroller.h rename to DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontrollermap.h index 1c2aced7..0de8d5f9 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/activatewindowpoolcontroller.h +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/deviceDependencies/poolcontrollermap.h @@ -35,21 +35,21 @@ #pragma once -#include "businessObjects/dramTimeDependencies/common/common.h" +#include "poolcontroller.h" -class ActivateWindowPoolController { +class PoolControllerMap { public: - ActivateWindowPoolController(const std::map& poolSizes); - ~ActivateWindowPoolController() = default; + PoolControllerMap(const std::map& pools); + ~PoolControllerMap() = default; void clear(); void push(const QString& poolName, DBDependencyEntry); void increment(const QString& poolName); void merge(std::vector& depEntries); + bool isDependency(const QString& poolName, const QString& phaseName); + protected: - std::map, QStringsComparator> mPools; - std::map mCounts; - std::map mPoolSizes; + std::map mPools; }; diff --git a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/phasedependenciestracker.cpp b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/phasedependenciestracker.cpp index 6f99fab5..2590518b 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/phasedependenciestracker.cpp +++ b/DRAMSys/traceAnalyzer/businessObjects/dramTimeDependencies/phasedependenciestracker.cpp @@ -185,7 +185,7 @@ PhaseDependenciesTracker::mCalculateDependencies(const std::shared_ptrgetDependencies(commands); // Tries to find all timing dependencies for each phase on the trace - ActivateWindowPoolController poolController = deviceConfig->getAWPools(); + PoolControllerMap poolController = deviceConfig->getPools(); for (size_t i = 1; i < phases.size(); i++) { // NAW dependencies variables reset poolController.clear(); @@ -220,12 +220,10 @@ PhaseDependenciesTracker::mCalculateDependencies(const std::shared_ptrphaseName)) { - if (otherPhase->phaseName == "ACT") { + if (poolController.isDependency(poolName, otherPhase->phaseName)) { if (timeDiff == dep.timeValue) { - // Captures only the first (exactly matching time) ACT in - // the ACT window as a dependency + // Captures only the first (exactly matching time) phase in + // the pool window as a dependency poolController.push(poolName, DBDependencyEntry{ phase->id, phase->phaseName, @@ -259,6 +257,7 @@ PhaseDependenciesTracker::mCalculateDependencies(const std::shared_ptrgetClk()) { entries.emplace_back(DBDependencyEntry{