You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[PERF]: Improve speed of returning the result pair #1638
CUresult(err) actually performs two dictionary lookups in large dictionaries. One is to find CUresult in the global dictionary of the module (cdef classes are actually Python objects so don't have a direct reference), and then to look up the enum value/name pair by the integer within the CUresult enum itself.
We can store CUresult in a cdef variable to skip the first lookup. We can also store CUresult.CUDA_SUCCESS in a cdef variable to make the "happy path" faster.
Preliminary measurements show this removes about 20% of the overhead (300us on my machine) on the #659 benchmark.
Non-backward compatible change
This approach still has the overhead of packing and unpacking the tuple everytime. We could instead do:
This would reduce the happy path to a simple C integer comparison and incref'ing the result. Unfortunately, this isn't backward compatible, and means our users would have to change their code from:
We already follow this pattern in libraries other than driver, runtime and nvrtc, so it may be worth doing this for consistency reasons as well as performance reasons.
Activity
Fix NVIDIA#1638: Faster returning of results
Fix NVIDIA#1638: Faster returning of results (NVIDIA#1647)
[PERF]: Add one more fast success path
[PERF]: Add one more fast success path (#1656)