forked from OSchip/llvm-project
Refactor: Move 'isParallelFor' from codegen backend to Dependences analysis, so other passes can also use it.
llvm-svn: 130752
This commit is contained in:
parent
e79a5e65c0
commit
dbdebe28de
|
@ -31,6 +31,7 @@ struct isl_union_map;
|
|||
struct isl_union_set;
|
||||
struct isl_map;
|
||||
struct isl_set;
|
||||
struct clast_for;
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
|
@ -69,6 +70,16 @@ namespace polly {
|
|||
/// valid for the scattering domain subset given.
|
||||
bool isParallelDimension(isl_set *loopDomain, unsigned parallelDimension);
|
||||
|
||||
/// @brief Check if a loop is parallel
|
||||
///
|
||||
/// Detect if a clast_for loop can be executed in parallel.
|
||||
///
|
||||
/// @param f The clast for loop to check.
|
||||
///
|
||||
/// @return bool Returns true if the incoming clast_for statement can
|
||||
/// execute in parallel.
|
||||
bool isParallelFor(const clast_for *f);
|
||||
|
||||
bool runOnScop(Scop &S);
|
||||
void printScop(raw_ostream &OS) const;
|
||||
virtual void releaseMemory();
|
||||
|
|
|
@ -31,8 +31,9 @@
|
|||
#include "llvm/Support/CommandLine.h"
|
||||
|
||||
#include <isl/flow.h>
|
||||
#include <isl/map.h>
|
||||
#include <isl/constraint.h>
|
||||
#define CLOOG_INT_GMP 1
|
||||
#include <cloog/cloog.h>
|
||||
#include <cloog/isl/cloog.h>
|
||||
|
||||
using namespace polly;
|
||||
using namespace llvm;
|
||||
|
@ -351,6 +352,13 @@ bool Dependences::isParallelDimension(isl_set *loopDomain,
|
|||
&& isl_union_set_is_empty(nonValid_waw);
|
||||
}
|
||||
|
||||
bool Dependences::isParallelFor(const clast_for *f) {
|
||||
isl_set *loopDomain = isl_set_from_cloog_domain(f->domain);
|
||||
assert(loopDomain && "Cannot access domain of loop");
|
||||
|
||||
return isParallelDimension(loopDomain, isl_set_n_dim(loopDomain));
|
||||
}
|
||||
|
||||
void Dependences::printScop(raw_ostream &OS) const {
|
||||
OS.indent(4) << "Must dependences:\n";
|
||||
OS.indent(8) << stringFromIslObj(must_dep) << "\n";
|
||||
|
|
|
@ -826,25 +826,6 @@ public:
|
|||
Builder.SetInsertPoint(AfterBB);
|
||||
}
|
||||
|
||||
/// @brief Check if a loop is parallel
|
||||
///
|
||||
/// Detect if a clast_for loop can be executed in parallel.
|
||||
///
|
||||
/// @param f The clast for loop to check.
|
||||
bool isParallelFor(const clast_for *f) {
|
||||
isl_set *loopDomain = isl_set_from_cloog_domain(f->domain);
|
||||
assert(loopDomain && "Cannot access domain of loop");
|
||||
|
||||
bool isParallel = DP->isParallelDimension(loopDomain,
|
||||
isl_set_n_dim(loopDomain));
|
||||
|
||||
if (isParallel)
|
||||
DEBUG(dbgs() << "Parallel loop with induction variable '" << f->iterator
|
||||
<< "' found\n";);
|
||||
|
||||
return isParallel;
|
||||
}
|
||||
|
||||
/// @brief Add a new definition of an openmp subfunction.
|
||||
Function* addOpenMPSubfunction(Module *M) {
|
||||
Function *F = Builder.GetInsertBlock()->getParent();
|
||||
|
@ -1157,11 +1138,11 @@ public:
|
|||
}
|
||||
|
||||
void codegen(const clast_for *f) {
|
||||
if (Vector && isInnermostLoop(f) && isParallelFor(f)
|
||||
if (Vector && isInnermostLoop(f) && DP->isParallelFor(f)
|
||||
&& (-1 != getNumberOfIterations(f))
|
||||
&& (getNumberOfIterations(f) <= 16)) {
|
||||
codegenForVector(f);
|
||||
} else if (OpenMP && !parallelCodeGeneration && isParallelFor(f)) {
|
||||
} else if (OpenMP && !parallelCodeGeneration && DP->isParallelFor(f)) {
|
||||
parallelCodeGeneration = true;
|
||||
parallelLoops.push_back(f->iterator);
|
||||
codegenForOpenMP(f);
|
||||
|
|
Loading…
Reference in New Issue