Segfault fixes and deterministic multithreading#126
Open
nh2 wants to merge 3 commits intonmoehrle:masterfrom
Open
Segfault fixes and deterministic multithreading#126nh2 wants to merge 3 commits intonmoehrle:masterfrom
nh2 wants to merge 3 commits intonmoehrle:masterfrom
Conversation
The direct call to `make` in `BUILD_COMMAND` used until now forced subprojects
to build with `-j1`, generating the message:
warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
See https://gitlab.kitware.com/cmake/cmake/issues/16273.
Until now, it was possible that a mask with a 255 in its border was generated,
later failing the `valid_mask` assertions, or, if assertions are disabled
by the build, segementation faults due to invalid memory accesses.
See the example in the added comment for a condition where this could happen.
The key insight is that if a point lay exactly on the "border" between two
pixels, say between pixel N and N+1, it counted as occupying pixel N+1.
So the triangle { (1,1), (1,2), (2,1) } in a 3x3 image would result in mask
64 64 64
64 255 255
64 255 64
(notice the triangle of 255s), instead of the correct mask
64 64 64
64 255 64
64 64 64
This commit fixes it by adding the condition that the last
`x = width-1` and `y = height-1` must not count as `inside` the triangle.
It also improves related assertions in a few places.
When adding to vectors (e.g. using `push_back()`), `ordered` in contrast to `critical` ensures that ordering of operations is the same as if run single-threadedly, and it ensures that the result is the same on every run of the program. This allows to generate deterministic results: Run with same inputs, byte-identical outputs are to be produced, independent of threading. I have checked using `time` on a 6-core machine that the changes have no significant impact on performance; this is expected because the critical regions are very small (usually adding small pointers to vectors). One location remains that still uses `critical` because `omp ordered` cannot be used inside `pragma omp parallel`, only inside `pragma omp parallel for`; this is likely because of the thread-local variable `projected_face_view_infos` being intended as a per-thread intermediate buffer; more effort needs to be put into how that can be put back into order. I've added a TODO for this. I haven't yet observed nondeterminism due to this, but may as well have been lucky.
This was referenced Oct 14, 2019
|
Just wanted to stop by and say thanks, ran into the same issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #125, and the commit messages.