summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorCarlo Bertolli <cbertol@us.ibm.com>2017-10-04 14:12:09 +0000
committerCarlo Bertolli <cbertol@us.ibm.com>2017-10-04 14:12:09 +0000
commitba1487ba69ef3cb5c3c8bdabab65b49200b389a9 (patch)
treee9af58083a9400bf173e7fe9abaae6d1114827f3 /clang/lib
parentcbbcd7fc1b0b368fa49ce7423894c6c49cf438da (diff)
downloadbcm5719-llvm-ba1487ba69ef3cb5c3c8bdabab65b49200b389a9.tar.gz
bcm5719-llvm-ba1487ba69ef3cb5c3c8bdabab65b49200b389a9.zip
[OpenMP] Initial implementation of teams distribute code generation
https://reviews.llvm.org/D38371 This patch implements codegen for the combined 'teams distribute" OpenMP pragma and adds regression tests for all its clauses. llvm-svn: 314905
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/OpenMPKinds.cpp4
-rw-r--r--clang/lib/CodeGen/CGStmtOpenMP.cpp34
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp4
3 files changed, 27 insertions, 15 deletions
diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 5eea4b5a5cf..b5f66e038b1 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -890,6 +890,9 @@ void clang::getOpenMPCaptureRegions(
CaptureRegions.push_back(OMPD_target);
CaptureRegions.push_back(OMPD_teams);
break;
+ case OMPD_teams_distribute:
+ CaptureRegions.push_back(OMPD_teams);
+ break;
case OMPD_teams:
case OMPD_simd:
case OMPD_for:
@@ -913,7 +916,6 @@ void clang::getOpenMPCaptureRegions(
case OMPD_taskloop_simd:
case OMPD_distribute_parallel_for_simd:
case OMPD_distribute_simd:
- case OMPD_teams_distribute:
case OMPD_teams_distribute_simd:
case OMPD_teams_distribute_parallel_for_simd:
case OMPD_teams_distribute_parallel_for:
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 2f819a14bcd..5cc14355391 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -2041,18 +2041,6 @@ void CodeGenFunction::EmitOMPTargetSimdDirective(
});
}
-void CodeGenFunction::EmitOMPTeamsDistributeDirective(
- const OMPTeamsDistributeDirective &S) {
- OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
- CGM.getOpenMPRuntime().emitInlinedDirective(
- *this, OMPD_teams_distribute,
- [&S](CodeGenFunction &CGF, PrePostActionTy &) {
- OMPLoopScope PreInitScope(CGF, S);
- CGF.EmitStmt(
- cast<CapturedStmt>(S.getAssociatedStmt())->getCapturedStmt());
- });
-}
-
void CodeGenFunction::EmitOMPTeamsDistributeSimdDirective(
const OMPTeamsDistributeSimdDirective &S) {
OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
@@ -3847,6 +3835,28 @@ void CodeGenFunction::EmitOMPTargetTeamsDirective(
emitCommonOMPTargetDirective(*this, S, CodeGen);
}
+void CodeGenFunction::EmitOMPTeamsDistributeDirective(
+ const OMPTeamsDistributeDirective &S) {
+
+ auto &&CodeGenDistribute = [&S](CodeGenFunction &CGF, PrePostActionTy &) {
+ CGF.EmitOMPDistributeLoop(S, emitOMPLoopBodyWithStopPoint, S.getInc());
+ };
+
+ // Emit teams region as a standalone region.
+ auto &&CodeGen = [&S, &CodeGenDistribute](CodeGenFunction &CGF,
+ PrePostActionTy &) {
+ OMPPrivateScope PrivateScope(CGF);
+ CGF.EmitOMPReductionClauseInit(S, PrivateScope);
+ (void)PrivateScope.Privatize();
+ CGF.CGM.getOpenMPRuntime().emitInlinedDirective(CGF, OMPD_distribute,
+ CodeGenDistribute);
+ CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_teams);
+ };
+ emitCommonOMPTeamsDirective(*this, S, OMPD_teams, CodeGen);
+ emitPostUpdateForReductionClause(*this, S,
+ [](CodeGenFunction &) { return nullptr; });
+}
+
void CodeGenFunction::EmitOMPCancellationPointDirective(
const OMPCancellationPointDirective &S) {
CGM.getOpenMPRuntime().emitCancellationPointCall(*this, S.getLocStart(),
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 81fea56033c..63ef808b3cc 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2043,7 +2043,8 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) {
case OMPD_parallel_for:
case OMPD_parallel_for_simd:
case OMPD_parallel_sections:
- case OMPD_teams: {
+ case OMPD_teams:
+ case OMPD_teams_distribute: {
QualType KmpInt32Ty = Context.getIntTypeForBitwidth(32, 1);
QualType KmpInt32PtrTy =
Context.getPointerType(KmpInt32Ty).withConst().withRestrict();
@@ -2166,7 +2167,6 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) {
case OMPD_distribute_parallel_for_simd:
case OMPD_distribute_simd:
case OMPD_distribute_parallel_for:
- case OMPD_teams_distribute:
case OMPD_teams_distribute_simd:
case OMPD_teams_distribute_parallel_for_simd:
case OMPD_teams_distribute_parallel_for:
OpenPOWER on IntegriCloud