-
Notifications
You must be signed in to change notification settings - Fork 88
Add VgpuTypeIDToUint32 helper function #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: PiotrProkop <pprokop@nvidia.com>
005170c to
4871684
Compare
elezar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @PiotrProkop.
It would be good to get @klueska to also take a look at this.
pkg/nvml/cgo_helpers_static.go
Outdated
| return (*C.char)(h.Data), cgoAllocsUnknown | ||
| } | ||
|
|
||
| func VgpuTypeIdToUint32(typeId VgpuTypeId) uint32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that there are exceptions, but in general we try to expose NVML-functionality in these bindings and this goes against that a bit.
Does your example not indicate the need for a String() function off interface instead of an explicit *ToUint32 function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got impression that interface for VgpuTypeId is auto generated based on NVML lib funcs, so I wanted to propose less intrusive option. String or uint32 both works for me. I wanted to show that newer go-nvml version is missing some info that was present in older version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have looked at this a bit. What about doing something like we do for the Interface type where we have the function:
Extensions() ExtendedInterface
We could to the same for VgpuTypeId:
//go:generate moq -rm -out mock/extendedvgputypeid.go -pkg mock . ExtendedVgpuTypeId:ExtendedVgpuTypeId
type ExtendedVgpuTypeId interface {
ID() uint32
}
I've pushed two commits with a proposal on top. Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks for looking into this.
|
@klueska did you had a chance to take a look at it? where |
Signed-off-by: Evan Lezar <elezar@nvidia.com>
Signed-off-by: Evan Lezar <elezar@nvidia.com>
b240786 to
615aa61
Compare
| VgpuTypeGetName(VgpuTypeId) (string, Return) | ||
| VgpuTypeGetNumDisplayHeads(VgpuTypeId) (int, Return) | ||
| VgpuTypeGetResolution(VgpuTypeId, int) (uint32, uint32, Return) | ||
| Extensions() ExtendedInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why / how did this get generated at the bottom? The generation code sorts the functions alphabetically ...
|
|
||
| package nvml | ||
|
|
||
| func (vgpuTypeId *nvmlVgpuTypeId) Extensions() ExtendedVgpuTypeId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think vgpuTypeId doesn't have to be a pointer receiver.
| } | ||
|
|
||
| // ID returns the numeric representaion of the vgpuTypeId. | ||
| func (vgpuTypeId *nvmlVgpuTypeId) ID() uint32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think vgpuTypeId doesn't have to be a pointer receiver.
|
@PiotrProkop PEDRO!!! is this PR no longer required/needed? Or can we continue to work on it? |
This PR adds new
VgpuTypeIdToUint32helper function that allows to retrieve underlyinguint32representation ofnvmlVgpuTypeId:this makes it easier to programmatically create vgpus , for example:
where
<typeID>is this underlyinguint32.In previous versions of
go-nvmlI could just do type conversion touint32directly asdevice.GetSupportedVgpus()was returning:instead of Interface.