F. P.
F. P.

Reputation: 5086

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

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!

Upvotes: 5

Views: 1221

Answers (1)

Konrad Rudolph
Konrad Rudolph

Reputation: 545628

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

Upvotes: 8

Related Questions