0

I have the following nested for loops. I want to parallelize the first loop but the second loop must NOT be parallelized. So I want that each thread executes the second loop in itself, which means that second loop must be special for each thread (for each "i" in the code).

How can I do that?

#pragma omp parallel for
    for (i=k+1;i<row;i++){
        for (n=0;n<k;n++){
           // #pragma omp atomic
            dummy += L[i][n]*L[k][n];
            L[i][k] = (A[i][k] - dummy)/L[k][k];
        }
        dummy = 0;
    }
4

1 回答 1

1

omp parallel forpragma 仅适用于紧随其后的循环。i循环将分布在线程之间。在 的每次迭代中in循环将在同一个线程上执行。您的代码已经完成了您正在尝试做的事情。

于 2012-04-07T07:50:19.473 回答