我有一个类似于这样的东西:
__global__ void globFunction(int *arr, int N) {
int idx = blockIdx.x* blockDim.x+ threadIdx.x;
// calculating and Writing results to arr ...
__syncthreads();
// reading values of another threads(ex i+1)
int val = arr[idx+1]; // IT IS GIVING OLD VALUE
}
int main() {
// declare array, alloc memory, copy memory, etc.
globFunction<<< 4000, 256>>>(arr, N);
// do something ...
return 0;
}
为什么我读取arr[idx+1]
的时候得到的是旧值?我已经调用了__syncthreads
,所以我期望看到更新后的值。我做错了什么?我是在读取缓存还是其他地方?