[OPENMP50]Codegen for reduction clauses with 'task' modifier.
Summary:
Added codegen for reduction clause with task modifier.
```
#pragma omp ... reduction(task, +: a)
{
#pragma omp ... in_reduction(+: a)
}
```
is translated into something like this:
```
#pragma omp ... reduction(+:a)
{
struct red_input_t {
void *reduce_shar;
void *reduce_orig;
size_t reduce_size;
void *reduce_init;
void *reduce_fini;
void *reduce_comb;
unsigned flags;
} r_var;
r_var.reduce_shar = &a;
r_var.reduce_orig = &original a;
r_var.reduce_size = sizeof(a);
r_var.reduce_init = [](void* l,void*){return *(int*)l=0;};
r_var.reduce_fini = nullptr;
r_var.reduce_comb = [](void* l,void* r){return *(int*)l += *(int)r;};
void *tg = __kmpc_taskred_modifier_init(<loc_addr>,<gtid>,
<flag - 0 for parallel, 1 for worksharing>,
<1 - number of reduction elements>,
&r_var);
{
#pragma omp ... in_reduction(+: a) firstprivate(tg)
...
}
__kmpc_task_reduction_modifier_fini(<loc_addr>,<gtid>,
<flag - 0 for parallel, 1 for worksharing>);
}
```
Reviewers: jdoerfert
Subscribers: yaxunl, guansong, jfb, cfe-commits, caomhin
Tags: #clang
Differential Revision: https://reviews.llvm.org/D79034
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index 2c91af3..ea21d5e 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2308,6 +2308,7 @@
// The NumClauses field was read in ReadStmtFromStream.
Record.skipInts(1);
VisitOMPExecutableDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
D->setHasCancel(Record.readInt());
}
@@ -2317,6 +2318,7 @@
void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
VisitOMPLoopDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
D->setHasCancel(Record.readInt());
}
@@ -2329,6 +2331,7 @@
// The NumClauses field was read in ReadStmtFromStream.
Record.skipInts(1);
VisitOMPExecutableDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
D->setHasCancel(Record.readInt());
}
@@ -2360,6 +2363,7 @@
void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
VisitOMPLoopDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
D->setHasCancel(Record.readInt());
}
@@ -2374,6 +2378,7 @@
// The NumClauses field was read in ReadStmtFromStream.
Record.skipInts(1);
VisitOMPExecutableDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
}
void ASTStmtReader::VisitOMPParallelSectionsDirective(
@@ -2382,6 +2387,7 @@
// The NumClauses field was read in ReadStmtFromStream.
Record.skipInts(1);
VisitOMPExecutableDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
D->setHasCancel(Record.readInt());
}
@@ -2489,12 +2495,14 @@
VisitStmt(D);
Record.skipInts(1);
VisitOMPExecutableDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
D->setHasCancel(Record.readBool());
}
void ASTStmtReader::VisitOMPTargetParallelForDirective(
OMPTargetParallelForDirective *D) {
VisitOMPLoopDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
D->setHasCancel(Record.readInt());
}
@@ -2564,6 +2572,7 @@
void ASTStmtReader::VisitOMPDistributeParallelForDirective(
OMPDistributeParallelForDirective *D) {
VisitOMPLoopDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
D->setHasCancel(Record.readInt());
}
@@ -2604,6 +2613,7 @@
void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
OMPTeamsDistributeParallelForDirective *D) {
VisitOMPLoopDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
D->setHasCancel(Record.readInt());
}
@@ -2622,6 +2632,7 @@
void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
OMPTargetTeamsDistributeParallelForDirective *D) {
VisitOMPLoopDirective(D);
+ D->setTaskReductionRefExpr(Record.readSubExpr());
D->setHasCancel(Record.readInt());
}