Documentation
¶
Overview ¶
Package ptxsync checks conservative subsets of PTX synchronization.
It uses PTX source control flow to certify uniform participation in full-CTA barrier phases along a finite, thread-independent path. It checks selected finite synchronization idioms and reports where a kernel requires analysis outside that subset, including memory barriers, async proxies, and release/acquire protocols.
This package is outside the compatibility promise of github.com/tmc/lib/nvidia. Its API may change or be removed in patch releases.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Protocol ¶
type Protocol uint8
Protocol selects a finite synchronization idiom. Each idiom has a narrower assurance claim than checking arbitrary PTX.
const ( // CTAMBarrier checks one local object's initialization, single // synchronous arrival, and test of the returned phase token. CTAMBarrier Protocol = iota + 1 // fence, bulk copy, commit, and completion wait. SharedAsyncCopy // GridPublication checks a release/acquire flag handoff between // two named single-thread entries on the same GPU. The supplied // entries model the publisher and subscriber, in that order. GridPublication )
type ProtocolPremises ¶
type ProtocolPremises struct {
// SingleCTA attests that the async-copy entry is launched as one CTA.
SingleCTA bool
// ExclusiveDestination attests that no other thread, launch, or
// host operation can write the global copy destination while the
// async-copy entry is running.
ExclusiveDestination bool
}
ProtocolPremises contains caller attestations about a launch and its environment. The checker cannot infer these facts from PTX.
type ProtocolReport ¶
ProtocolReport is the result of checking one recognized idiom. On a checked result Lines gives the protocol instruction lines in order; for GridPublication the publisher precedes the subscriber.
func CheckProtocol ¶
func CheckProtocol(source []byte, kind Protocol, premises ProtocolPremises, entries ...string) (ProtocolReport, error)
CheckProtocol checks the named entry or pair of entries. All entries must have .reqntid 1,1,1 and be straight-line. The caller supplies legal PTX for the target, normal progress, and exclusive access to named objects by the selected participants. SharedAsyncCopy requires both explicit launch premises. GridPublication further assumes the flag is initially zero, the two entries run once with one CTA each, and the CTAs run on the same GPU. Its guarantee is conditional on observing the release, regardless of whether or when the subscriber observes it.
The result applies to protocol shape and ordering, not memory allocation, launch admission, or arbitrary kernel safety. A result of Unknown has no safety implication.
type ReductionReport ¶
type ReductionReport struct {
Entry string
Status Status
Barriers []Barrier
WarpSyncs []int // PTX lines of proved full-warp shfl.sync / bar.warp.sync instructions
Findings []Finding
}
ReductionReport is the source-level synchronization check for a scoped warp and shared-memory reduction kernel entry.
func CheckReduction ¶
func CheckReduction(source []byte) ([]ReductionReport, error)
CheckReduction parses source and checks each kernel entry for a scoped warp/shared-memory reduction contract:
- Entry parameters loaded via ld.param.* are CTA-uniform.
- Every full-CTA bar.sync has an immediate ID in [0, 15], no participant count, and executes under CTA-uniform control flow (never inside a warp-divergent, lane-divergent, or data-dependent branch).
- Every shfl.sync.* or bar.warp.sync has a full-warp immediate member mask (0xffffffff / -1) and executes under warp-uniform or CTA-uniform control flow (never inside a lane-divergent or data-dependent branch).
- The %tid.x >> 5 (and %tid.x / 32) warp-uniformity rule assumes a warp-aligned CTA launch where blockDim.x % 32 == 0 so threads sharing %tid.x >> 5 belong to the same hardware warp.
- Registers assigned under a divergent branch arm inherit that branch's divergence scope so joins/phis across divergent arms cannot synthesize false CTA- or warp-uniformity.
- When both st.shared.* and ld.shared.* appear, no CFG path from any st.shared.* to any ld.shared.* may bypass a proved full-CTA bar.sync.
- Unmodeled ordering or collective instructions (mbarrier, async copy, tcgen05, mma/wgmma, multimem, vote/match/redux/elect, setmaxnreg, griddepcontrol, volatile, atomics, fences, acquire/release/relaxed) are always rejected as UNKNOWN.
An entry with no proved warp or CTA synchronization is reported as UNKNOWN.
type Report ¶
Report is the source-level check for one entry. Barriers is populated only when the schedule is established and gives its execution order.
func Check ¶
Check parses source and reports on each kernel entry in source order. The checker assumes legal PTX for the target and does not validate operand types, address validity, memory ordering, or machine-code lowering.
Example ¶
reports, err := Check([]byte(header + ".entry k() { bar.sync 0; ret; }"))
if err != nil {
fmt.Println(err)
return
}
fmt.Println(reports[0].Status, reports[0].Barriers[0].ID)
Output: CHECKED 0