[FEA]: Improve warning or error message for allocator exhaustion in parallel execution
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 486
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 295
Description
### Is this a duplicate?
- [x] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this request and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)
### Area
Thrust
### Is your feature request related to a problem? Please describe.
When using parallel algorithm, Thrust throws a generic `cudaErrorIllegalAddress` when device allocator exhaustion occurs. It would be helpful if Thrust provided a clearer diagnostic or warning message to indicate allocator exhaustion instead of a misleading illegal memory access error.
```
#include
#include
#include
#include
int main() {
int numberAtoms = 600 * 300;
auto grid = std::ranges::views::iota(0, numberAtoms);
std::for_each(std::execution::par_unseq, std::begin(grid), std::end(grid),
[](int i) {
std::vector data(15);
}
);
return 0;
}
```
The program runs fine for smaller vector sizes (e.g., 15). It fails at runtime for larger vector sizes (e.g., 100) with:
```
terminate called after throwing an instance of 'thrust::THRUST_300200_SM_90_NVHPC_NS::system::system_error'
what(): parallel_for: failed to synchronize: cudaErrorIllegalAddress: an illegal memory access was encountered
Aborted (core dumped)
```
Increasing the data size increases concurrent device allocations, which can exhaust the CUDA device heap and cause allocator failure.
Increasing the device heap limit resolves the issue:
```
cudaDeviceSetLimit(cudaLimitMallocHeapSize, 1 << 28);
```
The default heap size is 8 MB.
It would be beneficial if Thrust detects allocator exhaustion scenarios, and reports a clearer diagnostic or warning (e.g., indicating device heap exhaustion) rather than a generic cudaErrorIllegalAddress.
### Describe the solution you'd like
```
nvc++ -std=c++23 -Minfo=stdpar -stdpar=gpu test.cpp;
```
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.