[clang] [llvm] [OpenMP] Diagnostic check for imperfect loop collapse (PR #96087)
Julian Brown via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 19 08:49:42 PDT 2024
jtb20 wrote:
> something like
>
> ```
> bool Init[N] = {false};
> for (int ij = 0; ij < N*N; ij++) {
> int i = ij / N, j = ij % N;
> #pragma omp critical
> if (!Init[i]) {
> arr2[i] = i;
> Init[i] = true;
> }
> arr1[i][j] += arr2[i];
> }
> ```
I don't think synthesizing a critical region inside the collapsed loop will be a win overall, and also I don't quite see how it helps in this case. A correct version would be doing something like serialising the loop, I think, which I suppose sort of bypasses the problem, but doesn't really solve it. (When would we do such a transformation? How much analysis do we need to avoid killing performance in non-contrived cases?)
https://github.com/llvm/llvm-project/pull/96087
More information about the cfe-commits
mailing list