# CUDA线程 在以下形式代码中调用kernel函数的前提下, 那每个线程的全局索引正确的是? ```C++ dim3 gridDim = blocksPerGrid; dim3 blockDim = threadsPerBlock; .... kernel<<<gridDim, blockDim>>>(a,b,c) .... ``` ## 答案 ```C++ index = threadIdx.x + blockIdx.x * blockDim; ``` ## 选项 ### A ```C++ index = threadIdx.x + blockDim; ``` ### B ```C++ index = threadIdx.x * threadDim; ``` ### C ```C++ index = blockIdx.x * blockDim; ```