Skip to content

Commit f517219

Browse files
Add method IsImexCapable to Device interface
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent d3091e7 commit f517219

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pkg/nvlib/device/device.go

+28
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type Device interface {
3232
GetMigDevices() ([]MigDevice, error)
3333
GetMigProfiles() ([]MigProfile, error)
3434
GetPCIBusID() (string, error)
35+
IsImexEnabled() (bool, error)
3536
IsMigCapable() (bool, error)
3637
IsMigEnabled() (bool, error)
3738
VisitMigDevices(func(j int, m MigDevice) error) error
@@ -208,6 +209,33 @@ func (d *device) IsMigEnabled() (bool, error) {
208209
return (mode == nvml.DEVICE_MIG_ENABLE), nil
209210
}
210211

212+
// IsImexEnabled checks if a device has IMEX capabilities.
213+
func (d *device) IsImexEnabled() (bool, error) {
214+
if d.lib.hasSymbol("nvmlDeviceGetGpuFabricInfo") {
215+
_, ret := d.GetGpuFabricInfo()
216+
if ret == nvml.ERROR_NOT_SUPPORTED {
217+
return false, nil
218+
}
219+
if ret != nvml.SUCCESS {
220+
return false, fmt.Errorf("error getting GPU Fabric Info: %v", ret)
221+
}
222+
return true, nil
223+
}
224+
225+
if d.lib.hasSymbol("nvmlDeviceGetGpuFabricInfoV") {
226+
_, ret := d.GetGpuFabricInfoV().V2()
227+
if ret == nvml.ERROR_NOT_SUPPORTED {
228+
return false, nil
229+
}
230+
if ret != nvml.SUCCESS {
231+
return false, fmt.Errorf("error getting GPU Fabric Info: %v", ret)
232+
}
233+
return true, nil
234+
}
235+
236+
return false, nil
237+
}
238+
211239
// VisitMigDevices walks a top-level device and invokes a callback function for each MIG device configured on it.
212240
func (d *device) VisitMigDevices(visit func(int, MigDevice) error) error {
213241
capable, err := d.IsMigCapable()

0 commit comments

Comments
 (0)