This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP50]Codegen for scan directive in for simd regions.
ClosedPublic

Authored by ABataev on Jun 11 2020, 7:38 AM.

Details

Summary

Added codegen for scan directives in parallel for regions.

Emits the code for the directive with inscan reductions.
Original code:

 #pragma omp for simd reduction(inscan, op : ...)
for(...) {
  <input phase>;
  #pragma omp scan (in)exclusive(...)
  <scan phase>
}

is transformed to something:

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>;
}

Diff Detail

Event Timeline

ABataev created this revision.Jun 11 2020, 7:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 11 2020, 7:38 AM
jdoerfert accepted this revision.Jun 16 2020, 11:30 AM

LGTM. Nice :)

This revision is now accepted and ready to land.Jun 16 2020, 11:30 AM
This revision was automatically updated to reflect the committed changes.