Memory Classification
Memory Classification
2020 Jan 29th CookieLau
Preface
Register
Local Memory
Shared Memory
详见 014 Using Shared Memory
Global Memory
而如果比如说一个 warp 中的 threads 取连续的但不是 32-bytes 的倍数的大小的数据时候,可能多出来的不够 32-bytes 的部分 仍要 从 global memory 处拿 32-bytes,这样就有一部分的浪费,导致带宽的消耗。
Cuda 自身的 API 是很注重对齐的,比如 cudaMalloc 分配的内存都是对齐 256-bytes,所以我们在访存的时候也要注意这个特点,比如将 block thread 的size分配的合理一些,warp 的倍数,32的倍数之类的。
比如比较推荐的一种方法就是:
其实大小没有很大的影响,32的倍数即可。
Constant Memory
Texture Memory
Reference
Last updated