澄清CUDA中的内存事务

时间:2012-08-10 19:36:05

标签: cuda gpu

我对CUDA编程指南4.0第5.3.2.1节中的以下陈述感到困惑 在“绩效指南”一章中。

Global memory resides in device memory and device memory is accessed
via 32-, 64-, or 128-byte memory transactions. 

These memory transactions must be naturally aligned:Only the 32-, 64- , 
128- byte segments of device memory 
that are aligned to their size (i.e. whose first address is a 
multiple of their size) can be read or written by memory 
transactions.

1) 我对设备内存的理解是,线程对设备内存的访问是未缓存的:因此,如果线程访问内存位置a[i],它将仅获取a[i]而不会获取 a[i]附近的值。所以第一个声明似乎与此相矛盾。或许我在这里误解了“记忆交易”一词的用法?

2)第二句似乎不太清楚。有人可以解释一下吗?

1 个答案:

答案 0 :(得分:4)

  1. 内存事务按每个warp 执行。因此,32字节事务是8位类型的warp大小读取,64字节事务是16位类型的warp大小读取,128字节事务是32位类型的warp大小读取。
  2. 这只意味着所有读取必须与自然字大小边界对齐。 warp不可能读取具有一个字节偏移量的128字节事务。有关详细信息,请参阅this answer