[PATCH] D81658: [OPENMP50]Codegen for scan directive in for simd regions.

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 11 07:42:05 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 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>;
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81658

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81658.270137.patch
Type: text/x-patch
Size: 19227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200611/be0b07ef/attachment-0001.bin>


More information about the cfe-commits mailing list