forked from OSchip/llvm-project
ScopInfo: Only give away a copy of the schedule.
llvm-svn: 141256
This commit is contained in:
parent
4da8d9fc15
commit
cf3942dfa6
|
@ -295,7 +295,7 @@ public:
|
|||
/// @brief Get the scattering function of this ScopStmt.
|
||||
///
|
||||
/// @return The scattering function of this ScopStmt.
|
||||
isl_map *getScattering() const { return Scattering; }
|
||||
isl_map *getScattering() const;
|
||||
void setScattering(isl_map *scattering);
|
||||
|
||||
/// @brief Get an isl string representing this scattering.
|
||||
|
|
|
@ -106,8 +106,7 @@ bool Dependences::runOnScop(Scop &S) {
|
|||
else
|
||||
must_source = isl_union_map_add_map(must_source, accdom);
|
||||
}
|
||||
isl_map *scattering = isl_map_copy(Stmt->getScattering());
|
||||
schedule = isl_union_map_add_map(schedule, scattering);
|
||||
schedule = isl_union_map_add_map(schedule, Stmt->getScattering());
|
||||
}
|
||||
|
||||
DEBUG(
|
||||
|
@ -163,7 +162,7 @@ bool Dependences::isValidScattering(StatementToIslMapTy *NewScattering) {
|
|||
isl_map *scattering;
|
||||
|
||||
if (NewScattering->find(*SI) == NewScattering->end())
|
||||
scattering = isl_map_copy(Stmt->getScattering());
|
||||
scattering = Stmt->getScattering();
|
||||
else
|
||||
scattering = isl_map_copy((*NewScattering)[Stmt]);
|
||||
|
||||
|
@ -242,11 +241,11 @@ isl_union_map* getCombinedScheduleForSpace(Scop *scop, unsigned dimLevel) {
|
|||
|
||||
for (Scop::iterator SI = scop->begin(), SE = scop->end(); SI != SE; ++SI) {
|
||||
ScopStmt *Stmt = *SI;
|
||||
isl_map *scattering = isl_map_copy(Stmt->getScattering());
|
||||
unsigned remainingDimensions = isl_map_n_out(scattering) - dimLevel;
|
||||
scattering = isl_map_project_out(scattering, isl_dim_out, dimLevel,
|
||||
remainingDimensions);
|
||||
schedule = isl_union_map_add_map(schedule, scattering);
|
||||
unsigned remainingDimensions = Stmt->getNumScattering() - dimLevel;
|
||||
isl_map *Scattering = isl_map_project_out(Stmt->getScattering(),
|
||||
isl_dim_out, dimLevel,
|
||||
remainingDimensions);
|
||||
schedule = isl_union_map_add_map(schedule, Scattering);
|
||||
}
|
||||
|
||||
return schedule;
|
||||
|
|
|
@ -426,7 +426,7 @@ static isl_map *getEqualAndLarger(isl_space *setDomain) {
|
|||
isl_set *MemoryAccess::getStride(const isl_set *domainSubset) const {
|
||||
isl_map *accessRelation = isl_map_copy(getAccessFunction());
|
||||
isl_set *scatteringDomain = isl_set_copy(const_cast<isl_set*>(domainSubset));
|
||||
isl_map *scattering = isl_map_copy(getStatement()->getScattering());
|
||||
isl_map *scattering = getStatement()->getScattering();
|
||||
|
||||
scattering = isl_map_reverse(scattering);
|
||||
int difference = isl_map_n_in(scattering) - isl_set_n_dim(scatteringDomain);
|
||||
|
@ -512,9 +512,14 @@ void MemoryAccess::setNewAccessFunction(isl_map *newAccess) {
|
|||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
void ScopStmt::setScattering(isl_map *scattering) {
|
||||
|
||||
isl_map *ScopStmt::getScattering() const {
|
||||
return isl_map_copy(Scattering);
|
||||
}
|
||||
|
||||
void ScopStmt::setScattering(isl_map *NewScattering) {
|
||||
isl_map_free(Scattering);
|
||||
Scattering = scattering;
|
||||
Scattering = NewScattering;
|
||||
}
|
||||
|
||||
void ScopStmt::buildScattering(SmallVectorImpl<unsigned> &Scatter) {
|
||||
|
@ -784,7 +789,7 @@ std::string ScopStmt::getDomainStr() const {
|
|||
}
|
||||
|
||||
std::string ScopStmt::getScatteringStr() const {
|
||||
return stringFromIslObj(getScattering());
|
||||
return stringFromIslObj(Scattering);
|
||||
}
|
||||
|
||||
unsigned ScopStmt::getNumParams() const {
|
||||
|
|
|
@ -159,10 +159,11 @@ CloogUnionDomain *Cloog::buildCloogUnionDomain() {
|
|||
if (Stmt->isFinalRead())
|
||||
continue;
|
||||
|
||||
CloogScattering *Scattering=
|
||||
cloog_scattering_from_isl_map(isl_map_copy(Stmt->getScattering()));
|
||||
CloogDomain *Domain =
|
||||
cloog_domain_from_isl_set(Stmt->getDomain());
|
||||
CloogScattering *Scattering;
|
||||
CloogDomain *Domain;
|
||||
|
||||
Scattering = cloog_scattering_from_isl_map(Stmt->getScattering());
|
||||
Domain = cloog_domain_from_isl_set(Stmt->getDomain());
|
||||
|
||||
std::string entryName = Stmt->getBaseName();
|
||||
|
||||
|
|
|
@ -146,8 +146,11 @@ openscop_statement_p OpenScop::initializeStatement(ScopStmt *stmt) {
|
|||
// Domain & Schedule
|
||||
isl_set *domain = stmt->getDomain();
|
||||
Stmt->domain = domainToMatrix(domain);
|
||||
Stmt->schedule = scatteringToMatrix(stmt->getScattering());
|
||||
isl_map *Scattering = stmt->getScattering();
|
||||
Stmt->schedule = scatteringToMatrix(Scattering);
|
||||
isl_set_free(domain);
|
||||
isl_map_free(Scattering);
|
||||
|
||||
|
||||
// Statement name
|
||||
const char* entryName = stmt->getBaseName();
|
||||
|
|
|
@ -93,7 +93,9 @@ scoplib_statement_p ScopLib::initializeStatement(ScopStmt *stmt) {
|
|||
Stmt->domain = scoplib_matrix_list_malloc();
|
||||
Stmt->domain->elt = domainToMatrix(domain);
|
||||
Stmt->domain->next = NULL;
|
||||
Stmt->schedule = scatteringToMatrix(stmt->getScattering());
|
||||
isl_map *Scattering = stmt->getScattering;
|
||||
Stmt->schedule = scatteringToMatrix(Scattering);
|
||||
isl_map_free(Scattering);
|
||||
isl_set_free(domain);
|
||||
|
||||
// Statement name
|
||||
|
|
|
@ -179,7 +179,7 @@ bool Pocc::runOnScop(Scop &S) {
|
|||
if ((*SI)->isFinalRead())
|
||||
continue;
|
||||
|
||||
isl_map *scat = isl_map_copy((*SI)->getScattering());
|
||||
isl_map *scat = (*SI)->getScattering();
|
||||
isl_map *projected = isl_map_project_out(scat, isl_dim_out, lastLoop,
|
||||
scatterDims - lastLoop);
|
||||
|
||||
|
@ -199,11 +199,9 @@ bool Pocc::runOnScop(Scop &S) {
|
|||
for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
|
||||
if ((*SI)->isFinalRead())
|
||||
continue;
|
||||
isl_map *scat = (*SI)->getScattering();
|
||||
|
||||
int scatDims = isl_map_n_out(scat);
|
||||
isl_space *Space= isl_space_alloc(S.getCtx(), S.getNumParams(), scatDims,
|
||||
scatDims + 1);
|
||||
int scatDims = (*SI)->getNumScattering();
|
||||
isl_space *Space = isl_space_alloc(S.getCtx(), S.getNumParams(), scatDims,
|
||||
scatDims + 1);
|
||||
isl_basic_map *map = isl_basic_map_universe(isl_space_copy(Space));
|
||||
|
||||
for (int i = 0; i <= lastLoop - 1; i++) {
|
||||
|
|
|
@ -67,38 +67,41 @@ static int getSingleMap(__isl_take isl_map *map, void *user) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void extendScattering(Scop &S, unsigned scatDimensions) {
|
||||
static void extendScattering(Scop &S, unsigned NewDimensions) {
|
||||
for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
|
||||
ScopStmt *stmt = *SI;
|
||||
ScopStmt *Stmt = *SI;
|
||||
|
||||
if (stmt->isFinalRead())
|
||||
if (Stmt->isFinalRead())
|
||||
continue;
|
||||
|
||||
isl_map *scattering = stmt->getScattering();
|
||||
isl_space *Space = isl_space_alloc(isl_map_get_ctx(scattering), 0,
|
||||
isl_map_n_out(scattering), scatDimensions);
|
||||
isl_basic_map *changeScattering = isl_basic_map_universe(
|
||||
isl_space_copy(Space));
|
||||
unsigned OldDimensions = Stmt->getNumScattering();
|
||||
isl_space *Space;
|
||||
isl_basic_map *ChangeScattering;
|
||||
|
||||
Space = isl_space_alloc(Stmt->getIslCtx(), 0, OldDimensions, NewDimensions);
|
||||
ChangeScattering = isl_basic_map_universe(isl_space_copy(Space));
|
||||
isl_local_space *LocalSpace = isl_local_space_from_space(Space);
|
||||
|
||||
for (unsigned i = 0; i < isl_map_n_out(scattering); i++) {
|
||||
for (unsigned i = 0; i < OldDimensions; i++) {
|
||||
isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LocalSpace));
|
||||
isl_constraint_set_coefficient_si(c, isl_dim_in, i, 1);
|
||||
isl_constraint_set_coefficient_si(c, isl_dim_out, i, -1);
|
||||
changeScattering = isl_basic_map_add_constraint(changeScattering, c);
|
||||
ChangeScattering = isl_basic_map_add_constraint(ChangeScattering, c);
|
||||
}
|
||||
|
||||
for (unsigned i = isl_map_n_out(scattering); i < scatDimensions; i++) {
|
||||
for (unsigned i = OldDimensions; i < NewDimensions; i++) {
|
||||
isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LocalSpace));
|
||||
isl_constraint_set_coefficient_si(c, isl_dim_out, i, 1);
|
||||
changeScattering = isl_basic_map_add_constraint(changeScattering, c);
|
||||
ChangeScattering = isl_basic_map_add_constraint(ChangeScattering, c);
|
||||
}
|
||||
|
||||
isl_map *changeScatteringMap = isl_map_from_basic_map(changeScattering);
|
||||
isl_map *ChangeScatteringMap = isl_map_from_basic_map(ChangeScattering);
|
||||
|
||||
isl_space *SpaceModel = isl_map_get_space(scattering);
|
||||
changeScatteringMap = isl_map_align_params(changeScatteringMap, SpaceModel);
|
||||
stmt->setScattering(isl_map_apply_range(scattering, changeScatteringMap));
|
||||
ChangeScatteringMap = isl_map_align_params(ChangeScatteringMap,
|
||||
S.getParamSpace());
|
||||
isl_map *NewScattering = isl_map_apply_range(Stmt->getScattering(),
|
||||
ChangeScatteringMap);
|
||||
Stmt->setScattering(NewScattering);
|
||||
isl_local_space_free(LocalSpace);
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +394,7 @@ bool ScheduleOptimizer::runOnScop(Scop &S) {
|
|||
isl_union_set_from_set(domain));
|
||||
isl_map *stmtSchedule;
|
||||
isl_union_map_foreach_map(stmtBand, getSingleMap, &stmtSchedule);
|
||||
stmt->setScattering(isl_map_copy(stmtSchedule));
|
||||
stmt->setScattering(stmtSchedule);
|
||||
isl_union_map_free(stmtBand);
|
||||
}
|
||||
|
||||
|
@ -401,7 +404,7 @@ bool ScheduleOptimizer::runOnScop(Scop &S) {
|
|||
unsigned maxScatDims = 0;
|
||||
|
||||
for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI)
|
||||
maxScatDims = std::max(isl_map_n_out((*SI)->getScattering()), maxScatDims);
|
||||
maxScatDims = std::max((*SI)->getNumScattering(), maxScatDims);
|
||||
|
||||
extendScattering(S, maxScatDims);
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue