rapidsai / cuml

cuML - RAPIDS Machine Learning Library
https://docs.rapids.ai/api/cuml/stable/
Apache License 2.0
4.25k stars 534 forks source link

Don't presume pointers are mutually exclusive for device/host. #6128

Closed robertmaynard closed 1 week ago

robertmaynard commented 3 weeks ago

A pointer can be usable on the device and host at the same time. We can't invert is_dev_ptr() to check that something is a host pointer.

Here is the results of looking at the cudaPointerGetAttributes of different allocation types. As we can see things like cudaMallocManaged and cudaMallocHost allow the same pointer to be both host and device.

cudaPointerGetAttributes attributes malloc ptr
  is_dev_ptr  -> 0
  is_host_ptr -> 1
  memory loc  -> unregistered

cudaPointerGetAttributes attributes cudaMalloc ptr
  is_dev_ptr  -> 1
  is_host_ptr -> 0
  memory loc  -> device

cudaPointerGetAttributes attributes cudaMallocManaged cudaMemAttachGlobal ptr
  is_dev_ptr  -> 1
  is_host_ptr -> 1
  memory loc  -> managed

cudaPointerGetAttributes attributes cudaMallocManaged cudaMemAttachHost ptr
  is_dev_ptr  -> 1
  is_host_ptr -> 1
  memory loc  -> managed

cudaPointerGetAttributes attributes cudaMallocHost ptr
  is_dev_ptr  -> 1
  is_host_ptr -> 1
  memory loc  -> host
robertmaynard commented 3 weeks ago

Currently running some more manual validation checks

robertmaynard commented 2 weeks ago

/merge