gpu - 如果我们在 CUDA/GPU 中为每个 warp 划分一个块,那么一个块中的所有 warp 都使用相同的共享内存
问题描述
如果我们在 CUDA/GPU 中为每个 warp 划分一个块,那么一个块中的所有 warp 都使用相同的共享内存。任何人都举一个例子或解释如何通过编码来编写它。像下面的代码是让线程确定它在网格和块中的位置。现在,我们如何将它划分为每个块的扭曲?
> @cuda.jit def my_kernel(io_array):
> # Thread id in a 1D block
> tx = cuda.threadIdx.x
> # Block id in a 1D grid
> ty = cuda.blockIdx.x
> # Block width, i.e. number of threads per block
> bw = cuda.blockDim.x
> # Compute flattened index inside the array
> pos = tx + ty * bw
> if pos < io_array.size: # Check array boundaries
> io_array[pos] *= 2 # do the computation
解决方案
推荐阅读
- macros - Macros do not allow definition of lexical variables
- wait - 显式等待使用 winappdriver 自动化 Windows 应用程序
- android - 使用 windowTranslucentNavigation 和透明 navigationBarColor 将“带状”渐变放在导航栏后面
- docker - Docker volume and host permissions
- lets-encrypt - Traefik 可以使用 HTTPS 保护多少个域,有上限吗?
- xamarin - 如何在 iOS 上的键盘类型电子邮件上插入按钮“.com”?
- javascript - 尝试从 vuejs 组件打印时样式参数不适用于 print-js
- php - 无法让 PHP lastInsertId() 使用此设置
- ios - 无法将新创建的可可豆荚添加到私有豆荚规范
- sql - 操作重复值?