Fix #5073: Slices of dynamic shared memory all alias #5099
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The root of the issue was that computations of indices and slice bounds were incorrect because the shape of dynamic shared memory is generally
(0,)
. To fix this, we compute the shape (1-D only) of dynamic shared arrays using the dynamic shared memory size and the itemsize of the type of the array when it is created.This is implemented by reading the special register
%dynamic_smem_size
- unfortunately NVVM doesn't provide an intrinsic for this, so we access it using inline assembly.As part of these changes, the
_generic_array
function is refactored and_make_array
folded into it (_generic_array
was the only caller and its parameters were the same as its local variables). The refactored version checks for errors earlier on and moves groups the creation of various variables more closely with their usages.