-
Notifications
You must be signed in to change notification settings - Fork 25
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
Resolve data races found by ThreadSanitizer #121
base: master
Are you sure you want to change the base?
Conversation
graph/Graph.cc
Outdated
unsigned char expected = bfs_in_queue_; | ||
unsigned char desired; | ||
do { | ||
if ((value && IN_QUEUE(expected, index)) || (!value && !IN_QUEUE(expected, index))) { | ||
return false; | ||
} | ||
desired = expected; | ||
SET_IN_QUEUE(value ? desired : expected, index); | ||
CLEAR_IN_QUEUE(value ? expected : desired, index); | ||
} while (!bfs_in_queue_.compare_exchange_weak(expected, desired)); | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this compare to just locking. I wonder if the additional memory locality and smaller memory footprint make up for the coarser lock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locking is slightly slower - a few benchmarks show slowdown between 0.5% and 2%
30209e0
to
1a3f0b7
Compare
@jjcherry56 Do these changes seem reasonable, or is there a better way to address these data races? The atomic bitset seems a bit complicated to me, but it might be worth the speed up. |
Signed-off-by: Eryk Szpotanski <[email protected]> Co-authored-by: Krzysztof Bieganski <[email protected]>
1a3f0b7
to
4ccc9d8
Compare
As b4be3c5 fixed part of the data races, I've updated this PR to contain fixes for remaining ones - caused by:
|
This PR fixes following data races found by ThreadSanitizer when OpenSTA is run by OpenROAD-flow-scripts:
These changes incur a significant slowdown (between 10% and 40%, depending on number of threads, used design or stage).
Note that these are only the races found by ThreadSanitizer, not necessarily all of them.