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

🎨 Improved usability of the on-the-fly SiDB gate library #634

Open
wants to merge 51 commits into
base: main
Choose a base branch
from

Conversation

Drewniok
Copy link
Collaborator

Description

This PR improves the usability of the on-the-fly SiDB gate library. Additionally, several bugs have been fixed.

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have added a changelog entry.
  • I have created/adjusted the Python bindings for any new or updated functionality.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

@Drewniok Drewniok added the enhancement New feature or request label Jan 15, 2025
@Drewniok Drewniok self-assigned this Jan 15, 2025
Drewniok and others added 5 commits January 15, 2025 17:12
# Conflicts:
#	bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp
Signed-off-by: GitHub Actions <actions@github.com>
Drewniok and others added 3 commits January 15, 2025 17:23
Signed-off-by: GitHub Actions <actions@github.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Copy link

codecov bot commented Jan 18, 2025

Codecov Report

Attention: Patch coverage is 73.44111% with 115 lines in your changes missing coverage. Please review.

Project coverage is 97.80%. Comparing base (bbb9b0e) to head (e1b3bed).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...iction/technology/sidb_on_the_fly_gate_library.hpp 25.32% 115 Missing ⚠️

❌ Your patch check has failed because the patch coverage (73.44%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #634      +/-   ##
==========================================
- Coverage   98.14%   97.80%   -0.35%     
==========================================
  Files         245      247       +2     
  Lines       37235    37844     +609     
  Branches     1805     1866      +61     
==========================================
+ Hits        36546    37015     +469     
- Misses        688      829     +141     
+ Partials        1        0       -1     
Files with missing lines Coverage Δ
.../algorithms/physical_design/apply_gate_library.hpp 100.00% <100.00%> (ø)
...n/algorithms/physical_design/design_sidb_gates.hpp 98.79% <100.00%> (+0.40%) ⬆️
include/fiction/layouts/cell_level_layout.hpp 100.00% <100.00%> (ø)
include/fiction/technology/fcn_gate_library.hpp 88.63% <ø> (+0.54%) ⬆️
...clude/fiction/technology/sidb_bestagon_library.hpp 95.45% <100.00%> (ø)
include/fiction/technology/sidb_defect_surface.hpp 100.00% <100.00%> (ø)
.../algorithms/physical_design/apply_gate_library.cpp 100.00% <100.00%> (ø)
...t/algorithms/physical_design/design_sidb_gates.cpp 100.00% <100.00%> (ø)
test/technology/sidb_defect_surface.cpp 100.00% <100.00%> (ø)
...iction/technology/sidb_on_the_fly_gate_library.hpp 52.18% <25.32%> (ø)

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddbc2fa...e1b3bed. Read the comment docs.

@@ -146,7 +166,7 @@
* @return Bestagon gate representation of `t` including mirroring.
*/
template <typename GateLyt, typename CellLyt, typename Params>
static fcn_gate set_up_gate(const GateLyt& lyt, const tile<GateLyt>& t, const Params& parameters = Params{})
static fcn_gate set_up_gate(const GateLyt& lyt, const tile<GateLyt>& t, const Params& params)

Check warning

Code scanning / CodeQL

Poorly documented large function Warning

Poorly documented function: fewer than 2% comments for a function of 357 lines.
@Drewniok
Copy link
Collaborator Author

I know the coverage is still quite low, @marcelwa. Would it be possible to get some feedback on the structure before I increase the coverage? I would love to hear your feedback as I am curious to hear if there is a better way for the implementation. Thank you!

@Drewniok Drewniok requested a review from marcelwa January 27, 2025 11:13
Copy link
Collaborator

@marcelwa marcelwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for giving me the opportunity to review this PR early. I have a few suggestions here and there. Also, some questions remained from simply reading the code. Would be cool if we could discuss 🙂

@@ -258,7 +254,7 @@ template <typename CellLyt, typename GateLibrary, typename GateLyt>
* @return A cell-level layout that implements `lyt`'s gate types with building blocks defined in `GateLibrary`.
*/
template <typename CellLyt, typename GateLibrary, typename GateLyt, typename Params>
[[nodiscard]] CellLyt apply_parameterized_gate_library(const GateLyt& lyt, const Params& params)
CellLyt apply_parameterized_gate_library(const GateLyt& lyt, const Params& params)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case would this function's return type not be used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case the parameterized gate library does not terminate with a cell-level layout but throws an error.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I understand this correctly. The case you're talking about seems to be the one against noexcept. If a function may throw an exception, it can't be noexcept. However, if every single call to this function always assigns the return value to a variable, it should be [[nodiscard]].

Copy link
Collaborator Author

@Drewniok Drewniok Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! I was not precise enough. If I remember correctly, I think I changed it since I got compiler warnings here:

CHECK_THROWS(apply_parameterized_gate_library<cell_lyt, sidb_on_the_fly_gate_library, hex_even_row_gate_clk_lyt>(layout, params));

However, I think this could also be solved by using (void), right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what is on_the_fly_but_predefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we use the sidb_on_the_fly_gate_library, we have the option if all gates are designed on-the-fly, or if for complex gates aka double wire, cx, ha, predefined ones are tried to be used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can gladly rename it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hear "predefined" and "on-the-fly" are contradictory then? In this case, the file could be called simply predefined_double_wire.sqd. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the naming you suggested is indeed sufficient.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you okay with on_the_fly_with_predefined_double_wire?

Comment on lines 168 to +169
template <typename GateLyt, typename CellLyt, typename Params>
static fcn_gate set_up_gate(const GateLyt& lyt, const tile<GateLyt>& t, const Params& parameters = Params{})
static fcn_gate set_up_gate(const GateLyt& lyt, const tile<GateLyt>& t, const Params& params)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really long function. Can it be broken down meaningfully?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I know, and I am not a big fan of long functions either. However, I don't see a reasonable way to split it up. We could put everything inside if (lyt.is_buf(n)) into another function, but then the question arises, why exactly for this one?

@Drewniok
Copy link
Collaborator Author

Drewniok commented Jan 28, 2025

Thank you, @marcelwa, for 3a78118 🙏

}
}

TEST_CASE("Gate-level layout with with different gates", "[apply-gate-library]")

Check warning

Code scanning / CodeQL

Poorly documented large function Warning test

Poorly documented function: fewer than 2% comments for a function of 257 lines.
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions


#include "fiction/algorithms/physical_design/apply_gate_library.hpp"
#include "fiction/algorithms/physical_design/exact.hpp"
#include "fiction/technology/cell_ports.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: included header exact.hpp is not used directly [misc-include-cleaner]

Suggested change
#include "fiction/technology/cell_ports.hpp"
#include "fiction/technology/cell_ports.hpp"

/**
* Parameters for the *exact* placement and routing algorithm.
*/
exact_physical_design_params exact_design_parameters = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 'exact_physical_design_params' [clang-diagnostic-error]

    exact_physical_design_params exact_design_parameters = {};
    ^

/**
* The `stats` of the *exact* algorithm.
*/
exact_physical_design_stats exact_stats{};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 'exact_physical_design_stats' [clang-diagnostic-error]

    exact_physical_design_stats exact_stats{};
    ^


on_the_fly_circuit_design_on_defective_surface_stats<GateLyt> st{};

exact_physical_design_stats exact_stats{};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 'exact_physical_design_stats' [clang-diagnostic-error]

    exact_physical_design_stats exact_stats{};
    ^

{
// P&R with *exact* and the pre-determined blacklist
gate_level_layout =
exact_with_blacklist<GateLyt>(ntk, black_list, params.exact_design_parameters, &exact_stats);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [clang-diagnostic-c++20-extensions]

                exact_with_blacklist<GateLyt>(ntk, black_list, params.exact_design_parameters, &exact_stats);
                ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants