-
Notifications
You must be signed in to change notification settings - Fork 38
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 a warning for 64-bit 2D Morton codes #640
Conversation
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 you think of a test that would catch that issue?
So far, no. In fact, |
OK, after careful examination, this is not a bug. It works correctly despite doing a weird thing. The slowdown I observed on GPU was actually caused by a different issue. So this PR is now solely to fix the warning. |
We do (1 << 31). The problem is that MAX_INT (which is 2147483647) is smaller than that, which leads to overflow. Despite that, `unsigned int N = 1 << 31;` produces correct result, same as `unsigned int N = 1u << 31;`.
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.
I think this is much better even if it's not a bug. The bit shift here really is understood as multiplication that should not overflow.
Builds passed, only warnings from the SYCL container build. |
Introduced in #635.
We do (1 << 31). The problem is that MAX_INT (which is 2147483647) is one smaller than that, which leads to overflow.
NVCC correctly warns about that. But we don't catch Nvidia warnings in CI (see #272), so we missed this.
Not sure why none of the host compilers produced a warning.
This is the only place where it is necessary, all other places shift by less than 31.
This bug potentially leads to construction of a wrong hierarchy.