-
Notifications
You must be signed in to change notification settings - Fork 189
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 custom filters for processing accelerators #395
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Manuel Lorenzo <[email protected]>
106b5a7
to
6d0a25f
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.
initial review
/cc @jaypipes
#### filters | ||
The `ghw.Accelerator()` function accepts a slice of filters, of type string, as parameter | ||
in format `[<vendor>]:[<device>][:<class>]`, (same is the _lspci_ command). | ||
|
||
Some filter examples: | ||
* `::0302`. Select 3D controller cards. | ||
* `10de::0302`. Select Nvidia (`10de`) 3D controller cards (`0302`). | ||
* `1da3:1060:1200`. Select Habana Labs (`1da3`) Gaudi3 (`1060`) processing accelerator cards (`1200`). | ||
* `1002::`. Select AMD ATI hardware. | ||
|
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.
the filtering functionality is something we want, no questions about it.
I imagined it a bit higher level though. Like, pass a single function which takes a pci.Device
object and return (bool, string)
to convey if it should be accepted, and if not why. Or perhaps we can just (ab)use a error
as return value: if nil
, accept, if not err.Error()
can tell us why.
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.
something like
func Accelerator(filters ...func(dev *pci.Device) bool)
accelDev := &AcceleratorDevice{ | ||
Address: device.Address, | ||
PCIDevice: device, | ||
if len(i.DiscoveryFilters) > 0 { |
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.
the way I envisioned is that the user should be able to feed more filters in addition to the unavoidable buliltin
isAccelerator := func(dev *pci.Device) bool {}
probably using a different interface to maximize the safety: user-provided filters should never be allowed to modify the pci.Devices
passed to them (or, equivalently, any change made should be discarded)
This PR implements the feature to add a filter for hardware acceleration detection as described in issue #394.
This is just a draft, let's review it and we can change anything we feel is appropriate 😉