-
Notifications
You must be signed in to change notification settings - Fork 114
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
fix data races #1019
fix data races #1019
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1019 +/- ##
==========================================
- Coverage 91.84% 85.20% -6.65%
==========================================
Files 37 62 +25
Lines 4976 9791 +4815
Branches 0 1052 +1052
==========================================
+ Hits 4570 8342 +3772
- Misses 406 1449 +1043 ☔ View full report in Codecov by Sentry. |
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.
Thanks!
// thread sanitizer doesn't really know how to check when there are too many | ||
// mutex | ||
#if defined(__has_feature) | ||
#if __has_feature(thread_sanitizer) |
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.
Can we use &&
instead of two #if
s?
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.
Probably, I just copied this from clang user manual.
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.
ok apparently this wouldn't work.
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.
interesting!
@@ -109,6 +109,10 @@ struct UpdateProperties { | |||
} | |||
const int propVert = triProp[tri][i]; | |||
|
|||
auto old = std::atomic_exchange( | |||
reinterpret_cast<std::atomic<uint8_t>*>(&counters[propVert]), 1); | |||
if (old == 1) return; |
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.
What do these do?
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.
Make sure we only write the thing once.
Fixed some known data races in our code. The issue with data race is that it is undefined behavior. Also, data race can introduce non-determinism into our code, although that is not yet addressed now.
I think thread sanitizer is happy with our code now, for some reason it reports the custom radix sort as racy, but I have no idea why it is racy (I think I followed the tbb API), so it is exempted for now. For
AddNewEdgeVerts
, we are probably using many mutexes, which thread sanitizer is not too happy about, so I exempted it for now either.