Question ablout Global Memory Coalescing
Hi, Thanks for the great work, I have a question about Global Memory Coalescing.
In your code "2_kernel_global_mem_coalesce.cuh", on lines 13 and 14, your cRow and cCol variables are defined as follows:
```cpp
const int cRow = blockIdx.x * BLOCKSIZE + (threadIdx.x / BLOCKSIZE);
const int cCol = blockIdx.y * BLOCKSIZE + (threadIdx.x % BLOCKSIZE);
```
However, I came across a post by Lei Mao about Coalesced Memory Access where he uses a different indexing strategy:
```cpp
size_t const C_col_idx { blockIdx.x * blockDim.x + threadIdx.x };
size_t const C_row_idx { blockIdx.y * blockDim.y + threadIdx.y };
```
I wonder if these two methods are essentially the same or if they have differences in terms of memory coalescing and performance optimization. Could you please explain the differences between these two approaches and their impact on global memory access?
You can find the full post [here](https://leimao.github.io/article/CUDA-Matrix-Multiplication-Optimization/).
Thank you!
关闭于 2024-11-06 2 条评论