Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pkg/nvml/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import (
"github.com/NVIDIA/go-nvml/pkg/nvml"
)

// General untyped constants
const (
NVLINK_MAX_LINKS = nvml.NVLINK_MAX_LINKS
)

// Return constants
const (
SUCCESS = Return(nvml.SUCCESS)
Expand Down Expand Up @@ -131,3 +136,19 @@ const (
EventTypeSingleBitEccError = nvml.EventTypeSingleBitEccError
EventTypeDoubleBitEccError = nvml.EventTypeDoubleBitEccError
)

// GPU Topology enumeration
const (
TOPOLOGY_INTERNAL = GpuTopologyLevel(nvml.TOPOLOGY_INTERNAL)
TOPOLOGY_SINGLE = GpuTopologyLevel(nvml.TOPOLOGY_SINGLE)
TOPOLOGY_MULTIPLE = GpuTopologyLevel(nvml.TOPOLOGY_MULTIPLE)
TOPOLOGY_HOSTBRIDGE = GpuTopologyLevel(nvml.TOPOLOGY_HOSTBRIDGE)
TOPOLOGY_NODE = GpuTopologyLevel(nvml.TOPOLOGY_NODE)
TOPOLOGY_SYSTEM = GpuTopologyLevel(nvml.TOPOLOGY_SYSTEM)
)

// Generic enable/disable constants
const (
FEATURE_DISABLED = EnableState(nvml.FEATURE_DISABLED)
FEATURE_ENABLED = EnableState(nvml.FEATURE_ENABLED)
)
24 changes: 24 additions & 0 deletions pkg/nvml/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,27 @@ func (d nvmlDevice) GetSupportedEventTypes() (uint64, Return) {
e, r := nvml.Device(d).GetSupportedEventTypes()
return e, Return(r)
}

// GetTopologyCommonAncestor retrieves the common ancestor for two devices.
func (d nvmlDevice) GetTopologyCommonAncestor(o Device) (GpuTopologyLevel, Return) {
other, ok := o.(nvmlDevice)
if !ok {
return 0, ERROR_INVALID_ARGUMENT
}

l, r := nvml.Device(d).GetTopologyCommonAncestor(nvml.Device(other))
return GpuTopologyLevel(l), Return(r)
}

// GetNvLinkState retrieves the state of the device's NvLink for the link specified.
func (d nvmlDevice) GetNvLinkState(link int) (EnableState, Return) {
s, r := nvml.Device(d).GetNvLinkState(link)
return EnableState(s), Return(r)
}

// GetNvLinkRemotePciInfo retrieves the PCI information for the remote node on a NvLink link.
// Note: pciSubSystemId is not filled in this function and is indeterminate.
func (d nvmlDevice) GetNvLinkRemotePciInfo(link int) (PciInfo, Return) {
p, r := nvml.Device(d).GetNvLinkRemotePciInfo(link)
return PciInfo(p), Return(r)
}
132 changes: 132 additions & 0 deletions pkg/nvml/device_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions pkg/nvml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ type Device interface {
GetMigMode() (int, int, Return)
GetMinorNumber() (int, Return)
GetName() (string, Return)
GetNvLinkRemotePciInfo(int) (PciInfo, Return)
GetNvLinkState(int) (EnableState, Return)
GetPciInfo() (PciInfo, Return)
GetSupportedEventTypes() (uint64, Return)
GetTopologyCommonAncestor(Device) (GpuTopologyLevel, Return)
GetUUID() (string, Return)
IsMigDeviceHandle() (bool, Return)
RegisterEvents(uint64, EventSet) Return
Expand Down Expand Up @@ -145,3 +148,9 @@ type DeviceArchitecture nvml.DeviceArchitecture

// BrandType represents the brand of a GPU device
type BrandType nvml.BrandType

// GpuTopologyLevel represents level relationships within a system between two GPUs
type GpuTopologyLevel nvml.GpuTopologyLevel

// EnableState represents a generic enable/disable enum
type EnableState nvml.EnableState