diff options
author | David Shah <dave@ds0.me> | 2021-02-05 11:32:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 11:32:09 +0000 |
commit | b0f9b7834e4cb035d1fd60f0fa1948c0fdfa233c (patch) | |
tree | d8b70c19580030a1ee28431b5d2287a0ae1690da /common/archcheck.cc | |
parent | 40d026e6fc5ab94c732682c62a6803bd3140953e (diff) | |
parent | 450bfae86cc807e4aec8d3b725169fd044212079 (diff) | |
download | nextpnr-b0f9b7834e4cb035d1fd60f0fa1948c0fdfa233c.tar.gz nextpnr-b0f9b7834e4cb035d1fd60f0fa1948c0fdfa233c.tar.bz2 nextpnr-b0f9b7834e4cb035d1fd60f0fa1948c0fdfa233c.zip |
Merge pull request #570 from litghost/make_id_string_list_explicit
Mark IdString and IdStringList single argument constructors explicit.
Diffstat (limited to 'common/archcheck.cc')
-rw-r--r-- | common/archcheck.cc | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/common/archcheck.cc b/common/archcheck.cc index f950aa1a..6702032e 100644 --- a/common/archcheck.cc +++ b/common/archcheck.cc @@ -135,8 +135,10 @@ void archcheck_locs(const Context *ctx) // // This allows a fast way to check getPipsDownhill/getPipsUphill from getPips, // without balloning memory usage. -struct LruWireCacheMap { - LruWireCacheMap(const Context *ctx, size_t cache_size) : ctx(ctx), cache_size(cache_size) { +struct LruWireCacheMap +{ + LruWireCacheMap(const Context *ctx, size_t cache_size) : ctx(ctx), cache_size(cache_size) + { cache_hits = 0; cache_misses = 0; cache_evictions = 0; @@ -159,7 +161,8 @@ struct LruWireCacheMap { std::unordered_map<PipId, WireId> pips_downhill; std::unordered_map<PipId, WireId> pips_uphill; - void removeWireFromCache(WireId wire_to_remove) { + void removeWireFromCache(WireId wire_to_remove) + { for (PipId pip : ctx->getPipsDownhill(wire_to_remove)) { log_assert(pips_downhill.erase(pip) == 1); } @@ -169,7 +172,8 @@ struct LruWireCacheMap { } } - void addWireToCache(WireId wire) { + void addWireToCache(WireId wire) + { for (PipId pip : ctx->getPipsDownhill(wire)) { auto result = pips_downhill.emplace(pip, wire); log_assert(result.second); @@ -181,12 +185,13 @@ struct LruWireCacheMap { } } - void populateCache(WireId wire) { + void populateCache(WireId wire) + { // Put this wire at the end of last_access_list. auto iter = last_access_list.emplace(last_access_list.end(), wire); last_access_map.emplace(wire, iter); - if(last_access_list.size() > cache_size) { + if (last_access_list.size() > cache_size) { // Cache is full, remove front of last_access_list. cache_evictions += 1; WireId wire_to_remove = last_access_list.front(); @@ -202,9 +207,10 @@ struct LruWireCacheMap { // Determine if wire is in the cache. If wire is not in the cache, // adds the wire to the cache, and potentially evicts the oldest wire if // cache is now full. - void checkCache(WireId wire) { + void checkCache(WireId wire) + { auto iter = last_access_map.find(wire); - if(iter == last_access_map.end()) { + if (iter == last_access_map.end()) { cache_misses += 1; populateCache(wire); } else { @@ -215,18 +221,21 @@ struct LruWireCacheMap { } // Returns true if pip is uphill of wire (e.g. pip in getPipsUphill(wire)). - bool isPipUphill(PipId pip, WireId wire) { + bool isPipUphill(PipId pip, WireId wire) + { checkCache(wire); return pips_uphill.at(pip) == wire; } // Returns true if pip is downhill of wire (e.g. pip in getPipsDownhill(wire)). - bool isPipDownhill(PipId pip, WireId wire) { + bool isPipDownhill(PipId pip, WireId wire) + { checkCache(wire); return pips_downhill.at(pip) == wire; } - void cache_info() const { + void cache_info() const + { log_info("Cache hits: %zu\n", cache_hits); log_info("Cache misses: %zu\n", cache_misses); log_info("Cache evictions: %zu\n", cache_evictions); @@ -285,7 +294,7 @@ void archcheck_conn(const Context *ctx) // gains by avoiding the full pip -> wire map, and still preserves a fast // pip -> wire, assuming that pips are returned from getPips with some // chip locality. - LruWireCacheMap pip_cache(ctx, /*cache_size=*/64*1024); + LruWireCacheMap pip_cache(ctx, /*cache_size=*/64 * 1024); log_info("Checking all PIPs...\n"); for (PipId pip : ctx->getPips()) { WireId src_wire = ctx->getPipSrcWire(pip); |