Skip to content

[PERF]: Converting arguments of generic int or fixed-size int (e.g. cuuint32_t) are suboptimal #1642

Description

@mdboom

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:

cdefcydriver.cuuint32_tcytensorRankiftensorRankisNone:
ptensorRank=0elifisinstance(tensorRank, (cuuint32_t,)):
ptensorRank=int(tensorRank)
else:
ptensorRank=int(cuuint32_t(tensorRank))

This can be reduced to:

cdefcydriver.cuuint32_tcytensorRankiftensorRankisNone:
ptensorRank=0else:
ptensorRank=int(tensorRank)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Low priority - Nice to havecuda.bindingsEverything related to the cuda.bindings moduleperformance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions