Repository navigation
feat: add cp.async 4-byte and 8-byte copy intrinsics (sm_80+) - #280
Merged
Merged
Conversation
49 tasks done
honeyspoon
force-pushed
the
upstream-cp-async-small
branch
from
June 24, 2026 13:25
11f7ac2 to
ae2100f
Compare
6 tasks done
honeyspoon
force-pushed
the
upstream-cp-async-small
branch
from
June 26, 2026 17:41
ae2100f to
40d8ff0
Compare
honeyspoon
added a commit
to honeyspoon/cuda-oxide
that referenced
this pull request
Jun 26, 2026
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]>
Add cp.async.ca variants for 4-byte and 8-byte asynchronous global-to-shared memory copies, extending the existing 16-byte cp.async.ca/cg support. Lowered to inline PTX with AsmKind::SideEffect (memory write, non-convergent). Part of NVIDIA#274 Signed-off-by: abder <[email protected]>
Signed-off-by: nihalp <[email protected]>
nihalpasham
force-pushed
the
upstream-cp-async-small
branch
from
June 28, 2026 03:32
40d8ff0 to
24e53b0
Compare
Signed-off-by: nihalp <[email protected]>
nihalpasham
pushed a commit
to honeyspoon/cuda-oxide
that referenced
this pull request
Jun 28, 2026
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]>
Collaborator
|
Thank you for adding the missing 4-byte and 8-byte async-copy forms. They are useful building blocks for kernels that cannot naturally move a full 16 bytes per lane. I added a few safety and integration details on the branch:
Both copy widths now compile to the expected |
nihalpasham
pushed a commit
to honeyspoon/cuda-oxide
that referenced
this pull request
Jun 28, 2026
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]>
nihalpasham
added a commit
that referenced
this pull request
Jun 28, 2026
* feat: add cp.async zero-fill variants (src_size parameter, sm_80+)
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 #274. Depends on #280.
Signed-off-by: abder <[email protected]>
* fix: harden cp.async zero-fill integration
Signed-off-by: nihalp <[email protected]>
* style: format cp.async zero-fill example
Signed-off-by: nihalp <[email protected]>
---------
Signed-off-by: abder <[email protected]>
Signed-off-by: nihalp <[email protected]>
Co-authored-by: nihalp <[email protected]>
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 cp.async.ca variants for 4-byte and 8-byte asynchronous global-to-shared memory copies, extending the existing 16-byte cp.async.ca/cg support.
Summary
The existing
cp.asyncsupport covers 16-byte cache-all (ca) and cache-global (cg) copies. This PR adds the smaller 4-byte and 8-bytecp.async.cavariants, which are needed when copying sub-cacheline data (e.g., packed scalars, individual matrix fragments) in asynchronous pipelines.These are lowered to inline PTX assembly with
AsmKind::SideEffect(memory write to shared memory, non-convergent). A newinline_asm_sideeffect()helper is added tocommon.rsalongside the existinginline_asm_convergent(), providing the correct non-convergent + side-effect combination for memory operations that are not warp-synchronous.cp_async_ca_4(dst, src)cp.async.ca.shared.global [%0], [%1], 4;cp_async_ca_8(dst, src)cp.async.ca.shared.global [%0], [%1], 8;Part of #274
Changes
pub unsafe fnstubs inasync_copy.rs(raw pointer operations require unsafe).CpAsyncCa4Op,CpAsyncCa8Op) with 2 operands (dst shared ptr, src global ptr) and 0 results.emit_cp_async_ca_*translation functions with dispatch arms.convert_cp_async_ca_*lowering functions using newinline_asm_sideeffect()helper; 2MirToLlvmConversionimpls.inline_asm_sideeffect()helper for non-convergent side-effect inline asm (distinct from the existinginline_asm_convergent()which is for warp-synchronous ops).cp_async_smallend-to-end GPU example testing 4-byte and 8-byte async copies via shared memory.Testing
cargo test -p mir-lower --test lowering_testpassescargo fmt --checkandcargo clippycleancp_async_small)Checklist
git commit -s)cuda-bindings/modified