summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmtOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-10-13 08:23:51 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-10-13 08:23:51 +0000
commitb20597810086a6314a5801f7a2cdf03fb534a461 (patch)
treea58bd883af04bbeac381c2a33ed153cb99a7ce0c /clang/lib/CodeGen/CGStmtOpenMP.cpp
parentc451a40e9d68828830ae441dec0a50b35fe6f9d9 (diff)
downloadbcm5719-llvm-b20597810086a6314a5801f7a2cdf03fb534a461.tar.gz
bcm5719-llvm-b20597810086a6314a5801f7a2cdf03fb534a461.zip
[OPENMP] Codegen for 'num_threads' clause in 'parallel' directive.
This patch generates call to "kmpc_push_num_threads(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_threads);" library function before calling "kmpc_fork_call" each time there is an associated "num_threads" clause in the "omp parallel" directive. Differential Revision: http://reviews.llvm.org/D5145 llvm-svn: 219599
Diffstat (limited to 'clang/lib/CodeGen/CGStmtOpenMP.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmtOpenMP.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index a459d07a723..2b0fb043be0 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -183,6 +183,23 @@ void CodeGenFunction::EmitOMPFirstprivateClause(
}
}
+/// \brief Emits code for OpenMP parallel directive in the parallel region.
+static void EmitOMPParallelCall(CodeGenFunction &CGF,
+ const OMPParallelDirective &S,
+ llvm::Value *OutlinedFn,
+ llvm::Value *CapturedStruct) {
+ if (auto C = S.getSingleClause(/*K*/ OMPC_num_threads)) {
+ CodeGenFunction::RunCleanupsScope NumThreadsScope(CGF);
+ auto NumThreadsClause = cast<OMPNumThreadsClause>(C);
+ auto NumThreads = CGF.EmitScalarExpr(NumThreadsClause->getNumThreads(),
+ /*IgnoreResultAssign*/ true);
+ CGF.CGM.getOpenMPRuntime().EmitOMPNumThreadsClause(
+ CGF, NumThreads, NumThreadsClause->getLocStart());
+ }
+ CGF.CGM.getOpenMPRuntime().EmitOMPParallelCall(CGF, S.getLocStart(),
+ OutlinedFn, CapturedStruct);
+}
+
void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {
auto CS = cast<CapturedStmt>(S.getAssociatedStmt());
auto CapturedStruct = GenerateCapturedStmtArgument(*CS);
@@ -192,16 +209,13 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {
auto Cond = cast<OMPIfClause>(C)->getCondition();
EmitOMPIfClause(*this, Cond, [&](bool ThenBlock) {
if (ThenBlock)
- CGM.getOpenMPRuntime().EmitOMPParallelCall(*this, S.getLocStart(),
- OutlinedFn, CapturedStruct);
+ EmitOMPParallelCall(*this, S, OutlinedFn, CapturedStruct);
else
CGM.getOpenMPRuntime().EmitOMPSerialCall(*this, S.getLocStart(),
OutlinedFn, CapturedStruct);
});
- } else {
- CGM.getOpenMPRuntime().EmitOMPParallelCall(*this, S.getLocStart(),
- OutlinedFn, CapturedStruct);
- }
+ } else
+ EmitOMPParallelCall(*this, S, OutlinedFn, CapturedStruct);
}
void CodeGenFunction::EmitOMPLoopBody(const OMPLoopDirective &S,
OpenPOWER on IntegriCloud