Skip to content
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

Document how to get addresses of the underlying C objects from the low-level object bindings #126

Open
leofang opened this issue Sep 24, 2024 · 0 comments
Assignees
Labels
cuda.bindings Everything related to the cuda.bindings module documentation Improvements or additions to documentation P1 Medium priority - Should do

Comments

@leofang
Copy link
Member

leofang commented Sep 24, 2024

I am dumping @gigony's offline rants as trackable issues, since I ran into several of them a few times myself.

Today we say that "there's no object model in CUDA Python" and that "cuda.py (#70) comes to rescue". But technically it's not true. We do have low-level object wrappers such as cudaStream_t and CUcontext already. They are full-fledged Python objects, in the sense that the type bindings are implemented as Cython cdef classs. So what we really meant is that they are only meant to be used in a non-pythonic fashion, together with the low-level bindings to the C APIs.

One of the challenges with the low-level type bindings is getPtr() (example), which is a method that all low-level objects have. However, they do not behave as users would expect! For example, to get the underlying cudaStream_t pointer, one should call int(cudaStream_t) instead of cudaStream_t.getPtr(). I believe this was designed/implemented in order to shorten the time to prepare a kernel launch buffer, as instead of returning the pointer address to the actual struct/pointer getPtr() returns the pointer address to the pointer (to the struct/pointer), which can be easily copied over as a kernel argument void**.

We should at least document it, and in a parallel universe find a way to deprecate it with a better name.

@leofang leofang added documentation Improvements or additions to documentation P1 Medium priority - Should do labels Sep 24, 2024
@github-actions github-actions bot added the triage Needs the team's attention label Sep 24, 2024
@leofang leofang removed the triage Needs the team's attention label Oct 4, 2024
@leofang leofang added this to the cuda-python 12-next, 11-next milestone Oct 10, 2024
@leofang leofang assigned vzhurba01 and ksimpson-work and unassigned vzhurba01 Oct 10, 2024
@leofang leofang added the cuda.bindings Everything related to the cuda.bindings module label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda.bindings Everything related to the cuda.bindings module documentation Improvements or additions to documentation P1 Medium priority - Should do
Projects
None yet
Development

No branches or pull requests

3 participants