Open jlapeyre opened 3 years ago
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.
Finished examples of making this work are here https://github.com/Qiskit/rustworkx/pull/815 and reference therein. It looks like at least some of the items in the opening comment above are still relevant.
See this comment:
https://github.com/Qiskit/retworkx/pull/428#issuecomment-918391894
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