Skip to content

Commit

Permalink
Fix API call for GpmSampleAlloc
Browse files Browse the repository at this point in the history
A new GpmSample should be returned, not passed in by reference. As part of
this, add methods to hang of of the GpmSample type (which were missing
previously).

Signed-off-by: Kevin Klues <kklues@nvidia.com>
  • Loading branch information
klueska committed Apr 10, 2024
1 parent bd7ef9a commit 8611820
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/nvml/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ type Interface interface {
GpmMetricsGetV(MetricsGet *GpmMetricsGetType) GpmMetricsGetVType
GpmMetricsGet(MetricsGet *GpmMetricsGetType) Return
GpmSampleFree(GpmSample GpmSample) Return
GpmSampleAlloc(GpmSample *GpmSample) Return
GpmSampleAlloc() (GpmSample, Return)
GpmSampleGet(Device Device, GpmSample GpmSample) Return
GpmQueryDeviceSupportV(Device Device) GpmSupportV
GpmQueryDeviceSupport(Device Device) (GpmSupport, Return)
Expand Down
26 changes: 20 additions & 6 deletions pkg/nvml/gpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,28 @@ func (l *library) GpmSampleFree(GpmSample GpmSample) Return {
return nvmlGpmSampleFree(GpmSample)
}

func (GpmSample GpmSample) Free() Return {
return GpmSampleFree(GpmSample)
}

// nvml.GpmSampleAlloc()
func (l *library) GpmSampleAlloc(GpmSample *GpmSample) Return {
return nvmlGpmSampleAlloc(GpmSample)
func (l *library) GpmSampleAlloc() (GpmSample, Return) {
var GpmSample GpmSample
ret := nvmlGpmSampleAlloc(&GpmSample)
return GpmSample, ret
}

// nvml.GpmSampleGet()
func (l *library) GpmSampleGet(Device Device, GpmSample GpmSample) Return {
return Device.GpmSampleGet(GpmSample)
return GpmSample.Get(Device)
}

func (Device nvmlDevice) GpmSampleGet(GpmSample GpmSample) Return {
return nvmlGpmSampleGet(Device, GpmSample)
return GpmSample.Get(Device)
}

func (GpmSample GpmSample) Get(Device Device) Return {
return nvmlGpmSampleGet(Device.(nvmlDevice), GpmSample)
}

// nvml.GpmQueryDeviceSupport()
Expand Down Expand Up @@ -84,9 +94,13 @@ func (Device nvmlDevice) GpmQueryDeviceSupport() (GpmSupport, Return) {

// nvml.GpmMigSampleGet()
func (l *library) GpmMigSampleGet(Device Device, GpuInstanceId int, GpmSample GpmSample) Return {
return Device.GpmMigSampleGet(GpuInstanceId, GpmSample)
return GpmSample.MigGet(Device, GpuInstanceId)
}

func (Device nvmlDevice) GpmMigSampleGet(GpuInstanceId int, GpmSample GpmSample) Return {
return nvmlGpmMigSampleGet(Device, uint32(GpuInstanceId), GpmSample)
return GpmSample.MigGet(Device, GpuInstanceId)
}

func (GpmSample GpmSample) MigGet(Device Device, GpuInstanceId int) Return {
return nvmlGpmMigSampleGet(Device.(nvmlDevice), uint32(GpuInstanceId), GpmSample)
}

0 comments on commit 8611820

Please sign in to comment.