Skip to content
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

Inconsistent behavior of hypre_GetPointerLocation #1138

Open
ictmay opened this issue Sep 20, 2024 · 0 comments
Open

Inconsistent behavior of hypre_GetPointerLocation #1138

ictmay opened this issue Sep 20, 2024 · 0 comments

Comments

@ictmay
Copy link

ictmay commented Sep 20, 2024

The function hypre_GetPointerLocation in src/utilities/memory.c behaves differently on CUDA and HIP builds.

The functions cudaPointerGetAttributes and hipPointerGetAttributes are unreliable at identifying host pointers that weren't obtained from the CUDA/HIP host allocators respectively. For CUDA builds there are these lines in the above mentioned function:

if (attr.type == cudaMemoryTypeUnregistered)
{
   *memory_location = hypre_MEMORY_HOST;
}

A similar set of lines should be present for HIP builds, but are not.

Both CUDA and HIP builds will return hypre_MEMORY_HOST in the event of an error. However, given an arbitrary host pointer hipPointerGetAttributes will typically not error. Instead it will return a location of unregistered, and then hypre_GetPointerLocation will return hypre_MEMORY_UNDEFINED instead of hypre_MEMORY_HOST.

On debug builds with HIP this can result in a failed assertion in hypre_CheckMemoryLocation. I observed the following sequence of events recently:

  1. Called HYPRE_IJVectorAssemble
  2. That called hypre_IJVectorAssembleParDevice
  3. That called hypre_AuxParVectorDestroy(aux_vector)
  4. That deallocates the data fields inside the aux_vector struct correctly by specifying HYPRE_MEMORY_DEVICE
  5. Deallocating the struct itself fails since it is of course on host, and the above assertion fails when hypre_GetPointerLocation can not figure out that the struct is indeed on host.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant