我正在使用 OpenMP,但我遇到了错误结果的问题。
这是代码:
#pragma omp parallel shared(L,nthreads,chunk) private(tid,i,j){
tid = omp_get_thread_num();
if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("Starting matrix multiple example with %d threads\n",nthreads);
printf("Initializing matrices...\n");
}
#pragma omp for schedule (static, chunk)
for( i=0; i<SIZE_A;i++){
for( j=0; j<SIZE_B;j++){
if(A[i]==B[j]){
if(i==0 || j==0)
L[i][j]=1;
else
L[i][j] = L[i-1][j-1] + 1;
}
// or reset the matching score to 0
else
L[i][j]=0;
}
}
}
你怎么看,为什么我得到错误的结果?我应该改变什么?
非常感谢!