Repository navigation
Support cp_async_bulk_ignore_oob in DeviceTransform - #7449
Conversation
5d0f8da to
cda5508
Compare
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
79c326f to
16b3c7c
Compare
16b3c7c to
8b3c05e
Compare
This comment has been minimized.
This comment has been minimized.
8b3c05e to
a01a2cc
Compare
| { | ||
| ptx::mbarrier_init(&bar, 1); | ||
|
|
||
| char* smem = smem_base; |
There was a problem hiding this comment.
should this be
| char* smem = smem_base; | |
| unsigned char* smem = smem_base; |
| // use all threads to copy the head and tail bytes, use the elected thread to start the bulk copy | ||
| char* smem = smem_base; | ||
| ::cuda::std::uint32_t total_copied = 0; | ||
| ::cuda::ptx::cp_async_bulk_ignore_oob( |
There was a problem hiding this comment.
This is currently only predicated on the ptx ISA, is this uniformly available / beneficial for all architectures?
| const bool elected = cuda::device::__block_elect_one(); | ||
| if (elected) | ||
| { | ||
| ptx::mbarrier_init(&bar, 1); | ||
| // an update to the CUDA memory model blesses skipping the following fence | ||
| // ptx::fence_proxy_async(ptx::space_shared); | ||
| } |
There was a problem hiding this comment.
This is the same in all code paths, should we pull that one out?
e755e85 to
2ace387
Compare
3e7cf6d to
e0c73c7
Compare
📝 SummarySummary by CodeRabbit
WalkthroughChangesDeviceTransform bulk-copy support
Assessment against linked issues
Suggested reviewers: Merge Risk: 🟠 High · up to The new DeviceTransform path can return corrupted results or read out of bounds for non-tile-multiple inputs. The padding calculation and targeted coverage should be fixed before merge. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 5cfe3e56-70eb-4ce5-b801-f2859cf853f0
📒 Files selected for processing (2)
cub/cub/device/dispatch/kernels/kernel_transform.cuhcub/test/catch2_test_device_transform.cu
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.
| tail_padding = head_padding > 0 ? 16 - head_padding : 0; // tile size % 16 == 0 | ||
| bytes_to_copy = ::cuda::round_up(head_padding + int{sizeof(T)} * valid_items, bulk_copy_size_multiple); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
critical: tail_padding is wrong for the last block. The comment assumes tile size % 16 == 0, but valid_items is clamped by num_items, so sizeof(T) * valid_items is not a multiple of 16 in the last tile.
Two failure modes follow:
- With
head_padding > 0: e.g.sizeof(T)*valid_items == 5,head_padding == 3givesbytes_to_copy == 16andtail_padding == 13. Ignore-left plus ignore-right then cover the whole transfer, so no element bytes reach shared memory and the results are garbage. - With
head_padding == 0:tail_paddingstays 0 whilebytes_to_copyis rounded up, so the copy reads up to 15 bytes past the allocation. That is the out-of-bounds read this path is meant to remove.
Derive the ignore-right count from the actual over-copy instead. Both ignore values then stay within the 15-byte limit.
fix
- head_padding = aligned_ptr.head_padding;
- tail_padding = head_padding > 0 ? 16 - head_padding : 0; // tile size % 16 == 0
- bytes_to_copy = ::cuda::round_up(head_padding + int{sizeof(T)} * valid_items, bulk_copy_size_multiple);
+ head_padding = aligned_ptr.head_padding;
+ bytes_to_copy = ::cuda::round_up(head_padding + int{sizeof(T)} * valid_items, bulk_copy_size_multiple);
+ tail_padding = bytes_to_copy - head_padding - int{sizeof(T)} * valid_items;Add a test with a non-tile-multiple num_items combined with a head-padded input pointer to cover this.
🔬 CUB benchmark SASS comparisonHow to request a benchmark run
Targets with a SASS change
|
This comment has been minimized.
This comment has been minimized.
🥳 CI Workflow Results🟩 Finished in 3h 24m: Pass: 100%/176 | Total: 8d 13h | Max: 2h 52m | Hits: 27%/647273See results here. |
Fixes: #7167