aboutsummaryrefslogtreecommitdiffstats
path: root/fpga_interchange
diff options
context:
space:
mode:
authorMaciej Kurc <mkurc@antmicro.com>2021-07-16 15:53:00 +0200
committerMaciej Kurc <mkurc@antmicro.com>2021-07-16 15:53:00 +0200
commitccf2bb123c4c2f52142c82c3b6338856df4fbb80 (patch)
tree88f90a923f4d47a8918cddf5565a258e2534e573 /fpga_interchange
parentc95aa86a8e4fe290bdb030977b7ca40e619a0c30 (diff)
downloadnextpnr-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')
-rw-r--r--fpga_interchange/site_lut_mapping_cache.cc15
-rw-r--r--fpga_interchange/site_lut_mapping_cache.h22
2 files changed, 37 insertions, 0 deletions
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<IdString, IdString>);
+
+ 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<SiteLutMappingKey, SiteLutMappingResult> cache_;