Remove FinalRead

The FinalRead statement represented a virtual read that is executed after the
SCoP. It was used when we verified the correctness of a schedule by checking if
it yields the same FLOW dependences as the original code. This is only works, if
we have a final read that reads all memory at the end of the SCoP.
We now switched to just checking if a schedule does not introduce negative
dependences and also consider WAW WAR dependences. This restricts the schedules
a little bit more, but we do not have any optimizer that would calculate a more
complex schedule. Hence, for now final reads are obsolete.

llvm-svn: 152319
This commit is contained in:
Tobias Grosser 2012-03-08 15:21:51 +00:00
parent 45ed487a9c
commit 3cbe5cfff3
10 changed files with 1 additions and 105 deletions

View File

@ -283,9 +283,6 @@ class ScopStmt {
BasicBlock &bb, SmallVectorImpl<Loop*> &NestLoops,
SmallVectorImpl<unsigned> &Scatter);
/// Create the finalization statement.
ScopStmt(Scop &parent, SmallVectorImpl<unsigned> &Scatter);
friend class Scop;
public:
@ -353,12 +350,6 @@ public:
/// @brief Return the SCEV for a loop dimension.
const SCEVAddRecExpr *getSCEVForDimension(unsigned Dimension) const;
/// @brief Is this statement the final read statement?
///
/// A final read statement is scheduled after all statements to model
/// that all data used in the Scop is read after the Scop.
bool isFinalRead() { return getBasicBlock() == NULL; }
/// @brief Align the parameters in the statement to the scop context
void realignParams();

View File

@ -649,45 +649,6 @@ ScopStmt::ScopStmt(Scop &parent, TempScop &tempScop,
buildAccesses(tempScop, CurRegion);
}
ScopStmt::ScopStmt(Scop &parent, SmallVectorImpl<unsigned> &Scatter)
: Parent(parent), BB(NULL), IVS(0) {
BaseName = "FinalRead";
// Build iteration domain.
std::string IterationDomainString = "{[i0] : i0 = 0}";
Domain = isl_set_read_from_str(getIslCtx(), IterationDomainString.c_str());
Domain = isl_set_set_tuple_name(Domain, getBaseName());
// Build scattering.
unsigned ScatSpace = Parent.getMaxLoopDepth() * 2 + 1;
isl_space *Space = isl_space_alloc(getIslCtx(), 0, 1, ScatSpace);
Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering");
Space = isl_space_set_tuple_name(Space, isl_dim_in, getBaseName());
Scattering = isl_map_universe(Space);
// TODO: This is incorrect. We should not use a very large number to ensure
// that this statement is executed last.
Scattering = isl_map_fix_si(Scattering, isl_dim_out, 0, 200000000);
// Build memory accesses, use SetVector to keep the order of memory accesses
// and prevent the same memory access inserted more than once.
SetVector<const Value*> BaseAddressSet;
for (Scop::const_iterator SI = Parent.begin(), SE = Parent.end(); SI != SE;
++SI) {
ScopStmt *Stmt = *SI;
for (MemoryAccessVec::const_iterator I = Stmt->memacc_begin(),
E = Stmt->memacc_end(); I != E; ++I)
BaseAddressSet.insert((*I)->getBaseAddr());
}
for (SetVector<const Value*>::iterator BI = BaseAddressSet.begin(),
BE = BaseAddressSet.end(); BI != BE; ++BI)
MemAccs.push_back(new MemoryAccess(*BI, this));
}
std::string ScopStmt::getDomainStr() const {
return stringFromIslObj(Domain);
}
@ -857,7 +818,6 @@ Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution,
// Build the iteration domain, access functions and scattering functions
// traversing the region tree.
buildScop(tempScop, getRegion(), NestLoops, Scatter, LI);
Stmts.push_back(new ScopStmt(*this, Scatter));
realignParams();
@ -942,9 +902,7 @@ __isl_give isl_union_set *Scop::getDomains() {
isl_union_set *Domain = NULL;
for (Scop::iterator SI = begin(), SE = end(); SI != SE; ++SI)
if ((*SI)->isFinalRead())
continue;
else if (!Domain)
if (!Domain)
Domain = isl_union_set_from_set((*SI)->getDomain());
else
Domain = isl_union_set_union(Domain,

View File

@ -168,10 +168,6 @@ CloogUnionDomain *Cloog::buildCloogUnionDomain() {
for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
ScopStmt *Stmt = *SI;
if (Stmt->isFinalRead())
continue;
CloogScattering *Scattering;
CloogDomain *Domain;

View File

@ -102,9 +102,6 @@ Json::Value JSONExporter::getJSON(Scop &scop) const {
for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
ScopStmt *Stmt = *SI;
if (Stmt->isFinalRead())
continue;
Json::Value statement;
statement["name"] = Stmt->getBaseName();
@ -246,12 +243,7 @@ bool JSONImporter::runOnScop(Scop &scop) {
int index = 0;
for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
ScopStmt *Stmt = *SI;
if (Stmt->isFinalRead())
continue;
Json::Value schedule = jscop["statements"][index]["schedule"];
isl_map *m = isl_map_read_from_str(S->getIslCtx(), schedule.asCString());
NewScattering[*SI] = m;
index++;
@ -274,9 +266,6 @@ bool JSONImporter::runOnScop(Scop &scop) {
for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
ScopStmt *Stmt = *SI;
if (Stmt->isFinalRead())
continue;
int memoryAccessIdx = 0;
for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(),
ME = Stmt->memacc_end(); MI != ME; ++MI) {

View File

@ -176,8 +176,6 @@ openscop_statement_p OpenScop::initializeStatement(ScopStmt *stmt) {
void OpenScop::initializeStatements() {
for (Scop::reverse_iterator SI = PollyScop->rbegin(), SE = PollyScop->rend();
SI != SE; ++SI) {
if ((*SI)->isFinalRead())
continue;
openscop_statement_p stmt = initializeStatement(*SI);
stmt->next = openscop->statement;
openscop->statement = stmt;

View File

@ -148,10 +148,6 @@ StatementToIslMapTy *readScattering(Scop *S, openscop_scop_p OScop) {
openscop_statement_p stmt = OScop->statement;
for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
if ((*SI)->isFinalRead())
continue;
if (!stmt) {
errs() << "Not enough statements available in OpenScop file\n";
delete &NewScattering;

View File

@ -120,10 +120,6 @@ scoplib_statement_p ScopLib::initializeStatement(ScopStmt *stmt) {
void ScopLib::initializeStatements() {
for (Scop::reverse_iterator SI = PollyScop->rbegin(), SE = PollyScop->rend();
SI != SE; ++SI) {
if ((*SI)->isFinalRead())
continue;
scoplib_statement_p stmt = initializeStatement(*SI);
stmt->next = scoplib->statement;
scoplib->statement = stmt;
@ -706,10 +702,6 @@ StatementToIslMapTy *readScattering(Scop *S, scoplib_scop_p OScop) {
}
for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
if ((*SI)->isFinalRead())
continue;
if (!stmt) {
errs() << "Not enough statements available in OpenScop file\n";
freeStmtToIslMap(&NewScattering);

View File

@ -168,9 +168,6 @@ bool Pocc::runOnScop(Scop &S) {
bool isSingleValued = true;
for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
if ((*SI)->isFinalRead())
continue;
isl_map *scat = (*SI)->getScattering();
isl_map *projected = isl_map_project_out(scat, isl_dim_out, lastLoop,
scatterDims - lastLoop);
@ -189,8 +186,6 @@ bool Pocc::runOnScop(Scop &S) {
// Strip mine the innermost loop.
for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
if ((*SI)->isFinalRead())
continue;
isl_map *scat = (*SI)->getScattering();
int scatDims = (*SI)->getNumScattering();
isl_space *Space = isl_space_alloc(S.getIslCtx(), S.getNumParams(),

View File

@ -104,10 +104,6 @@ static int getSingleMap(__isl_take isl_map *map, void *user) {
static void extendScattering(Scop &S, unsigned NewDimensions) {
for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
ScopStmt *Stmt = *SI;
if (Stmt->isFinalRead())
continue;
unsigned OldDimensions = Stmt->getNumScattering();
isl_space *Space;
isl_basic_map *ChangeScattering;
@ -529,10 +525,6 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) {
for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
ScopStmt *Stmt = *SI;
if (Stmt->isFinalRead())
continue;
isl_set *Domain = Stmt->getDomain();
isl_union_map *StmtBand;
StmtBand = isl_union_map_intersect_domain(isl_union_map_copy(ScheduleMap),

View File

@ -79,14 +79,3 @@ bb2: ; preds = %bb, %entry
; CHECK: [n] -> { Stmt_bb[i0] -> MemRef_k_05_reg2mem[0] };
; CHECK: WriteAccess :=
; CHECK: [n] -> { Stmt_bb[i0] -> MemRef__reg2mem[0] };
; CHECK: FinalRead
; CHECK: Domain :=
; CHECK: [n] -> { FinalRead[0] };
; CHECK: Scattering :=
; CHECK: [n] -> { FinalRead[i0] -> scattering[200000000, o1, o2] };
; CHECK: ReadAccess :=
; CHECK: [n] -> { FinalRead[i0] -> MemRef_a[o0] };
; CHECK: ReadAccess :=
; CHECK: [n] -> { FinalRead[i0] -> MemRef_k_05_reg2mem[o0] };
; CHECK: ReadAccess :=
; CHECK: -> { FinalRead[i0] -> MemRef__reg2mem[o0] };