From ccf2bb123c4c2f52142c82c3b6338856df4fbb80 Mon Sep 17 00:00:00 2001 From: Maciej Kurc Date: Fri, 16 Jul 2021 15:53:00 +0200 Subject: Added computing and reporting LUT mapping cache size Signed-off-by: Maciej Kurc --- fpga_interchange/site_lut_mapping_cache.cc | 15 +++++++++++++++ fpga_interchange/site_lut_mapping_cache.h | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/fpga_interchange/site_lut_mapping_cache.cc b/fpga_interchange/site_lut_mapping_cache.cc index 86f39f2c..7edb0818 100644 --- a/fpga_interchange/site_lut_mapping_cache.cc +++ b/fpga_interchange/site_lut_mapping_cache.cc @@ -149,6 +149,21 @@ bool SiteLutMappingResult::apply (const SiteInformation& siteInfo) { return true; } +size_t SiteLutMappingResult::getSizeInBytes () const { + + size_t size = 0; + + size += sizeof(SiteLutMappingResult); + size += blockedWires.size() * sizeof(std::pair); + + for (const auto& cell : cells) { + size += sizeof(Cell); + size += cell.belPins.size() * sizeof(decltype(cell.belPins)::value_type); + } + + return size; +} + // ============================================================================ void SiteLutMappingCache::add (const SiteLutMappingKey& key, diff --git a/fpga_interchange/site_lut_mapping_cache.h b/fpga_interchange/site_lut_mapping_cache.h index 42a10ba7..b4c074c7 100644 --- a/fpga_interchange/site_lut_mapping_cache.h +++ b/fpga_interchange/site_lut_mapping_cache.h @@ -65,6 +65,10 @@ struct SiteLutMappingKey { static SiteLutMappingKey create (const SiteInformation& siteInfo); + size_t getSizeInBytes () const { + return sizeof(SiteLutMappingKey); + } + void computeHash () { hash_ = mkhash(0, tileType); hash_ = mkhash(hash_, siteType); @@ -128,6 +132,9 @@ struct SiteLutMappingResult { // Applies the mapping result to the site bool apply (const SiteInformation& siteInfo); + + // Returns size in bytes + size_t getSizeInBytes () const; }; // Site LUT mapping cache object @@ -144,6 +151,21 @@ public: return (float)numMisses / (float)(numHits + numMisses); } + size_t getCount () const { + return cache_.size(); + } + + size_t getSizeMB () const { + size_t size = 0; + for (const auto& it : cache_) { + size += it.first.getSizeInBytes(); + size += it.second.getSizeInBytes(); + } + + const size_t MB = 1024L * 1024L; + return (size + MB - 1) / MB; // Round up to megabytes + } + private: dict cache_; -- cgit v1.2.3