Search code examples
cudathread-synchronization

Where to call __syncthreads() function in CUDA


I have some bool variable , and my each threads must work with that , So I need to synchronise them it means I need to call __syncthreads() function in my program , but I don't know where to call it.


Solution

  • __syncthreads() function is __device__ function , so you must call it from your __global__ kernel or some other __device__ function , additional __syncthreads() is a synchronization barrier primitive that only synchronizes threads in the same block.