diff options
| author | Tobias Grosser <tobias@grosser.es> | 2014-11-06 19:35:21 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2014-11-06 19:35:21 +0000 |
| commit | 8b5344fda2a8db14eefc801342488a3a8374730e (patch) | |
| tree | 9495a257744dc59d1bbe0f042c1b05fccfd39954 /polly/lib/CodeGen | |
| parent | babee83257e021211277a9267cfd099a52b7e5f9 (diff) | |
| download | bcm5719-llvm-8b5344fda2a8db14eefc801342488a3a8374730e.tar.gz bcm5719-llvm-8b5344fda2a8db14eefc801342488a3a8374730e.zip | |
Explicitly annotate loops we want to run thread-parallel
We introduces a new flag -polly-parallel and use it to annotate the for-nodes in
the isl ast that we want to execute thread parallel (e.g., using OpenMP). We
previously already emmitted openmp annotations, but we did this for various
kinds of parallel loops, including some which we can not run in parallel.
With this patch we now have three annotations:
1) #pragma known-parallel [reduction]
2) #pragma omp for
3) #pragma simd
meaning:
1) loop has no loop carried dependences
2) loop will be executed thread-parallel
3) loop can possibly be vectorized
This patch introduces 1) and reduces the use of 2) to only the cases where we
will actually generate thread parallel code.
It is in preparation of openmp code generation in our isl backend.
Legacy:
- We also have a command line option -enable-polly-openmp. This option controls
the OpenMP code generation in CLooG. It will become an alias of
-polly-parallel after the CLooG code generation has been dropped.
http://reviews.llvm.org/D6142
llvm-svn: 221479
Diffstat (limited to 'polly/lib/CodeGen')
| -rw-r--r-- | polly/lib/CodeGen/IslAst.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp index 80455428edd..4b950b2867b 100644 --- a/polly/lib/CodeGen/IslAst.cpp +++ b/polly/lib/CodeGen/IslAst.cpp @@ -42,6 +42,11 @@ using namespace polly; using IslAstUserPayload = IslAstInfo::IslAstUserPayload; +static cl::opt<bool> + PollyParallel("polly-parallel", + cl::desc("Generate thread parallel code (isl codegen only)"), + cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory)); + static cl::opt<bool> UseContext("polly-ast-use-context", cl::desc("Use context"), cl::Hidden, cl::init(false), cl::ZeroOrMore, @@ -148,6 +153,7 @@ static isl_printer *cbPrintFor(__isl_take isl_printer *Printer, isl_pw_aff *DD = IslAstInfo::getMinimalDependenceDistance(Node); const std::string BrokenReductionsStr = getBrokenReductionsStr(Node); + const std::string KnownParallelStr = "#pragma known-parallel"; const std::string DepDisPragmaStr = "#pragma minimal dependence distance: "; const std::string SimdPragmaStr = "#pragma simd"; const std::string OmpPragmaStr = "#pragma omp parallel for"; @@ -158,8 +164,10 @@ static isl_printer *cbPrintFor(__isl_take isl_printer *Printer, if (IslAstInfo::isInnermostParallel(Node)) Printer = printLine(Printer, SimdPragmaStr + BrokenReductionsStr); - if (IslAstInfo::isOutermostParallel(Node)) - Printer = printLine(Printer, OmpPragmaStr + BrokenReductionsStr); + if (IslAstInfo::isExecutedInParallel(Node)) + Printer = printLine(Printer, OmpPragmaStr); + else if (IslAstInfo::isOutermostParallel(Node)) + Printer = printLine(Printer, KnownParallelStr + BrokenReductionsStr); isl_pw_aff_free(DD); return isl_ast_node_for_print(Node, Printer, Options); @@ -357,7 +365,8 @@ IslAst::IslAst(Scop *Scop, Dependences &D) : S(Scop) { isl_union_map *Schedule = isl_union_map_intersect_domain(S->getSchedule(), S->getDomains()); - if (DetectParallel || PollyVectorizerChoice != VECTORIZER_NONE) { + if (PollyParallel || DetectParallel || + PollyVectorizerChoice != VECTORIZER_NONE) { BuildInfo.Deps = &D; BuildInfo.InParallelFor = 0; @@ -444,6 +453,10 @@ bool IslAstInfo::isReductionParallel(__isl_keep isl_ast_node *Node) { return Payload && Payload->IsReductionParallel; } +bool IslAstInfo::isExecutedInParallel(__isl_keep isl_ast_node *Node) { + return PollyParallel && isOutermostParallel(Node) && !isReductionParallel(Node); +} + isl_union_map *IslAstInfo::getSchedule(__isl_keep isl_ast_node *Node) { IslAstUserPayload *Payload = getNodePayload(Node); return Payload ? isl_ast_build_get_schedule(Payload->Build) : nullptr; |

