[llvm] [OpenMP] [IR Builder] Changes to Support Scan Operation (PR #136035)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 28 01:49:57 PDT 2025
https://github.com/Meinersbur commented:
> For the above comment, I do not fully understand the design mentioned. I tried to create two lambdas in `ScanInfoInitialize` and stored it as two members (of type lambda) of the class `ScanInfo`, so the flang frontend calls these two lambdas when scan directive is lowered. However, that does not seem to simplify the design.
```
createScanLoop(LoopBodyGenCallbackTy InputPhaseCb, LoopBodyGenCallbackTy ScanPhaseCb, llvm::Value *scanVar, llvm::Type *scanType, ...)
```
It certainly makes the implementation more complicated, the question is by how much.
The reason why I think this would be preferable is that it does not the entire scan construct is built by a single call. Compared to an outer `createCanonicalScanLoops` where `createScan` has to be called inside the callback. This forces frontends to structure their CodeGen a certain way, and may overlook weird combinations in-between `createCanonicalScanLoops` and `createScan` such as `createCritical`:
```
#pragma omp for reduction(inscan,+:x)
for (int i = 0; i < n; ++i) {
#pragma omp critical
{
x += A[i];
#pragma omp scan inclusive(x)
B[i] = x;
}
}
```
My question is whether you have considered such a design and it seems now you have (and considered not worth the complexity). Given that (IMHO unfortunately) the entire OpenMP builder is already designed to have specific things happen within lambdas. your current design would not be unusual.
https://github.com/llvm/llvm-project/pull/136035
More information about the llvm-commits
mailing list