diff options
author | Maciej Kurc <mkurc@antmicro.com> | 2021-07-16 15:53:00 +0200 |
---|---|---|
committer | Maciej Kurc <mkurc@antmicro.com> | 2021-07-16 15:53:00 +0200 |
commit | ccf2bb123c4c2f52142c82c3b6338856df4fbb80 (patch) | |
tree | 88f90a923f4d47a8918cddf5565a258e2534e573 /fpga_interchange/site_lut_mapping_cache.h | |
parent | c95aa86a8e4fe290bdb030977b7ca40e619a0c30 (diff) | |
download | nextpnr-ccf2bb123c4c2f52142c82c3b6338856df4fbb80.tar.gz nextpnr-ccf2bb123c4c2f52142c82c3b6338856df4fbb80.tar.bz2 nextpnr-ccf2bb123c4c2f52142c82c3b6338856df4fbb80.zip |
Added computing and reporting LUT mapping cache size
Signed-off-by: Maciej Kurc <mkurc@antmicro.com>
Diffstat (limited to 'fpga_interchange/site_lut_mapping_cache.h')
-rw-r--r-- | fpga_interchange/site_lut_mapping_cache.h | 22 |
1 files changed, 22 insertions, 0 deletions
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<SiteLutMappingKey, SiteLutMappingResult> cache_; |