[OPENMP50]Codegen for scan directives in parallel for simd regions.
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 18 Jun 2020 17:34:23 +0000 (13:34 -0400)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 23 Jun 2020 12:41:11 +0000 (08:41 -0400)
commitcb90e6a7c0afdc04c5882d596e8f0b06888b5344
tree25ef148c77a6968ad582ce1ecae25c2387141c7c
parent8c7775e9a734b0129d2db19b92efe245552ccb3d
[OPENMP50]Codegen for scan directives in parallel for simd regions.

Summary:
Added codegen for scan directives in parallel for simd regions.

Emits the code for the directive with inscan reductions.
Original code:
```
 #pragma omp parallel for simd reduction(inscan, op : ...)
for() {
  <input phase>;
  #pragma omp scan (in)exclusive(...)
  <scan phase>
}
```
is transformed to something:
```
 #pragma omp parallel
{
size num_iters = <num_iters>;
<type> buffer[num_iters];
 #pragma omp for simd
for (i: 0..<num_iters>) {
  <input phase>;
  buffer[i] = red;
}
 #pragma omp barrier
for (int k = 0; k != ceil(log2(num_iters)); ++k)
for (size cnt = last_iter; cnt >= pow(2, k); --k)
  buffer[i] op= buffer[i-pow(2,k)];
 #pragma omp for simd
for (0..<num_iters>) {
  red = InclusiveScan ? buffer[i] : buffer[i-1];
  <scan phase>;
}
}
```

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82115
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp [new file with mode: 0644]