Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

cuda

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 temperature needs the last one's result.

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

Thanks!

like image 602
F. P. Avatar asked Dec 03 '10 12:12

F. P.


1 Answers

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

like image 155
Konrad Rudolph Avatar answered Nov 03 '22 21:11

Konrad Rudolph