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 ¶
- Constants
- Variables
- func Arch(dev driver.Device) (string, error)
- func KernelName(unroll int) string
- func Method(sw Sweep) string
- func NewRecord(h Host, sw Sweep, date time.Time, points []obsmodel.BandwidthPoint) (obsmodel.BandwidthRecord, error)
- func Run(dev driver.Device, cubin []byte, sw Sweep) ([]obsmodel.BandwidthPoint, error)
- func SMCounts(total, granule, groups int) ([]int, error)
- func Summary(samples []float64) (lo, median, hi float64, err error)
- func Time(mod driver.Module, s driver.Stream, src, sink driver.DevicePtr, bytes uint64, ...) (obsmodel.BandwidthPoint, error)
- type Config
- type Host
- type Sweep
Examples ¶
Constants ¶
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 ¶
var Unrolls = []int{1, 2, 4, 8, 16}
Unrolls are the loads in flight per thread for which Source defines a kernel.
Functions ¶
func KernelName ¶
KernelName returns the name of the kernel in Source that keeps unroll loads in flight per thread.
func Method ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
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.