Nested loops to CUDA

后端 未结 1 482
心在旅途
心在旅途 2021-01-23 00:22

I want to port my c code to CUDA. The main computational part contains 3 for nested loops:

for (int i=0; i< Nx;i++){
  for (int j=0;j

        
1条回答
  •  时光说笑
    2021-01-23 01:19

    Many ways you can do it, One of them is:

    for (int i=blockIdx.x; i< Nx; i += gridDim.x){
      for (int j=threadIdx.y; j

    The above you would call:

    // nx,ny block dimensions
    kernel <<< dim3(nBlocks), dim3(nx, ny) >>> (...);
    

    0 讨论(0)
提交回复
热议问题