简体   繁体   English

这些 CUDA 指针属性的类型是什么?

[英]What are the types of these CUDA pointer attributes?

The cuGetPointerAttribute() is passed a pointer to one of multiple types, filled according to the actual attribute requested. cuGetPointerAttribute()传递一个指向多种类型之一的指针,根据请求的实际属性填充。 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_BUFFER_ID - 可能是数字 ID,但它的类型是什么?
  • CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES - a bitmask, supposedly, but how wide? CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES - 一个位掩码,据说,但有多宽?

The CUDA driver API doesn't seem to answer these questions. CUDA 驱动程序 API 似乎没有回答这些问题。

PS - Even for the boolean attributes it's not made clear enough whether you should pass an int* or a bool* . PS - 即使对于 boolean 属性,是否应该传递int*bool*也不够清楚。

According to the documentation, the buffer id is stored as unsigned long long:根据文档,缓冲区 id 存储为 unsigned long long:

CU_POINTER_ATTRIBUTE_BUFFER_ID: Returns in *data a buffer ID which is guaranteed to be unique within the process. CU_POINTER_ATTRIBUTE_BUFFER_ID:在 *data 中返回一个缓冲区 ID,它保证在进程中是唯一的。 data must point to an unsigned long long . data 必须指向一个 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.当我尝试使用CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES传递char*时,valgrind 报告大小为 8 的无效写入。传递std::size_t*不会导致错误。

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*同样,将char*CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE一起使用,会报告大小为 4 的无效写入,而int*则不是这种情况

(using NVCC V11.5.119) (使用 NVCC V11.5.119)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM