Repository navigation
feat: add cp.async zero-fill variants (src_size parameter) - #305
Merged
Merged
Conversation
49 tasks done
honeyspoon
force-pushed
the
upstream-cp-async-zerofill
branch
from
June 26, 2026 17:43
5065f9c to
5b5a242
Compare
nihalpasham
force-pushed
the
upstream-cp-async-zerofill
branch
from
June 28, 2026 03:45
5b5a242 to
961479f
Compare
Add three `cp.async.ca` zero-fill variants that accept a `src_size`
parameter for hardware-assisted zero-fill of boundary tiles. When
`src_size < cp_size`, the remaining bytes are zero-filled by hardware.
| Device API | PTX |
|--------------------------|--------------------------------------------------------|
| `cp_async_ca_zfill_4` | `cp.async.ca.shared.global [smem], [gmem], 4, src_sz;` |
| `cp_async_ca_zfill_8` | `cp.async.ca.shared.global [smem], [gmem], 8, src_sz;` |
| `cp_async_ca_zfill_16` | `cp.async.ca.shared.global [smem], [gmem],16, src_sz;` |
Changes:
- cuda-device: 3 new `pub unsafe fn` stubs in `async_copy.rs`
- dialect-nvvm: 3 new ops (CpAsyncCaZfill{4,8,16}Op) with 3 operands
- mir-importer: generalized `emit_cp_async<T: Op>` shared emitter,
3 new zero-fill dispatch arms
- mir-lower: `convert_cp_async_zfill_impl` shared lowering with
`inline_asm_sideeffect()`, 3 MirToLlvmConversion impls
- tests: 3 new lowering tests
- example: `cp_async_zfill` e2e GPU test (full copy, partial copy,
zero copy)
Part of NVIDIA#274. Depends on NVIDIA#280.
Signed-off-by: abder <[email protected]>
Signed-off-by: nihalp <[email protected]>
Signed-off-by: nihalp <[email protected]>
nihalpasham
force-pushed
the
upstream-cp-async-zerofill
branch
from
June 28, 2026 04:23
961479f to
3dc667e
Compare
Collaborator
|
Thanks for the PR. Small-copy work with hardware zero-fill: The full, partial, and zero-source cases make the boundary-tile behavior easy to understand. I rebased the branch directly onto the corrected #280 head and added a few safety details:
The corrected |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add three
cp.async.cazero-fill variants that accept asrc_sizeparameter for hardware-assisted zero-fill of boundary tiles. Whensrc_size < cp_size, the remaining bytes are zero-filled.Summary
Extends the
cp.asyncsupport from #280 with the optionalsrc_sizeparameter. This is the standard mechanism for handling boundary conditions in tiled algorithms where the last tile may be smaller than the full tile size, avoiding the need for manual zero-padding on the host or a separate kernel path.cp_async_ca_zfill_4cp.async.ca.shared.global [smem], [gmem], 4, src_sz;cp_async_ca_zfill_8cp.async.ca.shared.global [smem], [gmem], 8, src_sz;cp_async_ca_zfill_16cp.async.ca.shared.global [smem], [gmem], 16, src_sz;Part of #274. Depends on #280.
Changes
pub unsafe fnstubs inasync_copy.rs(raw pointer operations require unsafe). Cross-references between zero-fill and non-zero-fill variants.CpAsyncCaZfill{4,8,16}Op) with 3 operands (dst, src, src_size) and 0 results.emit_cp_async<T: Op>shared emitter (replaces the previous per-variant functions), 3 new zero-fill dispatch arms.convert_cp_async_zfill_implshared lowering helper usinginline_asm_sideeffect(); 3MirToLlvmConversionimpls.cp_async_zfillend-to-end GPU test exercising full copy (src_size=4), partial copy (src_size=2, upper bytes zeroed), and zero copy (src_size=0, entire word zeroed).Testing
cargo test -p mir-lower --test lowering_testpasses (5/5 cp.async tests)cargo fmt --checkandcargo clippycleancp_async_zfill)Checklist
git commit -s)cuda-bindings/modified