Documentation
¶
Overview ¶
Package common define common variable
Package common define common types ¶
Package common this for util method
Index ¶
- Constants
- func GetDeviceTypeByChipName(chipName string) string
- func IsGreaterThanOrEqualInt32(num int64) bool
- func IsValidCardID(cardID int32) bool
- func IsValidCardIDAndDeviceID(cardID, deviceID int32) bool
- func IsValidChipInfo(chip *ChipInfo) bool
- func IsValidDevNumInCard(num int32) bool
- func IsValidDeviceID(deviceID int32) bool
- func IsValidLogicIDOrPhyID(id int32) bool
- func IsValidTemplateName(devType, templateName string) bool
- func IsValidUtilizationRate(num uint32) bool
- func IsValidVDevID(vDevID uint32) bool
- func RemoveDuplicate(list *[]string) []string
- type BoardInfo
- type CgoBaseResource
- type CgoComputingResource
- type CgoCreateVDevOut
- type CgoCreateVDevRes
- type CgoMediaResource
- type CgoSocFreeResource
- type CgoSocTotalResource
- type CgoVDevQueryInfo
- type CgoVDevQueryStru
- type ChipInfo
- type DevFaultInfo
- type DevProcInfo
- type DevProcessInfo
- type DeviceType
- type HbmInfo
- type MemoryInfo
- type VDevActivityInfo
- type VirtualDevInfo
Constants ¶
const ( // InvalidVal InvalidVal for NPU Invalid value InvalidVal = 0 // Success for interface return code Success = 0 // RetError return error when the function failed RetError = -1 // Percent constant of 100 Percent = 100 // MaxErrorCodeCount number of error codes MaxErrorCodeCount = 128 // UnRetError return unsigned int error UnRetError = math.MaxUint32 // DeviceIPLength length of device ip address DeviceIPLength = 4 // HiAIMaxCardID max card id for Ascend chip HiAIMaxCardID = math.MaxInt32 // HiAIMaxCardNum max card number HiAIMaxCardNum = 64 // HiAIMaxDeviceNum max device number HiAIMaxDeviceNum = 4 // NpuType present npu chip NpuType = 0 // ReduceOnePercent for calculation reduce one percent ReduceOnePercent = 0.01 // ReduceTenth for calculation reduce one tenth ReduceTenth = 0.1 // DefaultTemperatureWhenQueryFailed when get temperature failed, use this value DefaultTemperatureWhenQueryFailed = -275 // Ascend310 ascend 310 chip Ascend310 = "Ascend310" // Ascend310B ascend 310B chip Ascend310B = "Ascend310B" // Ascend310P ascend 310P chip Ascend310P = "Ascend310P" // Ascend910 ascend 910 chip Ascend910 = "Ascend910" // Ascend910B ascend 1980B(910B) chip Ascend910B = "Ascend910B" // Atlas200ISoc 200 soc env Atlas200ISoc = "Atlas 200I SoC A1" // NeverStopTimeout never stop interface timeout NeverStopTimeout = -1 // SubscribeAllDevice subscribe all device ID SubscribeAllDevice = -1 // MinVDevID min value of virtual device id MinVDevID = 100 // MaxVDevID max value of virtual device id MaxVDevID = 1124 )
const ( // Pattern1980B regular expression for 1980B Pattern1980B = `^910B\d{1}` // Pattern1980 regular expression for 1980 Pattern1980 = `^910B?` )
const ( // FaultRecover device fault recover FaultRecover = int8(0) // FaultOccur device fault occur FaultOccur = int8(1) // FaultOnce once device fault FaultOnce = int8(2) )
const ( // AMPMode for AMP chip work mode AMPMode = "AMP" // SMPMode for SMP chip work mode SMPMode = "SMP" // NetworkInit init status NetworkInit = 6 // NetworkSuccess chip network is healthy NetworkSuccess = 0 // MaxProcNum process number in device side MaxProcNum = 32 // UnitMB MB UnitMB float64 = 1024 * 1024 // Chip910 chip name 910 Chip910 = "910" )
const (
// BootStartFinish chip hot reset finish
BootStartFinish = 3
)
Variables ¶
This section is empty.
Functions ¶
func GetDeviceTypeByChipName ¶
GetDeviceTypeByChipName get device type by chipName
func IsGreaterThanOrEqualInt32 ¶
IsGreaterThanOrEqualInt32 check num range
func IsValidCardIDAndDeviceID ¶
IsValidCardIDAndDeviceID check two params both needs meet the requirement
func IsValidChipInfo ¶
IsValidChipInfo valid chip info is or not empty
func IsValidDevNumInCard ¶
IsValidDevNumInCard valid devNum in card
func IsValidLogicIDOrPhyID ¶
IsValidLogicIDOrPhyID valid logic id
func IsValidTemplateName ¶
IsValidTemplateName check template name meet the requirement
func IsValidUtilizationRate ¶
IsValidUtilizationRate valid utilization rate is 0-100
func IsValidVDevID ¶ added in v0.5.5
IsValidVDevID valid vir device id
func RemoveDuplicate ¶
RemoveDuplicate remove duplicate device
Types ¶
type CgoBaseResource ¶
type CgoBaseResource struct { Token uint64 TokenMax uint64 TaskTimeout uint64 VfgID uint32 VipMode uint8 Reserved []uint8 }
CgoBaseResource base resource info
type CgoComputingResource ¶
type CgoComputingResource struct { // accelator resource Aic float32 Aiv float32 Dsa uint16 Rtsq uint16 Acsq uint16 Cdqm uint16 CCore uint16 Ffts uint16 Sdma uint16 PcieDma uint16 // memory resource, MB as unit MemorySize uint64 // id resource EventID uint32 NotifyID uint32 StreamID uint32 ModelID uint32 // cpu resource TopicScheduleAicpu uint16 HostCtrlCPU uint16 HostAicpu uint16 DeviceAicpu uint16 TopicCtrlCPUSlot uint16 Reserved []uint8 }
CgoComputingResource compute resource info
type CgoCreateVDevOut ¶
type CgoCreateVDevOut struct { VDevID uint32 PcieBus uint32 PcieDevice uint32 PcieFunc uint32 VfgID uint32 Reserved []uint8 }
CgoCreateVDevOut create virtual device output info
type CgoCreateVDevRes ¶
CgoCreateVDevRes create virtual device input info
type CgoMediaResource ¶
type CgoMediaResource struct { Jpegd float32 Jpege float32 Vpc float32 Vdec float32 Pngd float32 Venc float32 Reserved []uint8 }
CgoMediaResource media resource info
type CgoSocFreeResource ¶
type CgoSocFreeResource struct { VfgNum uint32 VfgBitmap uint32 Base CgoBaseResource Computing CgoComputingResource Media CgoMediaResource }
CgoSocFreeResource soc free resource info
type CgoSocTotalResource ¶
type CgoSocTotalResource struct { VDevNum uint32 VDevID []uint32 VfgNum uint32 VfgBitmap uint32 Base CgoBaseResource Computing CgoComputingResource Media CgoMediaResource }
CgoSocTotalResource soc total resource info
type CgoVDevQueryInfo ¶
type CgoVDevQueryInfo struct { Name string Status uint32 IsContainerUsed uint32 Vfid uint32 VfgID uint32 ContainerID uint64 Base CgoBaseResource Computing CgoComputingResource Media CgoMediaResource }
CgoVDevQueryInfo virtual resource special info
type CgoVDevQueryStru ¶
type CgoVDevQueryStru struct { VDevID uint32 QueryInfo CgoVDevQueryInfo }
CgoVDevQueryStru virtual resource info
type ChipInfo ¶
type ChipInfo struct { Type string `json:"chip_type"` Name string `json:"chip_name"` Version string `json:"chip_version"` }
ChipInfo chip info
type DevFaultInfo ¶
type DevFaultInfo struct { EventID int64 LogicID int32 Severity int8 Assertion int8 AlarmRaisedTime int64 }
DevFaultInfo device's fault info
type DevProcInfo ¶
type DevProcInfo struct { Pid int32 // the total amount of memory occupied by the device side OS and allocated by the business, unit is MB MemUsage float64 }
DevProcInfo process info in device side
type DevProcessInfo ¶
type DevProcessInfo struct { DevProcArray []DevProcInfo ProcNum int32 }
DevProcessInfo device process info
type DeviceType ¶
type DeviceType int32
DeviceType device type enum
const ( // utilization // AICore Ascend310 & Ascend910 AICore DeviceType = 2 // frequency // MemoryFreq Ascend310 & Ascend310P MemoryFreq DeviceType = 1 // CtrlCpuFreq Ascend310 & Ascend910 & Ascend910B & Ascend310P CtrlCpuFreq DeviceType = 2 // HBMFreq Ascend310 & Ascend910 & Ascend910B HBMFreq DeviceType = 6 // AICoreCurrentFreq Ascend310 & Ascend910 & Ascend910B & Ascend310P AICoreCurrentFreq DeviceType = 7 // AICoreRatedFreq Ascend310 & Ascend910 & Ascend910B & Ascend310P AICoreRatedFreq = 9 // VectorCore Ascend310P VectorCore DeviceType = 12 )
type HbmInfo ¶
type HbmInfo struct { MemorySize uint64 `json:"memory_size"` // HBM total size,KB Frequency uint32 `json:"hbm_frequency"` // HBM frequency MHz Usage uint64 `json:"memory_usage"` // HBM memory usage,KB Temp int32 `json:"hbm_temperature"` // HBM temperature BandWidthUtilRate uint32 `json:"hbm_bandwidth_util"` // HBM bandwidth utilization }
HbmInfo HBM info
type MemoryInfo ¶
type MemoryInfo struct { MemorySize uint64 `json:"memory_size"` MemoryAvailable uint64 `json:"memory_available"` Frequency uint32 `json:"memory_frequency"` Utilization uint32 `json:"memory_utilization"` }
MemoryInfo memory information struct
type VDevActivityInfo ¶ added in v0.5.5
type VDevActivityInfo struct { VDevID uint32 VDevAiCoreRate uint32 VDevTotalMem uint64 VDevUsedMem uint64 VDevAiCore float64 IsVirtualDev bool }
VDevActivityInfo vNPU activity info for 310P
type VirtualDevInfo ¶
type VirtualDevInfo struct { TotalResource CgoSocTotalResource FreeResource CgoSocFreeResource VDevInfo []CgoVDevQueryStru VDevActivityInfo []VDevActivityInfo }
VirtualDevInfo virtual device infos