NVIDIA / NVIDIA/cccl

[BUG]: Thrust execution policy allocators should be rebound to the target type before allocating.

Open
#1,314 0 comments 0 reactions 0 assignees View on GitHub
thrust
Dominant language
C++
Stars
2.5k
Forks
487
Avg merge
2d 7h
Merged PRs (30d)
296

Description

### Is this a duplicate?

- [X] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this bug and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)

### Type of Bug

Runtime Error

### Component

Thrust

### Describe the bug

Thrust currently uses execution policy allocator as-is, without rebinding ([example](https://github.com/NVIDIA/cccl/blob/8cd246458ffed4894632c7e7ac566686288174f9/thrust/thrust/detail/execute_with_allocator.h#L53-L63)). This may result in type-specific issues, such as alignment problems.

Ideally, an execution policy should be able to be created with a `void`-typed allocator without issue, but currently this will fail to compile as the code linked above attempts to calculate `sizeof(void)`.

### How to Reproduce

Execute `thrust::reduce(thrust::device(thrust::device_allocator{}), ...)`. This will fail to compile.

### Expected behavior

Passing a `void`-typed allocator should compile, and all allocations using this generic allocator should be rebound prior to use.

### Reproduction link

_No response_

### Operating System

_No response_

### nvidia-smi output

_No response_

### NVCC version

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with thrust/thrust/detail/execute_with_allocator.h at the linked allocation code, then reproduce the compile failure with thrust::reduce(thrust::device(thrust::device_allocator{}), ...). Done means a void-typed execution-policy allocator compiles and generic allocations are rebound to their target type before use.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.