Skip to content

Typed CTA-shared pointers so TMA G2S can use .shared::cta (SM12x setmaxnreg loss, #1238) #1337

Open

Description

@lucifer1004

Problem

#1238: a kernel that combines setmaxnreg register donation with cp_async_bulk_tensor_*_g2s loses both USETMAXREG instructions on SM12x (ptxas C7506).

Root cause, from hand-written PTX assembled with CUDA 13.3 ptxas and inspected in SASS:

TMA G2S form sm_120a sm_100a
.shared::cluster with a converted generic address ptxas emits a runtime CTA-id check: local addresses take UTMALDG, anything else calls __cuda_syscall_cp_async_bulk_tensor_2d_tile_unicast; C7506 native, USETMAXREG kept
.shared::cluster with a 32-bit .shared::cta address (the CUTLASS idiom) same syscall path; C7506 native
isspacep.shared::cta branch, with the cluster fallback inline or in a separate function C7506 –
.shared::cta UTMALDG only, USETMAXREG kept native

On SM12x a unicast TMA into another CTA's shared memory is emulated by a syscall. ptxas keeps that path whenever it cannot prove that the destination is CTA-local. Only a statically emitted .shared::cta form avoids it; runtime checks and address tricks do not.

Options considered

  • Select .shared::cta by target (fix(tma): select CTA-local G2S on SM120/SM121 #1249). Unsound: SM12x does support peer destinations, through the emulated path.
  • An explicit _g2s_cta API with an unsafe locality promise (feat(tma): add CTA-local G2S tile intrinsics #1336). Works, but the caller carries the proof.
  • Infer locality from pointer provenance, by propagating address spaces through casts in the importer. Pointers passed to helpers stay generic, since helpers are not inlined, and changing pointer types tree-wide affects unrelated inline-PTX lowerings, such as tcgen05.alloc's cvta.to.shared.
  • Carry the address space in the type, like CuTe's smem_ptr. Locality is known statically, survives helper calls, and needs no dataflow. The importer already makes *mut Barrier and *mut SharedArray<..> addrspace(3) by type; this extends that to arbitrary CTA-shared pointers.

Plan

The existing cp_async_bulk_tensor_*_g2s keeps its cluster contract unchanged.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions