dutycycle

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: 4 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 dutycycle computes active and idle GPU duty-cycle intervals from PM sampling streams.

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

View Source
const KernelName = "duty_mma"

KernelName is the name of the kernel in Source.

View Source
const Source = `` /* 2073-byte string literal not displayed */

Source is the CUDA C duty-cycle kernel:

duty_mma(u64 *start, u64 window_ns, u64 period_ns, u64 busy_ns, float *sink)

*start must be zero before the launch; the first block to run stores %globaltimer there, and every block times its window and its periods from it. Launch at most as many blocks as are resident at once, so that none starts after the window ends.

Variables

View Source
var DefaultTolerance = Tolerance{Track: 0.1, Idle: 0.05}

DefaultTolerance is ±0.1 tracking and an idle reading below 5% of full.

View Source
var ErrNotTracking = errors.New("dutycycle: counter does not track the duty cycle")

ErrNotTracking reports a counter reading that does not follow the duty cycle it was given.

Functions

func Check

func Check(points []Point, idle float64, tol Tolerance) error

Check reports whether points, read with the kernel running, and idle, read with no kernel resident, track their set fractions within tol. It needs a point at fraction 1 to normalize by, and one at or below 0.5 so that a counter stuck near full cannot pass.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/nvidia/x/obs/cuptix/dutycycle"
)

func main() {
	// A tensor-pipe counter that follows the kernel, then one that reports
	// how long the sampling range was open.
	pipe := []dutycycle.Point{{Set: 1, Measured: 61.8}, {Set: 0.5, Measured: 31.2}, {Set: 0, Measured: 0.3}}
	open := []dutycycle.Point{{Set: 1, Measured: 99.9}, {Set: 0.5, Measured: 99.8}, {Set: 0, Measured: 99.9}}
	fmt.Println(dutycycle.Check(pipe, 0.1, dutycycle.DefaultTolerance))
	fmt.Println(dutycycle.Check(open, 0, dutycycle.DefaultTolerance))
}
Output:
<nil>
dutycycle: counter does not track the duty cycle: fraction 0.50 reads 0.999 of full

func Mean

func Mean(samples []Interval, from, to uint64) (float64, int, error)

Mean returns the mean value of the samples that lie wholly inside [from, to), and how many there were. It fails if there are none, or if a sample it would average is not finite.

Types

type Interval

type Interval struct {
	Start, End uint64
	Value      float64
}

An Interval is one counter sample over [Start, End) on the sampler's clock.

type Point

type Point struct {
	Set      float64
	Measured float64
}

A Point is a counter's mean reading while the kernel ran at fraction Set.

type Schedule

type Schedule struct {
	Window time.Duration
	Period time.Duration
	Busy   time.Duration
}

A Schedule sets the kernel's duty cycle: busy for Busy of every Period, for Window in all.

func Schedules

func Schedules(window, period time.Duration, fractions ...float64) ([]Schedule, error)

Schedules returns one schedule per fraction, sharing window and period.

func (Schedule) Fraction

func (s Schedule) Fraction() float64

Fraction returns the share of the window the kernel keeps the tensor pipes busy.

func (Schedule) Validate

func (s Schedule) Validate() error

Validate reports whether s is a schedule the kernel can run and a sampler can resolve: a period of at least 2µs, a busy time within it, and a window of at least 1000 periods.

type Tolerance

type Tolerance struct {
	Track float64
	Idle  float64
}

A Tolerance bounds Check: each normalized reading must lie within Track of its set fraction, and an idle device must read at most Idle of the fraction-1 reading.

Jump to

Keyboard shortcuts

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