streamread

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: 12 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 streamread measures sustained device global-memory read bandwidth across configurable streaming access patterns.

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 Source = `` /* 1125-byte string literal not displayed */

Source is the CUDA C streaming-read kernel. stream_read_uU reads n16 16-byte vectors from src with __ldcs (load, evict first), U independent loads per thread issued before any is used, folds them into a register, and writes only if the result matches a value no buffer of the pattern produces, so the loads cannot be removed and almost nothing is written.

Variables

View Source
var Unrolls = []int{1, 2, 4, 8, 16}

Unrolls are the loads in flight per thread for which Source defines a kernel.

Functions

func Arch

func Arch(dev driver.Device) (string, error)

Arch returns dev's architecture as sm_XY, the form cudaroofline keys ceilings by.

func KernelName

func KernelName(unroll int) string

KernelName returns the name of the kernel in Source that keeps unroll loads in flight per thread.

func Method

func Method(sw Sweep) string

Method describes how sw measures, for [cudaroofline.BandwidthRecord.Method]. It names the source by hash, so two records with the same method string ran the same kernel.

func NewRecord

func NewRecord(h Host, sw Sweep, date time.Time, points []obsmodel.BandwidthPoint) (obsmodel.BandwidthRecord, error)

NewRecord returns the device-resident bandwidth record for points measured on h by sw at date. Its GBps is the best full-device median, and it is validated before it is returned.

func Run

func Run(dev driver.Device, cubin []byte, sw Sweep) ([]obsmodel.BandwidthPoint, error)

Run measures every (SM count, config) point of sw on dev and returns one [cudaroofline.BandwidthPoint] per point. A point on the whole device runs in the primary context. A point on fewer SMs runs in a green context of that size, and only after graph.Partitions.Verify has shown, from the device, that work on it stays on that many SMs: bandwidth from a partition that leaked is a full-device number with the wrong label.

cubin is Source compiled for dev. The caller must hold the GPU and have called driver.Init; the calling goroutine must be locked to its thread.

func SMCounts

func SMCounts(total, granule, groups int) ([]int, error)

SMCounts returns the partition sizes a k-SM sweep measures: every multiple of granule up to the groups*granule SMs the driver can place in green contexts, then the whole device.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/nvidia/x/obs/diag/streamread"
)

func main() {
	// A GB10: 48 SMs, which the driver splits into 4 groups of 8.
	ks, err := streamread.SMCounts(48, 8, 4)
	if err != nil {
		panic(err)
	}
	fmt.Println(ks)
}
Output:
[8 16 24 32 48]

func Summary

func Summary(samples []float64) (lo, median, hi float64, err error)

Summary returns the minimum, median and maximum of samples. The median of an even count is the mean of the middle two.

func Time

func Time(mod driver.Module, s driver.Stream, src, sink driver.DevicePtr, bytes uint64, sms int, c Config, runs int) (obsmodel.BandwidthPoint, error)

Time returns the bandwidth of c reading the bytes bytes at src on sms SMs: runs launches on s timed with CUDA events, after one warmup launch that is not counted. Every launch reads all of src once.

mod is Source loaded in the current context, which must own s. src may be any device-readable range of a multiple of 16 bytes, such as a device allocation or host memory registered with the device; sink is 4 writable device bytes.

Types

type Config

type Config struct {
	Block       int // threads per block, a multiple of 32
	BlocksPerSM int // blocks launched per SM the launch may use
	Unroll      int // independent 16-byte loads in flight per thread; one of Unrolls
}

A Config is one launch geometry of the streaming-read kernel. Its bytes in flight per SM are BlocksPerSM * Block * Unroll * 16.

func DefaultConfigs

func DefaultConfigs() []Config

DefaultConfigs returns the bytes-in-flight sweep the measurement runs when none is given: 256-thread blocks, 4 or 8 per SM, 1 to 16 loads in flight per thread, which spans 16 KiB to 512 KiB per SM.

func (Config) BytesInFlightPerSM

func (c Config) BytesInFlightPerSM() int

BytesInFlightPerSM returns the bytes of loads c keeps outstanding on each SM, if all its blocks are resident at once.

Example
package main

import (
	"fmt"
	"github.com/tmc/lib/nvidia/x/obs/diag/streamread"
)

func main() {
	for _, c := range []streamread.Config{
		{Block: 256, BlocksPerSM: 4, Unroll: 1},
		{Block: 256, BlocksPerSM: 8, Unroll: 8},
	} {
		fmt.Printf("%s x%d/SM: %d KiB in flight per SM\n", streamread.KernelName(c.Unroll), c.BlocksPerSM, c.BytesInFlightPerSM()>>10)
	}
}
Output:
stream_read_u1 x4/SM: 16 KiB in flight per SM
stream_read_u8 x8/SM: 256 KiB in flight per SM

func (Config) Grid

func (c Config) Grid(sms int) int

Grid returns the blocks c launches on sms SMs.

func (Config) Validate

func (c Config) Validate() error

Validate reports whether c names a kernel in Source and a legal block.

type Host

type Host struct {
	Name         string // host name
	Device       string // product name as NVML reports it
	DeviceUUID   string
	Architecture string // sm_XY
	Driver       int    // cuDriverGetVersion
	TotalSMs     int
	Commit       string // revision of the measuring code
}

A Host is the identity a record is stamped with.

type Sweep

type Sweep struct {
	BufferBytes uint64   // bytes read per timed launch; a multiple of 16
	Runs        int      // timed launches per point, after one warmup
	Configs     []Config // geometries measured at each SM count
	SMs         []int    // SM counts; see SMCounts
	Granularity graph.Granularity
}

A Sweep says what Run measures.

Jump to

Keyboard shortcuts

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