use length instead of msb in bitstream manager for block bits to save memory

This commit is contained in:
tangxifan 2020-07-03 12:06:15 -06:00
parent 2783fda344
commit 7d9c36aae1
2 changed files with 13 additions and 11 deletions

View File

@ -78,11 +78,15 @@ std::vector<ConfigBitId> BitstreamManager::block_bits(const ConfigBlockId& block
VTR_ASSERT(true == valid_block_id(block_id));
size_t lsb = block_bit_id_lsbs_[block_id];
size_t msb = block_bit_id_msbs_[block_id];
size_t length = block_bit_lengths_[block_id];
std::vector<ConfigBitId> bits(msb - lsb + 1, ConfigBitId::INVALID());
std::vector<ConfigBitId> bits(length, ConfigBitId::INVALID());
for (size_t i = lsb; i < msb + 1; ++i) {
if (0 == length) {
return bits;
}
for (size_t i = lsb; i < lsb + length; ++i) {
bits[i - lsb] = ConfigBitId(i);
}
@ -152,7 +156,7 @@ ConfigBitId BitstreamManager::add_bit(const bool& bit_value) {
void BitstreamManager::reserve_blocks(const size_t& num_blocks) {
block_names_.reserve(num_blocks);
block_bit_id_lsbs_.reserve(num_blocks);
block_bit_id_msbs_.reserve(num_blocks);
block_bit_lengths_.reserve(num_blocks);
block_path_ids_.reserve(num_blocks);
block_input_net_ids_.reserve(num_blocks);
block_output_net_ids_.reserve(num_blocks);
@ -169,8 +173,8 @@ ConfigBlockId BitstreamManager::create_block() {
/* Add a new bit, and allocate associated data structures */
num_blocks_++;
block_names_.emplace_back();
block_bit_id_lsbs_.emplace_back(0);
block_bit_id_msbs_.emplace_back(-1);
block_bit_id_lsbs_.emplace_back(-1);
block_bit_lengths_.emplace_back(0);
block_path_ids_.push_back(-2);
block_input_net_ids_.emplace_back();
block_output_net_ids_.emplace_back();
@ -218,13 +222,11 @@ void BitstreamManager::add_block_bits(const ConfigBlockId& block,
VTR_ASSERT(true == valid_block_id(block));
/* Add the bit to the block, record anchors in bit indexing for block-level searching */
size_t lsb = num_bits_;
size_t msb = num_bits_ + block_bitstream.size() - 1;
block_bit_id_lsbs_[block] = num_bits_;
block_bit_lengths_[block] = block_bitstream.size();
for (const bool& bit : block_bitstream) {
add_bit(bit);
}
block_bit_id_lsbs_[block] = lsb;
block_bit_id_msbs_[block] = msb;
}
void BitstreamManager::add_path_id_to_block(const ConfigBlockId& block, const int& path_id) {

View File

@ -197,7 +197,7 @@ class BitstreamManager {
size_t num_blocks_;
std::unordered_set<ConfigBlockId> invalid_block_ids_;
vtr::vector<ConfigBlockId, size_t> block_bit_id_lsbs_;
vtr::vector<ConfigBlockId, size_t> block_bit_id_msbs_;
vtr::vector<ConfigBlockId, short> block_bit_lengths_;
/* Back-annotation for the bits */
/* Parent block of a bit in the Bitstream