wire

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: 7 Imported by: 0 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 wire defines the bounded, versioned records exchanged by a CUDA capture agent and its controller.

Index

Constants

View Source
const (
	Version           uint16 = 1
	HeaderSize               = 80
	DefaultMaxPayload        = 16 << 20
	DefaultMaxRecords        = 4096
	DefaultQueueBytes        = 64 << 20
)
View Source
const (
	KindBootstrap  uint16 = 1
	KindActivity   uint16 = 2
	KindFinalized  uint16 = 3
	KindCapability uint16 = 4
	KindFailure    uint16 = 5
	KindExternal   uint16 = 6
	KindAPI        uint16 = 7
	KindHost       uint16 = 8
	KindModule     uint16 = 9
	KindPCSample   uint16 = 10
	KindGEMM       uint16 = 11
	KindWindow     uint16 = 12
	KindAPICalls   uint16 = 13
	KindArgs       uint16 = 14
	KindDiag       uint16 = 15
	// KindAPICallback is one runtime or driver API call as the callback
	// API saw it, written only under CUDAPROF_API_CALLBACKS=all.
	KindAPICallback uint16 = 16
	// KindPMSample is one periodic PM sampling metric sample or summary,
	// written only under CUDAPROF_PM_SAMPLING=1.
	KindPMSample uint16 = 17
)

Record kinds. They match the KIND_ constants in the capture agent (native/cupti_agent.c); a test in this package checks that they agree.

Variables

View Source
var (
	ErrBadMagic    = errors.New("wire: bad magic")
	ErrBadVersion  = errors.New("wire: unsupported version")
	ErrMalformed   = errors.New("wire: malformed frame")
	ErrOversize    = errors.New("wire: frame exceeds limit")
	ErrSession     = errors.New("wire: session identity mismatch")
	ErrDuplicate   = errors.New("wire: duplicate sequence")
	ErrRecordLimit = errors.New("wire: record count exceeds limit")
	ErrQueueFull   = errors.New("wire: queue full")
)

Functions

func Write

func Write(w io.Writer, r Record, l Limits) error

Write writes one complete frame. It does not retry a short write that returns no error; io.ErrShortWrite is returned in that case.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder validates framing and maintains sequence/drop accounting.

func NewDecoder

func NewDecoder(r io.Reader, l Limits) *Decoder

func (*Decoder) ExpectSession

func (d *Decoder) ExpectSession(id [16]byte)

func (*Decoder) Next

func (d *Decoder) Next() (Record, error)

Next returns the next validated record. A truncated terminal frame returns io.ErrUnexpectedEOF, allowing journal recovery to retain the valid prefix.

func (*Decoder) Stats

func (d *Decoder) Stats() Stats

type Identity

type Identity struct {
	Session    [16]byte
	Process    uint64
	Generation uint64
}

Identity distinguishes a capture session and a process generation. Process is normally a PID; Generation must change across exec or PID reuse.

type Limits

type Limits struct {
	MaxPayload, MaxRecords, MaxFrame uint32
	QueueRecords, QueueBytes         uint32
}

Limits bounds allocations and queue growth. Zero fields use package defaults.

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue is a bounded nonblocking producer queue. Push copies the payload.

func NewQueue

func NewQueue(l Limits) *Queue

func (*Queue) Close

func (q *Queue) Close()

func (*Queue) Dropped

func (q *Queue) Dropped() uint64

func (*Queue) Pop

func (q *Queue) Pop() (Record, bool)

func (*Queue) Push

func (q *Queue) Push(r Record) error

type Record

type Record struct {
	Kind uint16
	Identity
	Sequence  uint64
	Dropped   uint64
	Timestamp uint64
	Payload   []byte
}

Record is one independently framed observation. Sequence numbers start at one within each process generation. Dropped is cumulative producer loss.

Timestamp is nanoseconds on CLOCK_MONOTONIC in the producing process, and says when the observation happened rather than when the record was framed. A record carrying a CUPTI activity is stamped with that activity's own start, which CUPTI takes on the same clock because the agent registers itself as CUPTI's timestamp source; a record the agent originates -- the bootstrap, the capability, a capture-range edge, a failure, the finalized record -- is stamped when the agent wrote it. The guarantee is that those are one clock, so within a process generation a capture-range edge really does bracket the device activity recorded between its edges and the interval between any two records is a duration. External-correlation records are the exception: they observe an identifier and not an instant, and carry zero.

Three limits come with that clock. It is not comparable across processes generally, and Identity is what separates the streams. It has no relation to wall-clock time, so it cannot be joined to anything timestamped by a clock outside the process. And an agent whose CUPTI could not accept the timestamp callback leaves CUPTI on its platform default -- CLOCK_REALTIME on Linux -- which differs from CLOCK_MONOTONIC by the host's boot time; such an agent says so in its capability record (clocks_unified), and a consumer that compares timestamps across kinds must read it, because nothing in this header distinguishes the two cases.

func (Record) MarshalBinary

func (r Record) MarshalBinary(l Limits) ([]byte, error)

type Stats

type Stats struct{ Records, Bytes, Gaps, Dropped uint64 }

Stats describes validated records and observed sequence gaps.

Jump to

Keyboard shortcuts

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