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
Add a check for overflow of n_results
variable in CrsGraphWrapperImpl::queryImpl function
#1012
Conversation
…pl::queryImpl function
I understand this check won't always catch the overflow, it's possible for |
if(n_results < 0){ | ||
// overflow | ||
throw std::runtime_error("The search resulted in too many neighbor pairs. " | ||
"Please ensure the primitive positions are not " | ||
"in a degenerate state."); | ||
} |
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.
Maybe, just
if(n_results < 0){ | |
// overflow | |
throw std::runtime_error("The search resulted in too many neighbor pairs. " | |
"Please ensure the primitive positions are not " | |
"in a degenerate state."); | |
} | |
// Catch possible overflow | |
ARBORX_ASSERT(n_results >= 0); |
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.
This is more helpful than the current state. Though as a user of this library (or for that matter any library), I would always prefer to avoid stepping through the library code to find out what an internal variable does.
@Shihab-Shahriar This is definitely an interesting proposition. In general, there are multiple places where overflow could occur, both in ArboX and Kokkos, this is just one of them. An issue with this particular approach to fixing it is that it won't work if we make counts to be unsigned, or if the overflow occurs within exclusive scan. What was the original failing behavior? Did the code crash? If it did, what was the error message? Have you tried running the original buggy code with any of the sanitizers, such as |
@masterleinad Am I right in that Kokkos just treats all of the passed dimensions as |
Yes, the |
@aprokop the error I initially had from kokkos was "not enough memory to allocate for "indices" array" in the On the issue of handling this in kokkos, I think an overload of |
Opened an issue on kokkos repo. |
Not doing it on ArborX side, will rely on Kokkos. |
Due to a failure in initialization, I had a bug where I generated too many neighbor pairs. I think this can happen anytime there are too many primitives in a small place (leading to N^2 pairs).
This check might help a future user to quickly track down this sort of bugs.
Please feel free to edit the error message.
(I wonder if this is something kokkos should try to catch i.e. when a user tries to allocate a view with a negative dimension size.)