You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SeqCst is overly restrictive. I believe that the ordering can be appropriately modified.
In par_bridge model, I believe that split_count is just a counter across threads and does not synchronize with other locals. Therefore, using Relaxed ordering should suffice.
let counter = self.tour_counter.fetch_add(1,Ordering::SeqCst);
Similarly, In solver model, tour_counter is just a counter across threads, using Relaxed ordering should suffice.
(happy to make a PR if this looks reasonable)
The text was updated successfully, but these errors were encountered:
wang384670111
changed the title
Potential to modify ordering for split_count in par_bridge module
Potential to modify ordering for split_count and tour_counter
Mar 4, 2024
It's been this way in par_bridge since it was first added in #550, but I don't think we paid much attention to that ordering. I agree that Relaxed should be fine, but I also think it won't make much difference, as this only executes once per thread for a given par_bridge. The real contention comes when they all wait on the same Mutex<Iter>.
The tsp counter is fine to change too. You're welcome to make a PR!
rayon/src/iter/par_bridge.rs
Lines 113 to 115 in 990841b
SeqCst
is overly restrictive. I believe that the ordering can be appropriately modified.In
par_bridge
model, I believe thatsplit_count
is just a counter across threads and does not synchronize with other locals. Therefore, usingRelaxed
ordering should suffice.rayon/rayon-demo/src/tsp/solver.rs
Line 67 in 990841b
Similarly, In
solver
model,tour_counter
is just a counter across threads, usingRelaxed
ordering should suffice.(happy to make a PR if this looks reasonable)
The text was updated successfully, but these errors were encountered: