Documentation
¶
Overview ¶
Package cudapmpred provides SASS pm_pred per-instruction event counting and PTX %pm0..%pm7 baseline counter auditing for NVIDIA sm_121a (GB10).
On sm_121a, bits [103:102] of the 128-bit instruction encoding select hardware performance monitor event triggers (PMN, PM1, PM2, PM3). This enables zero-trampoline per-instruction event counting directly inside executing kernels without code caves or branch trampolines.
Baseline counters are read using PTX %pm0..%pm7 and pmevent instructions, which lower to CS2R.32 and PMTRIG in SASS.
This package is outside the compatibility promise of github.com/tmc/lib/nvidia. Its API may change or be removed in patch releases.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/x/isa/sass"
"github.com/tmc/lib/nvidia/x/obs/cudapmpred"
)
func main() {
// Start with a basic NOP instruction on sm_121a.
nop := sass.Encoding{
Lo: 0x0000000000007918,
Hi: 0x000e220000000000,
}
// Tag the instruction with PM1 for per-instruction hardware event counting.
tagged, err := cudapmpred.EncodePMPred(nop, cudapmpred.PM1, sass.SM121a)
if err != nil {
panic(err)
}
pred, err := cudapmpred.DecodePMPred(tagged, sass.SM121a)
if err != nil {
panic(err)
}
fmt.Println("pm_pred:", pred)
}
Output: pm_pred: PM1
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodePMPred ¶
EncodePMPred encodes the pm_pred field into enc on the specified architecture. Only sass.SM121a is calibrated for pm_pred bit positioning.
func FindNvdisasm ¶
FindNvdisasm locates the nvdisasm toolchain executable.
func PatchInstructionBytes ¶
PatchInstructionBytes patches the 16-byte SASS instruction at offset in raw.
Types ¶
type PMPred ¶
type PMPred uint8
PMPred represents the 2-bit performance monitor trigger field in sm_121a SASS. It is encoded in bits [103:102] of the 128-bit instruction word (bits [39:38] of Hi).
const ( // PMN indicates no performance monitor event trigger (default). PMN PMPred = 0 // PM1 triggers performance monitor event 1 upon instruction execution. PM1 PMPred = 1 // PM2 triggers performance monitor event 2 upon instruction execution. PM2 PMPred = 2 // PM3 triggers performance monitor event 3 upon instruction execution. PM3 PMPred = 3 )
func DecodePMPred ¶
DecodePMPred extracts the pm_pred field from enc on the specified architecture.
func ParsePMPred ¶
ParsePMPred parses a performance monitor trigger name.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/x/obs/cudapmpred"
)
func main() {
p1, _ := cudapmpred.ParsePMPred("PM1")
p2, _ := cudapmpred.ParsePMPred("2")
pNone, _ := cudapmpred.ParsePMPred("NONE")
fmt.Println(p1, p2, pNone)
}
Output: PM1 PM2 PMN
type PTXBaseline ¶
type PTXBaseline struct {
Name string // PTX identifier (%pm0, pmevent, etc.)
SASSMnemonic string // Lowered SASS mnemonic (CS2R.32, PMTRIG, etc.)
SRIndex uint8 // Special register index in SASS (100 for PM0, etc.)
BitWidth int // Counter bit width (32 or 64)
}
PTXBaseline describes an audited PTX performance counter or trigger instruction.
func AuditPTXBaselines ¶
func AuditPTXBaselines() []PTXBaseline
AuditPTXBaselines returns the audited lowering of PTX performance monitor registers and pmevent instructions on sm_121a.