Documentation
¶
Overview ¶
Package tmemaddr checks that the tensor memory address of every tcgen05.ld and tcgen05.st in CUDA C++ or PTX source is the same in every lane of the warp.
PTX ISA 9.5 says of both instructions: "All the threads in the warp must specify the same value of taddr, which must be the base address of the collective load operation. Otherwise, the behavior is undefined." The lane a thread accesses is implied by its lane id, so an address built from the lane id, such as (32*warp + lane) << 16, is undefined behavior that an emulator reading one cell per thread does not see.
CheckCUDA and CheckPTX trace, within the source, which values derive from the lane id (threadIdx, %laneid, %tid) and report each tcgen05.ld or tcgen05.st whose address operand may be one of them. Shifting right by 5 or more bits, dividing by a multiple of 32 and masking with a constant whose low 5 bits are zero remove the lane id from a value. The analysis follows assignments, function parameters and return values but not control flow, so it reports a superset of the addresses that can differ between lanes for a reason it can see.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Site ¶
type Site struct {
Line int // 1-based line of the instruction in the source
Func string // enclosing function, or "" for PTX outside one
Op string // the instruction's opcode, such as tcgen05.ld.sync.aligned.32x32b.x1.b32
Addr string // the address operand
Cond string // for CheckCUDAConvergence, the lane-dependent condition
}
A Site is a tcgen05.ld or tcgen05.st whose address depends on the lane id, or a warp-collective tcgen05 instruction or call under a condition that does.
func CheckCUDA ¶
CheckCUDA checks every tcgen05.ld and tcgen05.st in the inline asm statements of the CUDA C++ source src. It returns the number of them and those whose address operand may depend on the lane id. The error reports an asm statement whose address operand it cannot find.
func CheckCUDAConvergence ¶
CheckCUDAConvergence checks that every warp-collective tcgen05 instruction (one with .sync.aligned) in the inline asm of the CUDA C++ source src, and every call of a function issuing one, is reached by all lanes of a warp or none. It returns the number of such sites and those governed by a condition that may depend on the lane id: the condition of an enclosing if, for, while or switch statement; of an earlier if that returns; of an earlier if in the same loop body that continues; or of an if anywhere in the loop body that breaks. Each Site's Cond is that condition. A condition such as tid < L is reported even when L is a multiple of 32; write it in warps, warp < L / 32, so the source says it holds for whole warps. Only threadIdx.x compared with a literal multiple of 32 is taken to hold for whole warps.
func CheckPTX ¶
CheckPTX checks every tcgen05.ld and tcgen05.st in the PTX source src. It returns the number of them and those whose address register may depend on the lane id (%laneid or %tid). Register names are not scoped by function, so a register that depends on the lane id in one function is taken to in all of them.