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

Sort VectorValues::values() by key when TBB is ON #1740

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

arutkowski
Copy link
Contributor

This PR fixes #1731 as the title suggests.

Specifically, a private member function sorted() was added, which is used by values(), operator<<, and html(const KeyFormatter&) to sort the output by key as a user would expect.

@arutkowski
Copy link
Contributor Author

arutkowski commented Mar 26, 2024

@dellaert Hmm, the Python CI with TBB timed out after 360 minutes. Should I try it again?

@varunagrawal
Copy link
Collaborator

@arutkowski can you please merge in the latest develop? I upgraded the OS on the Python CI to tackle this time out issue and we haven't been seeing it since.

@arutkowski
Copy link
Contributor Author

@varunagrawal It looks like I'm up to date now (1 commit ahead of 11409b0). It also looks like it passed CI.

/* ************************************************************************ */
std::map<Key, Vector> VectorValues::sorted() const {
std::map<Key, Vector> ordered;
for (const auto& kv : *this) ordered.emplace(kv);
Copy link

Choose a reason for hiding this comment

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

why not just use a std::vector<std::pair<Key, Vector>>, then performs reserve, emplace_back and sort ? The map structure is not continuous in memory, and the insertion operation is also very time-consuming.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a great suggestion @tanzby, however the map is used to maintain the same structure as that provided and expected by TBB. I don't think we know for certain if changing to a std::vector would play nicely with TBB or introduce some subtle bugs.

If you are well versed in how TBB works and can make a PR for this, we would welcome it.

Copy link
Collaborator

@varunagrawal varunagrawal left a comment

Choose a reason for hiding this comment

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

Can't see anything obviously problematic, so LGTM.

@varunagrawal varunagrawal merged commit 4abef92 into borglab:develop Apr 4, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VectorValues::vector() doesn't sort by key when GTSAM_WITH_TBB is ON
3 participants