2

在 CPU 上,我经常使用二维图像(间距线性)的“子图像”,它们只是指向“主”图像的某个 ROI。因此,对子图像的所有修改实际上也会改变“主”图像。

CUDA 中是否存在设备内存上的子图像到二维图像(间距线性)的问题?例如,可以将纹理绑定到它或纹理对象吗?NPP 例程是否正常工作?我之所以问,是因为某些例程可能需要某种对齐(缓冲区的“起始地址”)。

请注意,我主要对稳定性问题感兴趣。我想这些子图像可能会有轻微的性能损失,但这不是我主要关心的问题。

特别是,如果此处的“cudaBindTexture2D”文档中提到的缓冲区基地址的对齐限制,我会很感兴趣:

“由于硬件对纹理基地址强制要求对齐,因此 cudaBindTexture2D() 在 *offset 中返回一个字节偏移量,该偏移量必须应用于纹理提取,以便从所需的内存中读取。”

“纹理对象”(对于 CC >= 3.0 GPU)也是必需的?

4

1 回答 1

2

Any bound texture (whether via Texture Reference or Texture Object API) should satisfy the alignment requirement(s) provided by cudaGetDeviceProperties, in order to have a direct mapping between data coordinates and texture coordinates:

  1. Any bound texture should satisfy the alignment returned via textureAlignment (in bytes). Allocations provided by cudaMalloc and similar will satisfy this (for the starting address of the allocation).
  2. A 2D bound texture should (for each row in the texture) satisfy the alignment returned via texturePitchAlignment. Allocations provided by (for example) cudaMallocPitch will satisfy this.

NPP should work properly with any properly specified ROI.

Note that your document link is quite old. Current docs can be found here.

This question/answer may be of interest as well.

于 2014-09-12T18:04:47.853 回答