This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP50]Codegen for inscan reductions in worksharing directives.
ClosedPublic

Authored by ABataev on May 14 2020, 9:30 AM.

Details

Summary

Implemented codegen for reduction clauses with inscan modifiers in
worksharing constructs.

Emits the code for the directive with inscan reductions.
The code is the following:

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

Diff Detail

Event Timeline

ABataev created this revision.May 14 2020, 9:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2020, 9:30 AM

Looks good, puzzled about the one changed mentioned below.

clang/lib/Sema/SemaOpenMP.cpp
14900

Why would we continue after this error?

ABataev marked an inline comment as done.Jun 3 2020, 1:53 PM
ABataev added inline comments.
clang/lib/Sema/SemaOpenMP.cpp
14900

The function, that uses VLAs, might be processed in Sema, but not actually used (and, thus, is not emitted and the error message won't be generated). Need to continue the normal processing as if the error is not emitted. If we leave continue in the old place, the list of the reduction variables might be empty and in this case, the reduction clause won't be built. The scan directive then diagnoses that it does not see a single reduction clause with the inscan modifier.

jdoerfert accepted this revision.Jun 3 2020, 4:10 PM

Thx for the explanation. LGTM.

This revision is now accepted and ready to land.Jun 3 2020, 4:10 PM
This revision was automatically updated to reflect the committed changes.