-
Notifications
You must be signed in to change notification settings - Fork 84
Commit e8563a3
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 36b12aa commit e8563a3Copy full SHA for e8563a3
File tree
Expand file treeCollapse file tree
2 files changed
+1215
-0
lines changedFilter options
- gen/nvml
- pkg/nvml
Expand file treeCollapse file tree
2 files changed
+1215
-0
lines changed
0 commit comments