[PATCH] D81478: [OPENMP50]Codegen for scan directives in parallel for regions.

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 9 09:52:26 PDT 2020


ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, guansong, yaxunl.
Herald added a project: clang.

Added codegen for scan directives in parallel for regions.

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

  #pragma omp parallel for 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
  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
  for (0..<num_iters>) {
    red = InclusiveScan ? buffer[i] : buffer[i-1];
    <scan phase>;
  }
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81478

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/parallel_for_scan_codegen.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81478.269571.patch
Type: text/x-patch
Size: 19361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200609/b00c4fc4/attachment-0001.bin>


More information about the cfe-commits mailing list