Optimized sample generation in Sobol sequence code#593
Open
sshudler wants to merge 1 commit intoLuxCoreRender:masterfrom
Open
Optimized sample generation in Sobol sequence code#593sshudler wants to merge 1 commit intoLuxCoreRender:masterfrom
sshudler wants to merge 1 commit intoLuxCoreRender:masterfrom
Conversation
Comment on lines
+52
to
+59
| result ^= ((i & 1) * directions[offset]); | ||
| i >>= 1; offset++; | ||
| result ^= ((i & 1) * directions[offset]); | ||
| i >>= 1; offset++; | ||
| result ^= ((i & 1) * directions[offset]); | ||
| i >>= 1; offset++; | ||
| result ^= ((i & 1) * directions[offset]); | ||
| i >>= 1; offset++; |
There was a problem hiding this comment.
There is no longer a bounds check on i for 3 of the 4 indexes into directions before the loop repeats, how do you ensure the offset is always a valid index?
Author
There was a problem hiding this comment.
Before the change and after the change i wasn't used as an index into directions. Whenever the loop was hitting a 1 bit in i it would index into directions by that bit's offset. The way directions defined, starting from the offset it has SOBOL_BITS range for access, so in the new code the access to directions is valid and when i becomes 0 none of these directions values will be used in the result because of & with (0 & 1). Also, SOBOL_BITS == sizeof(i).
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.
This code does two things:
We noticed a performance improvement of about 6%-15% in some scenarios on some systems.
@csakthiv-intel