[clang][OpenMP] Add codegen for scope directive (#109197)
Added codegen for scope directive, enabled allocate and firstprivate clauses, and added scope directive LIT test. Testing - LIT tests (including new scope test). - OpenMP scope example test from 5.2 OpenMP API examples document. - Three executable scope tests from OpenMP_VV/sollve_vv suite.
This commit is contained in:
parent
02d34d800b
commit
d7c69c20a7
@ -420,7 +420,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs) {
|
|||||||
CGM.ErrorUnsupported(S, "OpenMP dispatch directive");
|
CGM.ErrorUnsupported(S, "OpenMP dispatch directive");
|
||||||
break;
|
break;
|
||||||
case Stmt::OMPScopeDirectiveClass:
|
case Stmt::OMPScopeDirectiveClass:
|
||||||
CGM.ErrorUnsupported(S, "scope with FE outlining");
|
EmitOMPScopeDirective(cast<OMPScopeDirective>(*S));
|
||||||
break;
|
break;
|
||||||
case Stmt::OMPMaskedDirectiveClass:
|
case Stmt::OMPMaskedDirectiveClass:
|
||||||
EmitOMPMaskedDirective(cast<OMPMaskedDirective>(*S));
|
EmitOMPMaskedDirective(cast<OMPMaskedDirective>(*S));
|
||||||
|
@ -4223,6 +4223,32 @@ void CodeGenFunction::EmitSections(const OMPExecutableDirective &S) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeGenFunction::EmitOMPScopeDirective(const OMPScopeDirective &S) {
|
||||||
|
{
|
||||||
|
// Emit code for 'scope' region
|
||||||
|
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
|
||||||
|
Action.Enter(CGF);
|
||||||
|
OMPPrivateScope PrivateScope(CGF);
|
||||||
|
(void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);
|
||||||
|
CGF.EmitOMPPrivateClause(S, PrivateScope);
|
||||||
|
CGF.EmitOMPReductionClauseInit(S, PrivateScope);
|
||||||
|
(void)PrivateScope.Privatize();
|
||||||
|
CGF.EmitStmt(S.getInnermostCapturedStmt()->getCapturedStmt());
|
||||||
|
CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_parallel);
|
||||||
|
};
|
||||||
|
auto LPCRegion =
|
||||||
|
CGOpenMPRuntime::LastprivateConditionalRAII::disable(*this, S);
|
||||||
|
OMPLexicalScope Scope(*this, S, OMPD_unknown);
|
||||||
|
CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_scope, CodeGen);
|
||||||
|
}
|
||||||
|
// Emit an implicit barrier at the end.
|
||||||
|
if (!S.getSingleClause<OMPNowaitClause>()) {
|
||||||
|
CGM.getOpenMPRuntime().emitBarrierCall(*this, S.getBeginLoc(), OMPD_scope);
|
||||||
|
}
|
||||||
|
// Check for outer lastprivate conditional update.
|
||||||
|
checkForLastprivateConditionalUpdate(*this, S);
|
||||||
|
}
|
||||||
|
|
||||||
void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {
|
void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {
|
||||||
if (CGM.getLangOpts().OpenMPIRBuilder) {
|
if (CGM.getLangOpts().OpenMPIRBuilder) {
|
||||||
llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
|
llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
|
||||||
|
@ -3823,6 +3823,7 @@ public:
|
|||||||
void EmitOMPInterchangeDirective(const OMPInterchangeDirective &S);
|
void EmitOMPInterchangeDirective(const OMPInterchangeDirective &S);
|
||||||
void EmitOMPForDirective(const OMPForDirective &S);
|
void EmitOMPForDirective(const OMPForDirective &S);
|
||||||
void EmitOMPForSimdDirective(const OMPForSimdDirective &S);
|
void EmitOMPForSimdDirective(const OMPForSimdDirective &S);
|
||||||
|
void EmitOMPScopeDirective(const OMPScopeDirective &S);
|
||||||
void EmitOMPSectionsDirective(const OMPSectionsDirective &S);
|
void EmitOMPSectionsDirective(const OMPSectionsDirective &S);
|
||||||
void EmitOMPSectionDirective(const OMPSectionDirective &S);
|
void EmitOMPSectionDirective(const OMPSectionDirective &S);
|
||||||
void EmitOMPSingleDirective(const OMPSingleDirective &S);
|
void EmitOMPSingleDirective(const OMPSingleDirective &S);
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
// RUN: %clang_cc1 -emit-llvm-only -verify -fopenmp %s
|
|
||||||
|
|
||||||
int main () {
|
|
||||||
int r = 0;
|
|
||||||
#pragma omp scope reduction(+:r) // expected-error {{cannot compile this scope with FE outlining yet}}
|
|
||||||
r++;
|
|
||||||
return r;
|
|
||||||
}
|
|
2267
clang/test/OpenMP/scope_codegen.cpp
Normal file
2267
clang/test/OpenMP/scope_codegen.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -887,6 +887,8 @@ def OMP_scope : Directive<"scope"> {
|
|||||||
let allowedClauses = [
|
let allowedClauses = [
|
||||||
VersionedClause<OMPC_Private, 51>,
|
VersionedClause<OMPC_Private, 51>,
|
||||||
VersionedClause<OMPC_Reduction, 51>,
|
VersionedClause<OMPC_Reduction, 51>,
|
||||||
|
VersionedClause<OMPC_FirstPrivate, 52>,
|
||||||
|
VersionedClause<OMPC_Allocate, 52>,
|
||||||
];
|
];
|
||||||
let allowedOnceClauses = [
|
let allowedOnceClauses = [
|
||||||
VersionedClause<OMPC_NoWait, 51>,
|
VersionedClause<OMPC_NoWait, 51>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user