cudas2r

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cudas2r provides a telemetry oracle for NVIDIA SASS special registers (SR 0..255) accessible via S2R, CS2R, and S2UR instructions on sm_121a (GB10).

Special registers expose hardware state, timers, thread/block identifiers, performance counters, memory bounds, and fault status. This package audits the mapping from PTX special registers to SASS SR indices and classifies each index according to measured hardware readability, hardware pending status, or hardware refusal under gpu-lock on GB10.

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/obs/cudas2r"
)

func main() {
	// Look up SR_TID.X in the 256-entry special register table.
	desc, ok := cudas2r.LookupByName("SR_TID.X")
	if !ok {
		panic("SR_TID.X not found")
	}

	fmt.Printf("%s: index=%d ptx=%s read-only=%v\n", desc.Name, desc.Index, desc.PTXName, desc.ReadOnly)
}
Output:
SR_TID.X: index=33 ptx=%tid.x read-only=true

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuditPTXSpecialRegisters

func AuditPTXSpecialRegisters() map[string]SRDescriptor

AuditPTXSpecialRegisters maps all PTX special registers to their SASS SR descriptors.

func EncodeCS2R

func EncodeCS2R(rd uint8, srIndex uint8, is64 bool, pred string, c sass.ControlCode) (sass.Encoding, error)

EncodeCS2R encodes a 128-bit sm_121a CS2R Rd, SR instruction (32-bit or 64-bit pair).

func EncodeS2R

func EncodeS2R(rd uint8, srIndex uint8, pred string, c sass.ControlCode) (sass.Encoding, error)

EncodeS2R encodes a 128-bit sm_121a S2R Rd, SR instruction.

Example
package main

import (
	"fmt"

	"github.com/tmc/lib/nvidia/x/isa/sass"
	"github.com/tmc/lib/nvidia/x/obs/cudas2r"
)

func main() {
	ctrl := sass.ControlCode{Stall: 2, Yield: true, WriteBarrier: 7, ReadBarrier: 7}
	// Encode S2R R0, SR_LANEID (index 0).
	enc, err := cudas2r.EncodeS2R(0, 0, "", ctrl)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Lo=%#016x selector=%d\n", enc.Lo, (enc.Hi>>8)&0xff)
}
Output:
Lo=0x0000000000007919 selector=0

func EncodeS2UR

func EncodeS2UR(urd uint8, srIndex uint8, pred string, c sass.ControlCode) (sass.Encoding, error)

EncodeS2UR encodes a 128-bit sm_121a S2UR URd, SR instruction.

func FindNvdisasm

func FindNvdisasm() (string, error)

FindNvdisasm locates the nvdisasm toolchain executable.

func VerifyEncodingNvdisasm

func VerifyEncodingNvdisasm(enc sass.Encoding) (string, error)

VerifyEncodingNvdisasm verifies that enc disassembles into a valid sm_120 instruction using host nvdisasm -b SM120 -hex prior to GPU launch.

Types

type SRDescriptor

type SRDescriptor struct {
	Index       uint8
	Name        string
	PTXName     string
	ReadOnly    bool
	S2R         bool
	S2UR        bool
	CS2R        bool
	Status      Status
	Description string
}

SRDescriptor describes one SASS special register index (0..255).

func LookupByIndex

func LookupByIndex(index uint8) SRDescriptor

LookupByIndex returns the descriptor for special register index.

func LookupByName

func LookupByName(name string) (SRDescriptor, bool)

LookupByName returns the descriptor for special register name (SASS or PTX).

func Table

func Table() [256]SRDescriptor

Table returns the complete 256-entry table of sm_121a special registers.

type Status

type Status string

Status represents the qualification status of a special register.

const (
	// StatusMeasured indicates the special register has been verified on hardware.
	StatusMeasured Status = "measured"

	// StatusUnsupported indicates the hardware or toolchain rejects reading this register.
	StatusUnsupported Status = "ErrUnsupported"

	// StatusHardwarePending indicates the register has not yet been probed on this target.
	StatusHardwarePending Status = "ErrHardwarePending"

	// StatusUnmeasured indicates the test executed without reading this counter.
	StatusUnmeasured Status = "Unmeasured"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL