fix(cuda.core): declare cdef attrs for system event wrappers and decode packed gpu_id - #2606
fix(cuda.core): declare cdef attrs for system event wrappers and decode packed gpu_id#2606rluo8 wants to merge 8 commits into
Conversation
|
Hi @mdboom , this issue is about system event. Could you please help review it? |
|
mdboom
left a comment
There was a problem hiding this comment.
What is the root issue this is trying to solve?
This is making these objects mutable and they definitely shouldn't be -- their intention is to return values from the NVML API, not to set things on them.
The gpu_id / pci_id bridge in _system_events.pyx added here makes sense, though.
|
Hi @mdboom , thanks for the review. I understand your concern. The root issue is that constructing SystemEvent / SystemEvents / EventData / DeviceAttributes throws exception: these are Cython cdef class types with no dict, so undeclared self._event_data / self._attributes in init raise AttributeError. This is the reproduce script: Output: After the fix, it doesn't make the public API mutable, the cdef field is not visible from Python. Output: This looks similar to Cython’s guidance about cdef class AttributeErrors : https://docs.cython.org/en/stable/src/userguide/troubleshooting.html Unlike a regular class, cdef class has a fixed list of attributes that you can write to and you need to declare them explicitly. For example: Thanks! |
…ssing-cdef-attrs # Conflicts: # cuda_core/tests/system/test_system_device.py
…trs' into fix/system-event-missing-cdef-attrs
Description
Two issues were found when adding coverage tests (internal bug 6595639):
Missing
cdefattributes onSystemEvent,SystemEvents,EventData, andDeviceAttributes. These are Cythoncdef classtypes (no__dict__), so undeclaredself._event_data/self._attributesassignments raiseAttributeError.RegisteredSystemEvents.wait()therefore crashes as soon as a real bind/unbind event arrives.SystemEvent.devicetype mismatch. NVML's packed intgpu_id(domain[31:16] | bus[15:8] | device[7:0]), which requires an NVML-style PCI bus ID string (NVML_DEVICE_PCI_BUS_ID_FMT). Decode at the call site via_pci_bus_id_from_gpu_id.Adds regression tests for construction, packing decode, and end-to-end
SystemEvent.deviceresolution against livepci_info.Verification:
0000:c1:00.0yields
SystemEventswithgpu_id=0xC100→00000000:C1:00.0, andpost-rebind
SystemEvent.deviceresolves correctlyDeviceAttributescdef fix verified