intel_gpu_top

package
v0.0.0-...-e7f0d49 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package intel_gpu_top generates utilization statistics for an Intel GPU, using the 'intel-gpu-top' command. Currently, we support V1.17 and V1.18.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadGPUStats

func ReadGPUStats(r io.Reader) iter.Seq2[GPUStats, error]

ReadGPUStats decodes the output of "intel-gpu-top -J" and iterates through the GPUStats records.

Works with intel-gpu-top v1.17. If you want to use v1.18 (which uses a different layout), see V118toV117. This middleware converts the output back to v1.17 layout, so it can be processed by ReadGPUStats

Types

type ClientStats

type ClientStats struct {
	EngineClasses map[string]struct {
		Busy string `json:"busy"`
		Unit string `json:"unit"`
	} `json:"engine-classes"`
	Name string `json:"name"`
	Pid  string `json:"pid"`
}

ClientStats contains statistics for one client, currently using the GPU.

type EngineStats

type EngineStats struct {
	Unit string  `json:"unit"`
	Busy float64 `json:"busy"`
	Sema float64 `json:"sema"`
	Wait float64 `json:"wait"`
}

EngineStats contains the utilization of one GPU engine.

type GPUStats

type GPUStats struct {
	Engines map[string]EngineStats `json:"engines"`
	Clients map[string]ClientStats `json:"clients"`
	Period  struct {
		Unit     string  `json:"unit"`
		Duration float64 `json:"duration"`
	} `json:"period"`
	Interrupts struct {
		Unit  string  `json:"unit"`
		Count float64 `json:"count"`
	} `json:"interrupts"`
	Rc6 struct {
		Unit  string  `json:"unit"`
		Value float64 `json:"value"`
	} `json:"rc6"`
	Frequency struct {
		Unit      string  `json:"unit"`
		Requested float64 `json:"requested"`
		Actual    float64 `json:"actual"`
	} `json:"frequency"`
	Power struct {
		Unit    string  `json:"unit"`
		GPU     float64 `json:"GPU"`
		Package float64 `json:"Package"`
	} `json:"power"`
	ImcBandwidth struct {
		Unit   string  `json:"unit"`
		Reads  float64 `json:"reads"`
		Writes float64 `json:"writes"`
	} `json:"imc-bandwidth"`
}

GPUStats contains GPU utilization, as presented by intel-gpu-top

type V118toV117

type V118toV117 struct {
	Source io.Reader
	// contains filtered or unexported fields
}

V118toV117 converts the input from v1.18 of intel_gpu_top to v1.17 syntax. Specifically:

  • V1.18 generates the stats as a json array ("[" and "]").
  • V1.18 *sometimes* (?) writes commas between the stats.

This means json.Decoder will try to read in the full array, where we want to stream the individual records. V118toV117 solves this by removed the array & comma tokens, turning the data back to V1.17 layout.

func (*V118toV117) HasCompleteObject

func (r *V118toV117) HasCompleteObject() (*bytes.Buffer, bool)

func (*V118toV117) Process

func (r *V118toV117) Process(char byte)

func (*V118toV117) Read

func (r *V118toV117) Read(p []byte) (n int, err error)

Read reads from the source and extracts complete JSON objects.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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