bank 是CUDA中一个重要概念,是内存的访问时一种划分方式,在CPU中,访问某个地址的内存时,为了减少读写内次次数,访问地址并不是随机的,而是一次性访问bank内的内存地址,类似于内存对齐一样,一次性获取到该bank内的所有地址内存,以提高内存带宽利用率,一般CPU认为如果一个程序要访问某个内存地址时,其附近的数据也有很大概率会在接下来会被访问到。
在CUDA中 在理解bank之前,需要了解共享内存。
shared memory
shared memory为CUDA中内存模型中的一中内存模式,为一个片上内存,比全局内存(global memory)要快很多,在同一个block内的所有线程都可以访问到该内存中的数据,与local 或者global内存相比具有高带宽、低延迟的作用。
Because it is on-chip, shared memory has much higher bandwidth and much lower latency than local or global memory.
为了提高share memory的访问速度 除了在硬件上采用片上内存的方式之外,还采用了很多其他技术。其中为了提高内存带宽,共享内存被划分为相同大小的内存模型,称之为bank,,这样就可以将n个地址读写合并成n个独立的bank,这样就有效提高了带宽。
To achieve high bandwidth, shared memory is divided into equally-sized memory modules, called banks, which can be accessed simultaneously. Any memory read or write request made of n addresses that fall in n distinct memory banks can therefore be serviced simultaneously, yielding an overall bandwidth that is n times as high as the bandwidth of a single module.

本文深入解析CUDA中的Bank概念,探讨Bank冲突对性能的影响及优化策略。Bank是CUDA内存访问的重要划分方式,通过并行访问不同Bank提高内存带宽。文章详细阐述了Bank冲突的产生原因,如何避免以及CUDA提供的API来调整Bank大小。
最低0.47元/天 解锁文章
128

被折叠的 条评论
为什么被折叠?



