From b85af57971d96d326eb156a4b0549717d2dc57bc Mon Sep 17 00:00:00 2001 From: tangxifan Date: Thu, 2 Jul 2020 12:39:18 -0600 Subject: [PATCH] optimizing fabric bitsteream memory footprint --- openfpga/src/fpga_bitstream/build_fabric_bitstream.cpp | 4 ++++ openfpga/src/fpga_bitstream/fabric_bitstream.cpp | 7 +++++++ openfpga/src/fpga_bitstream/fabric_bitstream.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/openfpga/src/fpga_bitstream/build_fabric_bitstream.cpp b/openfpga/src/fpga_bitstream/build_fabric_bitstream.cpp index 240f19028..417959fd5 100644 --- a/openfpga/src/fpga_bitstream/build_fabric_bitstream.cpp +++ b/openfpga/src/fpga_bitstream/build_fabric_bitstream.cpp @@ -495,6 +495,10 @@ FabricBitstream build_fabric_dependent_bitstream(const BitstreamManager& bitstre VTR_ASSERT(1 == top_block.size()); VTR_ASSERT(0 == top_module_name.compare(bitstream_manager.block_name(top_block[0]))); + /* Reserve bits before build-up */ + fabric_bitstream.reserve(bitstream_manager.bits().size()); + + /* Start build-up formally */ build_module_fabric_dependent_bitstream(config_protocol, bitstream_manager, top_block[0], module_manager, top_module, diff --git a/openfpga/src/fpga_bitstream/fabric_bitstream.cpp b/openfpga/src/fpga_bitstream/fabric_bitstream.cpp index 1e318a530..01c064549 100644 --- a/openfpga/src/fpga_bitstream/fabric_bitstream.cpp +++ b/openfpga/src/fpga_bitstream/fabric_bitstream.cpp @@ -55,6 +55,13 @@ bool FabricBitstream::bit_din(const FabricBitId& bit_id) const { /****************************************************************************** * Public Mutators ******************************************************************************/ +void FabricBitstream::reserve(const size_t& num_bits) { + bit_ids_.reserve(num_bits); + config_bit_ids_.reserve(num_bits); + bit_addresses_.reserve(num_bits); + bit_dins_.reserve(num_bits); +} + FabricBitId FabricBitstream::add_bit(const ConfigBitId& config_bit_id) { FabricBitId bit = FabricBitId(bit_ids_.size()); /* Add a new bit, and allocate associated data structures */ diff --git a/openfpga/src/fpga_bitstream/fabric_bitstream.h b/openfpga/src/fpga_bitstream/fabric_bitstream.h index 519330dae..8554ea83c 100644 --- a/openfpga/src/fpga_bitstream/fabric_bitstream.h +++ b/openfpga/src/fpga_bitstream/fabric_bitstream.h @@ -60,6 +60,9 @@ class FabricBitstream { bool bit_din(const FabricBitId& bit_id) const; public: /* Public Mutators */ + /* Reserve config bits */ + void reserve(const size_t& num_bits); + /* Add a new configuration bit to the bitstream manager */ FabricBitId add_bit(const ConfigBitId& config_bit_id);