Skip to content

Retain the underlying object types when retrieving the .handle attribute #370

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

Closed
leofang opened this issue Jan 9, 2025 · 2 comments · Fixed by #463
Closed

Retain the underlying object types when retrieving the .handle attribute #370

leofang opened this issue Jan 9, 2025 · 2 comments · Fixed by #463
Assignees
Labels
breaking Breaking changes are introduced cuda.core Everything related to the cuda.core module enhancement Any code-related improvements P0 High priority - Must do!

Comments

@leofang
Copy link
Member

leofang commented Jan 9, 2025

Today we always return a Python int and erase the type information, e.g.

@property
def handle(self) -> int:
"""Return the underlying cudaStream_t pointer address as Python int."""
return int(self._mnff.handle)

However, it could be possible that users want to retain the underlying cuda.binding type so that it can be consumed in, say, Cython:

from cuda.core.experimental import Device

from cuda.bindings.runtime cimport cudaStream_t

s = Device().create_stream()

cdef cudaStream_t s_cy = s.handle

We should keep .handle's type, and add .ptr that returns the type-erased pointer address as Python int.

@leofang leofang added breaking Breaking changes are introduced cuda.core Everything related to the cuda.core module enhancement Any code-related improvements P0 High priority - Must do! labels Jan 9, 2025
@leofang leofang added this to the cuda.core beta 3 milestone Jan 9, 2025
@leofang leofang self-assigned this Jan 21, 2025
@leofang
Copy link
Member Author

leofang commented Feb 24, 2025

From #435 (comment)

FWIW I think adding ObjectCode.code (instead of Program.code) for retrieving the wrapped content makes a lot of sense. I think not having it was an overlook. Let us add it as part of #370. (ObjectCode does not have .handle, but this is close enough.)

@carterbox
Copy link
Contributor

One thing that surprised me about this change is that handle() -> obj and from_handle(int) -> obj are now asymmetric, but they use the same word "handle".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking changes are introduced cuda.core Everything related to the cuda.core module enhancement Any code-related improvements P0 High priority - Must do!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants