gohlml

package module
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

gohlml

This repository provides a translation layer from HLML to Golang. The library is meant to be integrated into other modules requiring HLML access and to be set of wrappers around the C API provided by libhlml.so

Testing

To test the code, transfer the repository to a server where the Habana driver is installed and run the following:

go test

Code Cover

To validate metrics code coverage, run:

go test -cover

Documentation

Overview

Package gohlml is a Go package serves as a bridge to work with hlml C library. It allows access to native Habana device commands and information.

Index

Constants

View Source
const (

	// HlmlCriticalError indicates a critical error in the device
	HlmlCriticalError = C.HLML_EVENT_CRITICAL_ERR
	// HLDriverPath indicates on habana device dir
	HLDriverPath = "/sys/class/accel"
	// HLModulePath indicates on habana module dir
	HLModulePath = "/sys/module/habanalabs"
	// BITSPerLong repsenets 64 bits in logs
	BITSPerLong = 64
)

Variables

View Source
var (
	ErrNotIntialized      = errors.New("hlml not initialized")
	ErrInvalidArgument    = errors.New("invalid argument")
	ErrNotSupported       = errors.New("not supported")
	ErrAlreadyInitialized = errors.New("hlml already initialized")
	ErrNotFound           = errors.New("not found")
	ErrInsufficientSize   = errors.New("insufficient size")
	ErrDriverNotLoaded    = errors.New("driver not loaded")
	ErrAipIsLost          = errors.New("aip is lost")
	ErrMemoryError        = errors.New("memory error")
	ErrNoData             = errors.New("no data")
	ErrUnknownError       = errors.New("unknown error")
)

Functions

func DeleteEventSet

func DeleteEventSet(es EventSet)

func DeviceCount

func DeviceCount() (uint, error)

DeviceCount gets number of Habana devices in the system

func FWVersion

func FWVersion(idx uint) (kernel string, uboot string, err error)

FWVersion returns the firmware version for a given device

func GetDeviceTypeName added in v1.14.0

func GetDeviceTypeName() (string, error)

func InitWithLogs

func InitWithLogs() error

InitWithLogs initializes the HLML library with logging on

func Initialize

func Initialize() error

Initialize initializes the HLML library

func RegisterEventForDevice

func RegisterEventForDevice(es EventSet, event int, uuid string) error

func Shutdown

func Shutdown() error

Shutdown shutdowns the HLML library

func SystemDriverVersion

func SystemDriverVersion() (string, error)

SystemDriverVersion returns the driver version on the system

Types

type Device

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

Device struct maps to C HLML structure

func DeviceHandleByIndex

func DeviceHandleByIndex(idx uint) (Device, error)

DeviceHandleByIndex gets a handle to a particular device by index

func DeviceHandleBySerial

func DeviceHandleBySerial(serial string) (*Device, error)

DeviceHandleBySerial gets a handle to a particular device by serial number

func DeviceHandleByUUID

func DeviceHandleByUUID(uuid string) (Device, error)

DeviceHandleByUUID gets a handle to a particular device by UUIC

func (Device) BoardID

func (d Device) BoardID() (uint, error)

BoardID returns an ID for the PCB board

func (Device) ClockThrottleReasons

func (d Device) ClockThrottleReasons() (uint64, error)

ClockThrottleReasons returns current clock throttle reasons

func (Device) ECCMode added in v1.14.0

func (d Device) ECCMode() (uint, uint, error)

ECCMode retrieves the current and pending ECC modes for the device

1 - ECCMode enabled
0 - ECCMode disabled

func (Device) EnergyConsumptionCounter

func (d Device) EnergyConsumptionCounter() (uint64, error)

EnergyConsumptionCounter returns energy consumption

func (Device) HLRevision

func (d Device) HLRevision() (int, error)

HLRevision returns the revision of the HL library

func (Device) ICClockMax added in v1.14.0

func (d Device) ICClockMax() (uint, error)

ICClockMax returns the maximum IC clock frequency for a given device

func (Device) IsReplacedRowsPendingStatus added in v1.14.0

func (d Device) IsReplacedRowsPendingStatus() (int, error)

IsReplacedRowsPendingStatus return 0 (false) or 1 (true) if there are any rows need of replacement in a power cycle

func (Device) MMEClockMax added in v1.14.0

func (d Device) MMEClockMax() (uint, error)

MMEClockMax returns the maximum MME clock frequency for a given device

func (Device) MacAddressInfo added in v1.14.0

func (d Device) MacAddressInfo() (map[int]string, error)

MacAddressInfo retrieves the masks for supported ports and external ports.

func (Device) MemoryInfo

func (d Device) MemoryInfo() (uint64, uint64, uint64, error)

MemoryInfo returns the current memory usage in bytes for total, used, free

func (Device) MinorNumber

func (d Device) MinorNumber() (uint, error)

MinorNumber returns Minor number.

func (Device) ModuleID added in v1.6.1

func (d Device) ModuleID() (uint, error)

ModuleID returns the device moduleID

func (Device) Name

func (d Device) Name() (string, error)

Name returns Device Name

func (Device) NicLinkStatus added in v1.14.0

func (d Device) NicLinkStatus(port uint) (uint, error)

NicLinkStatus gets a port and checks its status. return 1 (up) or 0 (down)

func (Device) NumaNode

func (d Device) NumaNode() (*uint, error)

NumaNode returns the Numa affinity of the device or nil is no affinity.

func (Device) PCBAssemblyVersion

func (d Device) PCBAssemblyVersion() (string, error)

PCBAssemblyVersion returns the PCB Assembly info

func (Device) PCBVersion

func (d Device) PCBVersion() (string, error)

PCBVersion returns the PCB version

func (Device) PCIBus

func (d Device) PCIBus() (uint, error)

PCIBus returns the PCI bus info for a given device

func (Device) PCIBusID

func (d Device) PCIBusID() (string, error)

PCIBusID returns the PCI bus id for a given device

func (Device) PCIDomain

func (d Device) PCIDomain() (uint, error)

PCIDomain returns the PCI domain for a given device

func (Device) PCIID

func (d Device) PCIID() (uint, error)

PCIID returns the PCI id for a given device

func (Device) PCILinkSpeed

func (d Device) PCILinkSpeed() (uint, error)

PCILinkSpeed returns the current PCI link speed for a given device

func (Device) PCILinkWidth

func (d Device) PCILinkWidth() (uint, error)

PCILinkWidth returns the current PCI link width for a given device

func (Device) PCIReplayCounter

func (d Device) PCIReplayCounter() (uint, error)

PCIReplayCounter returns PCIe replay count

func (Device) PCIeLinkGeneration

func (d Device) PCIeLinkGeneration() (uint, error)

PCIeLinkGeneration returns PCIe replay count MUST run with SUDO/priviledged

func (Device) PCIeLinkWidth

func (d Device) PCIeLinkWidth() (uint, error)

PCIeLinkWidth returns PCIe link width

func (Device) PCIeRX

func (d Device) PCIeRX() (uint, error)

PCIeRX returns PCIe receive throughput

func (Device) PCIeTX

func (d Device) PCIeTX() (uint, error)

PCIeTX returns PCIe transmit throughput

func (Device) PowerManagementDefaultLimit added in v1.14.0

func (d Device) PowerManagementDefaultLimit() (uint, error)

PowerManagementDefaultLimit Retrieves default power management limit on this device, in milliwatts. Default power management limit is a power management limit that the device boots with.

func (Device) PowerUsage

func (d Device) PowerUsage() (uint, error)

PowerUsage returns the power usage in milliwatts for a given device

func (Device) ReplacedRowDoubleBitECC added in v1.14.0

func (d Device) ReplacedRowDoubleBitECC() (uint, error)

ReplacedRowDoubleBitECC returns the number of rows with double-bit ecc errors

func (Device) ReplacedRowSingleBitECC added in v1.14.0

func (d Device) ReplacedRowSingleBitECC() (uint, error)

ReplacedRowSingleBitECC returns the number of rows with single-bit ecc errors

func (Device) SOCClockInfo

func (d Device) SOCClockInfo() (uint, error)

SOCClockInfo returns the SoC clock frequency for a given device

func (Device) SOCClockMax added in v1.14.0

func (d Device) SOCClockMax() (uint, error)

SOCClockMax returns the maximum SoC clock frequency for a given device

func (Device) SerialNumber

func (d Device) SerialNumber() (string, error)

SerialNumber returns the device serial number

func (Device) TPCClockMax added in v1.14.0

func (d Device) TPCClockMax() (uint, error)

TPCClockMax returns the maximum TPC clock frequency for a given device

func (Device) TemperatureOnBoard added in v1.14.0

func (d Device) TemperatureOnBoard() (uint, error)

TemperatureOnBoard returns the temperature in celsius for a device board

func (Device) TemperatureOnChip added in v1.14.0

func (d Device) TemperatureOnChip() (uint, error)

TemperatureOnChip returns the temperature in celsius for a the device chip

func (Device) TemperatureThresholdGPU added in v1.14.0

func (d Device) TemperatureThresholdGPU() (uint, error)

TemperatureThresholdGPU Retrieves the known temperature threshold for the AIP with the specified threshold type in degrees

func (Device) TemperatureThresholdMemory added in v1.14.0

func (d Device) TemperatureThresholdMemory() (uint, error)

TemperatureThresholdMemory Retrieves the known temperature threshold for the AIP with the specified threshold type in degrees

func (Device) TemperatureThresholdShutdown added in v1.14.0

func (d Device) TemperatureThresholdShutdown() (uint, error)

TemperatureThresholdShutdown Retrieves the known temperature threshold for the AIP with the specified threshold type in degrees

func (Device) TemperatureThresholdSlowdown added in v1.14.0

func (d Device) TemperatureThresholdSlowdown() (uint, error)

TemperatureThresholdSlowdown Retrieves the known temperature threshold for the AIP with the specified threshold type in degrees

func (Device) UUID

func (d Device) UUID() (string, error)

UUID returns the unique id for a given device

func (Device) UtilizationInfo

func (d Device) UtilizationInfo() (uint, error)

UtilizationInfo returns the utilization aip rate for a given device

type Event

type Event struct {
	Serial string
	Etype  uint64
}

Event contains uuid and event type

func WaitForEvent

func WaitForEvent(es EventSet, timeout uint) (Event, error)

type EventSet

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

EventSet is a cast of the C type of the hlml event set

func NewEventSet

func NewEventSet() EventSet

type PCIInfo

type PCIInfo struct {
	BusID    string
	DeviceID uint
}

PCIInfo contains the PCI properties of the device

Jump to

Keyboard shortcuts

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