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

Use rayon-cond to use threads conditionally without manual code duplication. #448

Open
jlapeyre opened this issue Sep 13, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@jlapeyre
Copy link
Collaborator

jlapeyre commented Sep 13, 2021

See this comment:

#428 (comment)

Sometimes one wants to choose whether to use multiple threads in a loop based on some runtime criteria. rayon-cond does the code duplication with a macro hidden behind a nice interface.

@mtreinish pointed to these sections that could be cleaned up this way.

https://github.com/Qiskit/retworkx/blob/main/src/shortest_path/floyd_warshall.rs#L189-L216
https://github.com/Qiskit/retworkx/blob/main/src/shortest_path/floyd_warshall.rs#L117-L140
https://github.com/Qiskit/retworkx/blob/main/src/shortest_path/average_length.rs#L65-L72
https://github.com/Qiskit/retworkx/blob/main/src/shortest_path/distance_matrix.rs#L73-L84

@mtreinish mtreinish added this to the 0.11.0 milestone Sep 14, 2021
@mtreinish mtreinish added the enhancement New feature or request label Sep 14, 2021
@jlapeyre
Copy link
Collaborator Author

Unfortunately, rayon's par_iter iterates over items in a collection, but rayon-cond's CondIterator iterates over references to items. So code has to be changed a bit when modifying to use rayon-cond.

@mtreinish mtreinish removed this from the 0.11.0 milestone Jan 4, 2022
@jlapeyre
Copy link
Collaborator Author

Finished examples of making this work are here #815 and reference therein.
It looks like at least some of the items in the opening comment above are still relevant.

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

No branches or pull requests

2 participants