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

Changed the random number generator in packer to deterministic vtr::irand #2871

Merged
merged 4 commits into from
Jan 28, 2025

Conversation

haydar-c
Copy link
Contributor

Description

Changed the random number generator in add_cluster_molecule_candidates_by_attraction_group in packer to be vtr::irand. Initiated the vtr::RngContainer in do_clustering before each reference of try_glow_cluster.

Related Issue

#2858

[Pack] Random Number Generator in Packer is Non-Deterministic #2858

Motivation and Context

Aim is to make the adding cluster molecule candidate by attraction groups in packing deterministic.

How Has This Been Tested?

Local tests: vtr_reg_basic, vtr_reg_strong
CI Test Workflow

Types of changes

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@github-actions github-actions bot added VPR VPR FPGA Placement & Routing Tool lang-cpp C/C++ code labels Jan 24, 2025
Copy link
Contributor

@AlexandreSinger AlexandreSinger left a comment

Choose a reason for hiding this comment

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

@haydar-c Thank you for this change! I have some style comments that I think would improve your change and improve the documentation.

vpr/src/pack/greedy_candidate_selector.cpp Outdated Show resolved Hide resolved
vpr/src/pack/greedy_candidate_selector.h Show resolved Hide resolved
vpr/src/pack/greedy_candidate_selector.h Outdated Show resolved Hide resolved
vpr/src/pack/greedy_clusterer.cpp Outdated Show resolved Hide resolved
vpr/src/pack/greedy_clusterer.h Outdated Show resolved Hide resolved
@@ -160,6 +161,8 @@ GreedyClusterer::do_clustering(ClusterLegalizer& cluster_legalizer,

print_pack_status_header();

vtr::RngContainer rng(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that the only user of this RngContainer object is GreedyCandidateSelector. If this is the case, I think it makes more sense to add it as a member variable to GreedyCandidateSelector and initilize it in its constructor instead of passing it down a deep function call hierarchy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree! That would make things much cleaner! Especially since it is an independent object!

Copy link
Contributor

@AlexandreSinger AlexandreSinger left a comment

Choose a reason for hiding this comment

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

@haydar-c This is a beautiful PR now! I really like this implementation! Great job. LGTM

@haydar-c
Copy link
Contributor Author

@haydar-c This is a beautiful PR now! I really like this implementation! Great job. LGTM

Thanks for the review! Merging this now.

@AlexandreSinger
Copy link
Contributor

AlexandreSinger commented Jan 26, 2025

@haydar-c Perhaps wait to merge this until Vaughn has a quick look!

Edit: He may have other comments than mine.

@haydar-c
Copy link
Contributor Author

@haydar-c Perhaps wait to merge this until Vaughn has a quick look!

Edit: He may have other comments than mine.

Sure, still learning the conventions. Thanks for pointing that out.

Copy link
Contributor

@vaughnbetz vaughnbetz left a comment

Choose a reason for hiding this comment

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

Looks good; I suggest one commenting tweak.

@@ -516,5 +517,9 @@ class GreedyCandidateSelector {
/// @brief A count on the number of unrelated clustering attempts which
/// have been performed.
int num_unrelated_clustering_attempts_ = 0;

/// @brief Random number generator to get a random atom between 0 and
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd make this slightly more general to start.
I'd change this to:
@brief Random number generator used by the clusterer. Currently this is used only when selecting atoms from
attraction groups, but could be used for other purposes in the future.

@AlexandreSinger
Copy link
Contributor

LGTM. Merging.

@AlexandreSinger AlexandreSinger merged commit ddae365 into master Jan 28, 2025
36 checks passed
@AlexandreSinger AlexandreSinger deleted the making_packer_rng_deterministic branch January 28, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-cpp C/C++ code VPR VPR FPGA Placement & Routing Tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants