Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preloading clean #1810

Merged
merged 56 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
48a386c
add read and write uniqueblocks commands
treelin611 Aug 2, 2024
7f426d5
add commands
treelin611 Aug 2, 2024
5ac19ea
read unique blocks io
treelin611 Aug 5, 2024
c726744
add sb unique modules
treelin611 Aug 5, 2024
72a90a4
add preload function
treelin611 Aug 6, 2024
9c67950
preload functions
treelin611 Aug 7, 2024
e45619b
write sb
treelin611 Aug 8, 2024
755959a
add cb cx write function
treelin611 Aug 8, 2024
a785a57
small bug mod
treelin611 Aug 19, 2024
699131a
full flow with bugs
treelin611 Aug 19, 2024
913fdc0
debuged
treelin611 Aug 23, 2024
968824c
build unique blocks final version
treelin611 Aug 26, 2024
9c061e0
Merge branch 'preloading' of github.com:lnis-uofu/OpenFPGA
treelin611 Aug 26, 2024
88fa9f8
add test case
treelin611 Aug 26, 2024
701a7a5
add test case
treelin611 Aug 26, 2024
5153cee
mod reg_test script
treelin611 Aug 26, 2024
67c7c2d
mod comments
treelin611 Aug 26, 2024
9e283f3
remove redundant include
treelin611 Aug 26, 2024
3c28f84
build bug
treelin611 Aug 27, 2024
1b0fcae
reformat code
treelin611 Aug 27, 2024
1b34f4f
Merge branch 'master' into preloading_clean
tangxifan Aug 27, 2024
cde4c8d
mod according to code review
treelin611 Aug 28, 2024
d4028b4
modification no build warning now
treelin611 Aug 28, 2024
0a14b2f
pass device_rr_gsb instead of openfpga_ctx
treelin611 Aug 28, 2024
df05c90
make the read block coord and read instance coords clearer
treelin611 Aug 28, 2024
352c9b4
add cmd dependency
treelin611 Aug 28, 2024
a23860a
reformat code
treelin611 Aug 28, 2024
8372eea
add preload flag to device_rr_gsb and revert change to build fabric
treelin611 Aug 28, 2024
d30a208
Merge branch 'master' into preloading_clean
tangxifan Aug 28, 2024
643e3a2
fix build bug
treelin611 Aug 29, 2024
9e49168
change file location
treelin611 Aug 30, 2024
cb003f8
mod prelod flag
treelin611 Aug 30, 2024
adeb9ba
fix typo
treelin611 Aug 30, 2024
acce640
add test case
treelin611 Aug 30, 2024
1d35a17
delete redundant file
treelin611 Aug 30, 2024
94309c2
change to reference
treelin611 Aug 30, 2024
a2b290c
mod typo
treelin611 Aug 30, 2024
a70582c
preload document copied
treelin611 Sep 4, 2024
263eb6b
Update unique_blocks.rst
treelin611 Sep 4, 2024
73d5e64
Merge branch 'preloading_doc' into preloading_clean
treelin611 Sep 5, 2024
af7201d
fix is_compressed_ tag
treelin611 Sep 9, 2024
41d0eb7
modification on device_rr_gsb
treelin611 Sep 9, 2024
d15025d
add a task case to ease the use of compress_routing option
treelin611 Sep 9, 2024
f1547ba
fix build error
treelin611 Sep 9, 2024
ae6a8cb
fix bug
treelin611 Sep 10, 2024
77b1880
Merge branch 'master' into preloading_clean
treelin611 Sep 11, 2024
b2a5bd8
fix merge error
treelin611 Sep 11, 2024
55611db
rewrite write_xml function
treelin611 Sep 11, 2024
172260e
modified index.rst
treelin611 Sep 11, 2024
27db6d2
modified unique_block.rst
treelin611 Sep 11, 2024
5ccad72
add comments
treelin611 Sep 12, 2024
41d3819
reformat code
treelin611 Sep 12, 2024
e6c43ec
add command doc
treelin611 Sep 12, 2024
52f5cf0
add link to command doc
treelin611 Sep 12, 2024
423e152
add link to command doc, valid now
treelin611 Sep 12, 2024
b5452b7
Merge branch 'master' into preloading_clean
treelin611 Sep 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions docs/source/manual/file_formats/unique_blocks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.. _file_formats_unique_blocks:
treelin611 marked this conversation as resolved.
Show resolved Hide resolved

treelin611 marked this conversation as resolved.
Show resolved Hide resolved
Unique Blocks (.xml)
~~~~~~~~~~~~~~~~~

A unique blocks file is formatted in XML. The unique blocks can be of type ``cbx``, ``cby`` or ``sb``. As illustrated by the XML code below, the file includes the type and coordinates of these unique blocks, as well as the coordinates of their corresponding instances.

Configurable Block
^^^^^^^^^^^^^^^^^^^
treelin611 marked this conversation as resolved.
Show resolved Hide resolved

Unique blocks can be applied to various blocks, each of which can be of type ``cbx``, ``cby`` or ``sb``, and may have different coordinates.

.. option:: <block type="<string>" x="<string>" y="<string>"/>

For each block, a set of keys can be defined. For unique blocks, both keys and instances can be specified. However, if a unique block does not have an instance, only keys are permitted.

- ``type`` specifies the type of the unique block in the FPGA fabric. Valid values for ``type`` are ``cbx``, ``cby`` or ``sb``.

- ``x`` represents the x-coordinate of the unique block.

- ``y`` represents the y-coordinate of the unique block.

Configurable Instance
^^^^^^^^^^^^^^^^^^^

A specific unique block can have multiple instances, where each instance is a mirrored version of the unique block. Each instance shares the same type as its parent block and includes information about its coordinates.

.. option:: <instance x="<string>" y="<string>"/>

- ``x`` specifies the x-coordinate of the instance.

- ``y`` specifies the y-coordinate of the instance.


The following content provides an example of a unique block file:

.. code-block:: xml

<unique_blocks>
<block type="sb" x="0" y="0">
</block>
<block type="sb" x="0" y="1">
</block>
<block type="sb" x="1" y="0">
</block>
<block type="sb" x="1" y="1">
</block>
<block type="cbx" x="1" y="0">
<instance x="0" y="0"/>
<instance x="0" y="1"/>
</block>
<block type="cbx" x="1" y="1">
</block>
<block type="cby" x="0" y="1">
<instance x="0" y="0"/>
<instance x="1" y="0"/>
</block>
<block type="cby" x="1" y="1">
</block>
</unique_blocks>


174 changes: 174 additions & 0 deletions openfpga/src/annotation/device_rr_gsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ size_t DeviceRRGSB::get_num_cb_unique_module(const t_rr_type& cb_type) const {
}
}

void DeviceRRGSB::init_is_dirty_flag() { is_dirty_ = false; }
void DeviceRRGSB::set_is_dirty_flag(const bool flag) { is_dirty_ = flag; }
treelin611 marked this conversation as resolved.
Show resolved Hide resolved
bool DeviceRRGSB::get_is_dirty_flag() const { return is_dirty_; }
/* Identify if a GSB actually exists at a location */
bool DeviceRRGSB::is_gsb_exist(const RRGraphView& rr_graph,
const vtr::Point<size_t> coord) const {
Expand Down Expand Up @@ -171,6 +174,18 @@ void DeviceRRGSB::reserve(const vtr::Point<size_t>& coordinate) {
cby_unique_module_id_[x].resize(coordinate.y());
}
}
void DeviceRRGSB::reserve_unique_modules(const vtr::Point<size_t>& coordinate) {
sb_unique_module_id_.resize(coordinate.x());
cbx_unique_module_id_.resize(coordinate.x());
cby_unique_module_id_.resize(coordinate.x());

for (size_t x = 0; x < coordinate.x(); ++x) {
sb_unique_module_id_[x].resize(coordinate.y());

cbx_unique_module_id_[x].resize(coordinate.y());
cby_unique_module_id_[x].resize(coordinate.y());
}
}

/* Resize rr_switch_block array is needed*/
void DeviceRRGSB::resize_upon_need(const vtr::Point<size_t>& coordinate) {
Expand Down Expand Up @@ -348,6 +363,7 @@ void DeviceRRGSB::build_unique_module(const RRGraphView& rr_graph) {
build_cb_unique_module(rr_graph, CHANY);

build_gsb_unique_module();
set_is_dirty_flag(true);
}

void DeviceRRGSB::add_gsb_unique_module(const vtr::Point<size_t>& coordinate) {
Expand Down Expand Up @@ -408,6 +424,20 @@ void DeviceRRGSB::clear() {

clear_sb_unique_module();
clear_sb_unique_module_id();
init_is_dirty_flag();
}

void DeviceRRGSB::clear_unique_modules() {
/* clean unique module lists */
clear_cb_unique_module(CHANX);
clear_cb_unique_module_id(CHANX);

clear_cb_unique_module(CHANY);
clear_cb_unique_module_id(CHANY);

clear_sb_unique_module();
clear_sb_unique_module_id();
init_is_dirty_flag();
}

void DeviceRRGSB::clear_gsb() {
Expand Down Expand Up @@ -551,4 +581,148 @@ size_t DeviceRRGSB::get_cb_unique_module_index(
return cb_unique_module_id;
}

void DeviceRRGSB::preload_unique_cbx_module(
const vtr::Point<size_t>& block_coordinate,
const std::vector<vtr::Point<size_t>>& instance_coords) {
/*check whether the preloaded value exceeds the limit */
size_t limit_x = cbx_unique_module_id_.size();
size_t limit_y = cbx_unique_module_id_[0].size();
VTR_ASSERT(block_coordinate.x() < limit_x);
VTR_ASSERT(block_coordinate.y() < limit_y);
add_cb_unique_module(CHANX, block_coordinate);
/* preload the unique block */
set_cb_unique_module_id(CHANX, block_coordinate,
get_num_cb_unique_module(CHANX) - 1);

/* preload the instances of the unique block. Instance will have the same id
* as the unique block */
for (auto instance_location : instance_coords) {
VTR_ASSERT(instance_location.x() < limit_x);
VTR_ASSERT(instance_location.y() < limit_y);
set_cb_unique_module_id(
CHANX, instance_location,
cbx_unique_module_id_[block_coordinate.x()][block_coordinate.y()]);
}
}

void DeviceRRGSB::preload_unique_cby_module(
const vtr::Point<size_t>& block_coordinate,
const std::vector<vtr::Point<size_t>>& instance_coords) {
/*check whether the preloaded value exceeds the limit */
size_t limit_x = cby_unique_module_id_.size();
size_t limit_y = cby_unique_module_id_[0].size();

VTR_ASSERT(block_coordinate.x() < limit_x);
VTR_ASSERT(block_coordinate.y() < limit_y);
add_cb_unique_module(CHANY, block_coordinate);
/* preload the unique block */
set_cb_unique_module_id(CHANY, block_coordinate,
get_num_cb_unique_module(CHANY) - 1);

/* preload the instances of the unique block. Instance will have the same id
* as the unique block */
for (auto instance_location : instance_coords) {
VTR_ASSERT(instance_location.x() < limit_x);
VTR_ASSERT(instance_location.y() < limit_y);
set_cb_unique_module_id(
CHANY, instance_location,
cby_unique_module_id_[block_coordinate.x()][block_coordinate.y()]);
}
}

void DeviceRRGSB::preload_unique_sb_module(
const vtr::Point<size_t>& block_coordinate,
const std::vector<vtr::Point<size_t>>& instance_coords) {
/*check whether the preloaded value exceeds the limit */
VTR_ASSERT(block_coordinate.x() < sb_unique_module_id_.size());
VTR_ASSERT(block_coordinate.y() < sb_unique_module_id_[0].size());
sb_unique_module_.push_back(block_coordinate);
/* Record the id of unique module */
sb_unique_module_id_[block_coordinate.x()][block_coordinate.y()] =
sb_unique_module_.size() - 1;

/* each mirror instance of the unique module will have the same module id as
* the unique module */
for (auto instance_location : instance_coords) {
VTR_ASSERT(instance_location.x() < sb_unique_module_id_.size());
VTR_ASSERT(instance_location.y() < sb_unique_module_id_[0].size());
sb_unique_module_id_[instance_location.x()][instance_location.y()] =
sb_unique_module_id_[block_coordinate.x()][block_coordinate.y()];
}
}

/*The following four functions will allow us to get
The map between (id,mirror instance coord), (id, unique block coord)
As the unique block and its mirror instances share the same id, we can get the
map between (unique block coord, mirror instance coord)
*/
void DeviceRRGSB::get_id_unique_sb_block_map(
std::map<int, vtr::Point<size_t>>& id_unique_block_map) const {
treelin611 marked this conversation as resolved.
Show resolved Hide resolved
for (size_t id = 0; id < get_num_sb_unique_module(); ++id) {
const auto& unique_block_coord = sb_unique_module_[id];
auto unique_module_id =
sb_unique_module_id_[unique_block_coord.x()][unique_block_coord.y()];
id_unique_block_map[unique_module_id] = unique_block_coord;
}
}

void DeviceRRGSB::get_id_sb_instance_map(
std::map<int, std::vector<vtr::Point<size_t>>>& id_instance_map) const {
for (size_t location_x = 0; location_x < sb_unique_module_id_.size();
++location_x) {
for (size_t location_y = 0; location_y < sb_unique_module_id_[0].size();
++location_y) {
auto unique_module_id = sb_unique_module_id_[location_x][location_y];
vtr::Point<size_t> instance_coord(location_x, location_y);
id_instance_map[unique_module_id].push_back(instance_coord);
}
}
}

void DeviceRRGSB::get_id_unique_cbx_block_map(
std::map<int, vtr::Point<size_t>>& id_unique_block_map) const {
for (size_t id = 0; id < get_num_cb_unique_module(CHANX); ++id) {
const auto& unique_block_coord = cbx_unique_module_[id];
auto unique_module_id =
cbx_unique_module_id_[unique_block_coord.x()][unique_block_coord.y()];
id_unique_block_map[unique_module_id] = unique_block_coord;
}
}

void DeviceRRGSB::get_id_cbx_instance_map(
std::map<int, std::vector<vtr::Point<size_t>>>& id_instance_map) const {
for (size_t location_x = 0; location_x < cbx_unique_module_id_.size();
++location_x) {
for (size_t location_y = 0; location_y < cbx_unique_module_id_[0].size();
++location_y) {
auto unique_module_id = cbx_unique_module_id_[location_x][location_y];
vtr::Point<size_t> instance_coord(location_x, location_y);
id_instance_map[unique_module_id].push_back(instance_coord);
}
}
}

void DeviceRRGSB::get_id_unique_cby_block_map(
std::map<int, vtr::Point<size_t>>& id_unique_block_map) const {
for (size_t id = 0; id < get_num_cb_unique_module(CHANY); ++id) {
const auto& unique_block_coord = cby_unique_module_[id];
auto unique_module_id =
cby_unique_module_id_[unique_block_coord.x()][unique_block_coord.y()];
id_unique_block_map[unique_module_id] = unique_block_coord;
}
}

void DeviceRRGSB::get_id_cby_instance_map(
std::map<int, std::vector<vtr::Point<size_t>>>& id_instance_map) const {
for (size_t location_x = 0; location_x < cby_unique_module_id_.size();
++location_x) {
for (size_t location_y = 0; location_y < cby_unique_module_id_[0].size();
++location_y) {
auto unique_module_id = cby_unique_module_id_[location_x][location_y];
vtr::Point<size_t> instance_coord(location_x, location_y);
id_instance_map[unique_module_id].push_back(instance_coord);
}
}
}

} /* End namespace openfpga*/
42 changes: 35 additions & 7 deletions openfpga/src/annotation/device_rr_gsb.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ class DeviceRRGSB {
const vtr::Point<size_t>& coordinate) const;

public: /* Mutators */
void set_is_dirty_flag(const bool flag);
bool get_is_dirty_flag() const;
treelin611 marked this conversation as resolved.
Show resolved Hide resolved
void build_gsb_unique_module(); /* Add a switch block to the array, which will
automatically identify and update the lists
of unique mirrors and rotatable mirrors */
void reserve(
const vtr::Point<size_t>& coordinate); /* Pre-allocate the rr_switch_block
array that the device requires */
void reserve_sb_unique_submodule_id(
void reserve_unique_modules(
const vtr::Point<size_t>&
coordinate); /* Pre-allocate the rr_sb_unique_module_id matrix that the
device requires */
Expand All @@ -95,9 +100,33 @@ class DeviceRRGSB {
automatically identify and update the lists
of unique mirrors and rotatable mirrors */
void clear(); /* clean the content */
private: /* Internal cleaners */
void clear_gsb(); /* clean the content */
void preload_unique_cbx_module(
const vtr::Point<size_t>& block_coordinate,
const std::vector<vtr::Point<size_t>>& instance_coords);
void preload_unique_cby_module(
const vtr::Point<size_t>& block_coordinate,
const std::vector<vtr::Point<size_t>>& instance_coords);
void preload_unique_sb_module(
const vtr::Point<size_t>& block_coordinate,
const std::vector<vtr::Point<size_t>>& instance_coords);
void clear_unique_modules();
void get_id_sb_instance_map(
std::map<int, std::vector<vtr::Point<size_t>>>& id_instance_map) const;
void get_id_unique_sb_block_map(
std::map<int, vtr::Point<size_t>>& id_unique_block_map) const;
void get_id_cbx_instance_map(
std::map<int, std::vector<vtr::Point<size_t>>>& id_instance_map) const;
void get_id_unique_cbx_block_map(
std::map<int, vtr::Point<size_t>>& id_unique_block_map) const;
void get_id_cby_instance_map(
std::map<int, std::vector<vtr::Point<size_t>>>& id_instance_map) const;
void get_id_unique_cby_block_map(
std::map<int, vtr::Point<size_t>>& id_unique_block_map) const;

private: /* Internal cleaners */
void clear_gsb(); /* clean the content */
void clear_cb_unique_module(const t_rr_type& cb_type); /* clean the content */
void init_is_dirty_flag();
treelin611 marked this conversation as resolved.
Show resolved Hide resolved
void clear_cb_unique_module_id(
const t_rr_type& cb_type); /* clean the content */
void clear_sb_unique_module(); /* clean the content */
Expand Down Expand Up @@ -133,11 +162,10 @@ class DeviceRRGSB {
const t_rr_type&
cb_type); /* Add a switch block to the array, which will automatically
identify and update the lists of unique side module */
void build_gsb_unique_module(); /* Add a switch block to the array, which will
automatically identify and update the lists
of unique mirrors and rotatable mirrors */
private: /* Internal Data */

private: /* Internal Data */
std::vector<std::vector<RRGSB>> rr_gsb_;
bool is_dirty_ = false; // is_valid
treelin611 marked this conversation as resolved.
Show resolved Hide resolved

std::vector<std::vector<size_t>>
gsb_unique_module_id_; /* A map from rr_gsb to its unique mirror */
Expand Down
Loading
Loading