Open
Description
We allow users to call .to_numpy(copy=False)
on arbitrary memory.
This is fine even with pure GPU memory, to either:
- transport pointers around w/o access from the host or
- use as managed memory from the host (read/write)
For the situation that the pointer is in GPU memory and not managed, we should instead raise a runtime exception with the hint to use .to_numpy(copy=True)
, .to_cupy(copy=False)
or activate managed memory.
We can use AMReX_GpuUtility.H
for isManaged
, isDevicePtr
, isPinnedPtr
helpers. It wraps cudaPointerGetAttributes
and, once later supported, similar functions for HIP and SYCL.
https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__UNIFIED.html#group__CUDART__UNIFIED_1gd89830e17d399c064a2f3c3fa8bb4390