[PERF]: Converting arguments of generic int or fixed-size int (e.g. cuuint32_t) are suboptimal
Open
Nobody has claimed this yet.
cuda.bindings
P2
performance
- Dominant language
- Cython
- Stars
- 3.4k
- Forks
- 329
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 116
Description
In driver, runtime and nvrtc, the conversion of an argument that accepts any Python int or None, but converts to one of the fixed-size C ints in CUDA (e.g. cuuint32_t) looks like:
cdef cydriver.cuuint32_t cytensorRank
if tensorRank is None:
ptensorRank = 0
elif isinstance(tensorRank, (cuuint32_t,)):
ptensorRank = int(tensorRank)
else:
ptensorRank = int(cuuint32_t(tensorRank))
This can be reduced to:
cdef cydriver.cuuint32_t cytensorRank
if tensorRank is None:
ptensorRank = 0
else:
ptensorRank = int(tensorRank)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the driver, runtime, and nvrtc conversion code for the isinstance-based pattern shown in the issue; start by comparing those call sites with the simplified form. Replace applicable conversions while preserving the None-to-zero behavior, then verify the affected components' existing checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100