Skip to content

Commit 8c5dd87

Browse files
committed
Add script to generate a raw cgo-level interface for go-nvml
This interface can be used in conjunction with the standard "wrapper" interface, including the use its interface abstractions like Devices, GPUInstances, ComputeInstances, etc. It is invoked as nvml.CgoAPI.<api-call>, following the original function signatures of the C-API, where there is only a single return value and additional return values are passed as arguments. An example usage is: ``` // Start with using the CgoAPI ret := nvml.CgoAPI.Init() defer nvml.Shutdown() require.Equal(t, SUCCESS, ret, "Init should succeed") var count uint32 ret = nvml.CgoAPI.DeviceGetCount(&count) require.Equal(t, SUCCESS, ret, "DeviceGetCount should succeed") var device Device ret = nvml.CgoAPI.DeviceGetHandleByIndex(0, &device) require.Equal(t, SUCCESS, ret, "DeviceGetHandleByIndex should succeed") // Now call Device interface methods directly name, ret := device.GetName() require.Equal(t, SUCCESS, ret, "Device.GetName should succeed") t.Logf("Device.GetName: %s", name) uuid, ret := device.GetUUID() require.Equal(t, SUCCESS, ret, "Device.GetUUID should succeed") t.Logf("Device.GetUUID: %s", uuid) brand, ret := device.GetBrand() require.Equal(t, SUCCESS, ret, "Device.GetBrand should succeed") t.Logf("Device.GetBrand: %v", brand) busType, ret := device.GetBusType() require.Equal(t, SUCCESS, ret, "Device.GetBusType should succeed") t.Logf("Device.GetBusType: %v", busType) ``` Signed-off-by: Kevin Klues <[email protected]>
1 parent e02ab06 commit 8c5dd87

File tree

2 files changed

+1235
-0
lines changed

2 files changed

+1235
-0
lines changed

0 commit comments

Comments
 (0)