开发者

CUDA Beginner - Force waiting for a thread to finish before moving on

开发者 https://www.devze.com 2023-01-28 21:39 出处:网络
I am learning CUDA and I have something like this at the moment. __device__ void iterate_temperatures(int fieldSize, Atom *atoms) {

I am learning CUDA and I have something like this at the moment.

__device__ void iterate_temperatures(int fieldSize, Atom *atoms) {

  int temperature = threadIdx.x + blockDim.x * blockIdx.x;

  nAtoms = pow(fieldSize, DIMENSION);


  iterate_atoms<<< nAtoms >>>(atoms, nAtoms, temperature);
}

Thing is, each tempe开发者_StackOverflow中文版rature needs the last one's result.

How can I force each block to wait for the last one.

Thanks!


Just putting in a call to __syncthreads() should do exactly what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消