kparzysz wrote:

> I think you're right for this particular test case, but I don't think that 
> solution works in general. Consider something like:
> 
> ```
> int arr1[N][N], arr2[N];
> 
> #pragma omp parallel for collapse(2)
> {
>   for (int i = 0; i < N; i++) {
>     arr2[i] = i;
>     for (int j = 0; j < N; j++) {
>       arr1[i][j] += arr2[i];
>     }
>   }
> }
> ```

This already looks unsafe.  Even if the collapsed nest has a form that 
preserves the correct order of execution, the reads and writes to arr1 and arr2 
will be scattered over multiple iterations.  The "parallel for" in itself 
doesn't have to respect any loop-carried dependencies.

https://github.com/llvm/llvm-project/pull/96087
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to