0

The cuGetPointerAttribute() is passed a pointer to one of multiple types, filled according to the actual attribute requested. Some of those types are stated explicitly or may be deduced implicitly to deduce, but some - not so much. Specifically... what are the types to which a pointer must be passed for the attributes:

  • CU_POINTER_ATTRIBUTE_BUFFER_ID - probably a numeric ID, but what's its type?
  • CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES - a bitmask, supposedly, but how wide?

The CUDA driver API doesn't seem to answer these questions.

PS - Even for the boolean attributes it's not made clear enough whether you should pass an int* or a bool*.

einpoklum
  • 118,144
  • 57
  • 340
  • 684

1 Answers1

1

According to the documentation, the buffer id is stored as unsigned long long:

CU_POINTER_ATTRIBUTE_BUFFER_ID: Returns in *data a buffer ID which is guaranteed to be unique within the process. data must point to an unsigned long long.

When I try to pass a char* with CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES, valgrind reports an invalid write of size 8. Passing std::size_t* does not cause errors.

Similarly, using char* with CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE, reports an invalid write of size 4, which is not the case with int*

(using NVCC V11.5.119)

Abator Abetor
  • 2,345
  • 1
  • 10
  • 12
  • Missed that last bit in the documentation regarding the buffer ID. Good idea about using valgrind to check for the write size... :-) – einpoklum Dec 01 '21 at 21:41