Skip to content

Fix DeviceNDArray.device_ctypes_pointer to always be ctypes#295

Merged
kkraus14 merged 1 commit intoNVIDIA:mainfrom
gmarkall:fix-device-ctypes-pointer
Jun 13, 2025
Merged

Fix DeviceNDArray.device_ctypes_pointer to always be ctypes#295
kkraus14 merged 1 commit intoNVIDIA:mainfrom
gmarkall:fix-device-ctypes-pointer

Conversation

@gmarkall
Copy link
Contributor

@gmarkall gmarkall commented Jun 13, 2025

When the NVIDIA bindings are in use, device_ctypes_pointer should always be a ctypes pointer, otherwise the interface changes depending on which set of bindings are in use. This has been a long-standing inconsistency, but it needs to be resolved.

The fundamental change is only to DeviceNDArray.device_ctypes_pointer. The associated changes are all fixups to maintain internal consistency.

This likely covers 95% of broken use cases, with the remaining small number being related to streams and events, that are both more involved to fix and less likely to be directly affected by users (because users will mostly not look directly at the stream / event handle).

When the NVIDIA bindings are in use, `device_ctypes_pointer` should
always be a ctypes pointer, otherwise the interface changes depending on
which set of bindings are in use. This has been a long-standing
inconsistency, but it needs to be resolved.

The fundamental change is only to `DeviceNDArray.device_ctypes_pointer`.
The associated changes are all fixups to maintain internal consistency.
@copy-pr-bot
Copy link

copy-pr-bot bot commented Jun 13, 2025

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@gmarkall
Copy link
Contributor Author

/ok to test

@gmarkall gmarkall added the 3 - Ready for Review Ready for review by team label Jun 13, 2025
@gmarkall gmarkall marked this pull request as ready for review June 13, 2025 15:17
@copy-pr-bot
Copy link

copy-pr-bot bot commented Jun 13, 2025

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@gmarkall gmarkall requested review from kkraus14 and leofang June 13, 2025 15:19
@gmarkall gmarkall changed the title [WIP] Fix DeviceNDArray.device_ctypes_pointer to always be ctypes Fix DeviceNDArray.device_ctypes_pointer to always be ctypes Jun 13, 2025
@kkraus14 kkraus14 merged commit 7a94cfc into NVIDIA:main Jun 13, 2025
39 checks passed
gmarkall added a commit to gmarkall/numba-cuda that referenced this pull request Jun 14, 2025
- NFC: Don't rely on `Dispatcher._compiler` API (NVIDIA#289)
- [DOCS] Improve the introduction and installation section of the documentation (NVIDIA#293)
- Fix `DeviceNDArray.device_ctypes_pointer` to always be ctypes (NVIDIA#295)
- Raise better error when `cuda.bindings` are not available (NVIDIA#294)
@gmarkall gmarkall mentioned this pull request Jun 14, 2025
gmarkall added a commit that referenced this pull request Jun 14, 2025
- NFC: Don't rely on `Dispatcher._compiler` API (#289)
- [DOCS] Improve the introduction and installation section of the documentation (#293)
- Fix `DeviceNDArray.device_ctypes_pointer` to always be ctypes (#295)
- Raise better error when `cuda.bindings` are not available (#294)
@leofang
Copy link
Member

leofang commented Jun 16, 2025

LGTM, thx Graham/Keith!

gmarkall added a commit that referenced this pull request Jul 7, 2025
…#295 (#296)

* Make `Context.handle` always be a `drvapi.cu_context` instance

It should not change based on which binding is in use.

* Attempt to make streams and events consistent

* Move `.value` access to finalizer

---------

Co-authored-by: brandon-b-miller <brmiller@nvidia.com>
gmarkall added a commit to gmarkall/numba-cuda that referenced this pull request Jul 18, 2025
- Add deadlock warnings to Stream.add_callback and Stream.async_done docstrings (NVIDIA#321)
- `MemoryPointer`: ensure `CUdeviceptr` used with NVIDIA binding (NVIDIA#328)
- Fix indexing GPUs with CUdevice object (NVIDIA#319)
- Fix bindings: consistency of contexts, streams, and events, similar to NVIDIA#295 (NVIDIA#296)
- Fix nvrtc resolution when CUDA_HOME env is set (NVIDIA#314)
@gmarkall gmarkall mentioned this pull request Jul 18, 2025
gmarkall added a commit that referenced this pull request Jul 18, 2025
- Add deadlock warnings to Stream.add_callback and Stream.async_done docstrings (#321)
- `MemoryPointer`: ensure `CUdeviceptr` used with NVIDIA binding (#328)
- Fix indexing GPUs with CUdevice object (#319)
- Fix bindings: consistency of contexts, streams, and events, similar to #295 (#296)
- Fix nvrtc resolution when CUDA_HOME env is set (#314)
atmnp pushed a commit to atmnp/numba-cuda that referenced this pull request Jul 21, 2025
- Add deadlock warnings to Stream.add_callback and Stream.async_done docstrings (NVIDIA#321)
- `MemoryPointer`: ensure `CUdeviceptr` used with NVIDIA binding (NVIDIA#328)
- Fix indexing GPUs with CUdevice object (NVIDIA#319)
- Fix bindings: consistency of contexts, streams, and events, similar to NVIDIA#295 (NVIDIA#296)
- Fix nvrtc resolution when CUDA_HOME env is set (NVIDIA#314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 - Ready for Review Ready for review by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants