-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add VgpuTypeIDToUint32 helper function #129
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: PiotrProkop <[email protected]>
005170c
to
4871684
Compare
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.
@@ -73,3 +73,7 @@ func unpackPCharString(str string) (*C.char, *struct{}) { | |||
h := (*stringHeader)(unsafe.Pointer(&str)) | |||
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.
@klueska did you had a chance to take a look at it?
where
|
This PR adds new
VgpuTypeIdToUint32
helper function that allows to retrieve underlyinguint32
representation ofnvmlVgpuTypeId
:this makes it easier to programmatically create vgpus , for example:
where
<typeID>
is this underlyinguint32
.In previous versions of
go-nvml
I could just do type conversion touint32
directly asdevice.GetSupportedVgpus()
was returning:instead of Interface.