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

CUDA: Integer Overflow in Array Size Check #123

Closed
christgau opened this issue Feb 16, 2022 · 1 comment
Closed

CUDA: Integer Overflow in Array Size Check #123

christgau opened this issue Feb 16, 2022 · 1 comment

Comments

@christgau
Copy link

Hi,

@posch and I noted for the CUDA version of the benchmarks that large array sizes cause an integer overflow in the check whether the required amount of memory exceeds the GPUs global memory capacity:

cudaGetDeviceProperties(&props, 0);
if (props.totalGlobalMem < 3*ARRAY_SIZE*sizeof(T))
throw std::runtime_error("Device does not have enough memory for all 3 buffers");

On a x86_64 system with Linux (and GCC 8.3) an "large enough" array size of, e.g., 1024^3 causes an overflow when multiplied with three. The resulting (negative) value is then sign extended/promoted to (unsigned) size_t and compared with the memory capacity. The comparison shown above returns true even if the device in use has 40 GB or more of memory and could therefore provide the space for the three arrays.

This may affect not only the CUDA version of the benchmark.

tomdeakin added a commit that referenced this issue Feb 16, 2022
@tomdeakin
Copy link
Contributor

This should be fixed in the develop branch, and will go into v4.1 when we release that.

Thanks for reporting the Issue.

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

No branches or pull requests

2 participants