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

fix data races #1019

Merged
merged 1 commit into from
Nov 4, 2024
Merged

fix data races #1019

merged 1 commit into from
Nov 4, 2024

Conversation

pca006132
Copy link
Collaborator

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.

Copy link

codecov bot commented Nov 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.20%. Comparing base (d437097) to head (36489d0).
Report is 139 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@elalish elalish left a 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)
Copy link
Owner

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 #ifs?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Owner

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do these do?

Copy link
Collaborator Author

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.

@pca006132 pca006132 merged commit 4076b14 into elalish:master Nov 4, 2024
39 checks passed
@pca006132 pca006132 deleted the fix-race branch November 4, 2024 05:29
@elalish elalish mentioned this pull request Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants