Skip to content

.to_numpy(copy=False) Runtime Error if Device Memory #201

Open
@ax3l

Description

@ax3l

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend: cudaSpecific to CUDA execution (GPUs)enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions