Skip to content

Commit

Permalink
[Polly][Isl] Move to the new-polly-generator branch version of isl-no…
Browse files Browse the repository at this point in the history
…exceptions.h. NFCI

This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in `lib/External/isl/include/isl/isl-noxceptions.h` and the official isl C++ interface.

With this commit we are moving from the `polly-generator` branch to the `new-polly-generator` branch that is more mantainable and is based on the official C++ interface `cpp-checked.h`.

Changes made:
 - There are now many sublcasses for `isl::ast_node` representing different isl types. Use `isl::ast_node_for`, `isl::ast_node_user`, `isl::ast_node_block` and `isl::ast_node_mark` where needed.
 - There are now many sublcasses for `isl::schedule_node` representing different isl types. Use `isl::schedule_node_mark`, `isl::schedule_node_extension`, `isl::schedule_node_band` and `isl::schedule_node_filter` where needed.
 - Replace the `isl::*::dump` with `dumpIslObj` since the isl dump method is not exposed in the C++ interface.
 - `isl::schedule_node::get_child` has been renamed to `isl::schedule_node::child`
 - `isl::pw_multi_aff::get_pw_aff` has been renamed to `isl::pw_multi_aff::at`
 - The constructor `isl::union_map(isl::union_pw_multi_aff)` has been replaced with the static method `isl::union_map::from()`
 - Replace usages of `isl::val::add_ui` with `isl::val::add`
 - `isl::union_set_list::alloc` is now a constructor
 - All the `isl_size` values are now wrapped inside the class `isl::size` use `isl::size::release` to get the internal `isl_size` value where needed.
 - `isl-noexceptions.h` has been generated by patacca/isl@73f5ed1

No functional change intended.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D107225
  • Loading branch information
patacca committed Aug 16, 2021
1 parent c019142 commit d3fdbda
Show file tree
Hide file tree
Showing 23 changed files with 13,041 additions and 11,000 deletions.
7 changes: 4 additions & 3 deletions polly/include/polly/CodeGen/IslNodeBuilder.h
Expand Up @@ -217,7 +217,8 @@ class IslNodeBuilder {
// of loop iterations.
//
// 3. With the existing code, upper bounds have been easier to implement.
isl::ast_expr getUpperBound(isl::ast_node For, CmpInst::Predicate &Predicate);
isl::ast_expr getUpperBound(isl::ast_node_for For,
CmpInst::Predicate &Predicate);

/// Return non-negative number of iterations in case of the following form
/// of a loop and -1 otherwise.
Expand All @@ -228,7 +229,7 @@ class IslNodeBuilder {
///
/// NumIter is a non-negative integer value. Condition can have
/// isl_ast_op_lt type.
int getNumberOfIterations(isl::ast_node For);
int getNumberOfIterations(isl::ast_node_for For);

/// Compute the values and loops referenced in this subtree.
///
Expand Down Expand Up @@ -317,7 +318,7 @@ class IslNodeBuilder {
bool preloadInvariantEquivClass(InvariantEquivClassTy &IAClass);

void createForVector(__isl_take isl_ast_node *For, int VectorWidth);
void createForSequential(isl::ast_node For, bool MarkParallel);
void createForSequential(isl::ast_node_for For, bool MarkParallel);

/// Create LLVM-IR that executes a for node thread parallel.
///
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/ScheduleTreeTransform.h
Expand Up @@ -134,7 +134,7 @@ struct RecursiveScheduleTreeVisitor

/// By default, recursively visit the child nodes.
RetTy visitNode(const isl::schedule_node &Node, Args... args) {
isl_size NumChildren = Node.n_children();
isl_size NumChildren = Node.n_children().release();
for (isl_size i = 0; i < NumChildren; i += 1)
getDerived().visit(Node.child(i), std::forward<Args>(args)...);
return RetTy();
Expand Down
45 changes: 45 additions & 0 deletions polly/include/polly/Support/GICHelper.h
Expand Up @@ -186,6 +186,51 @@ ISL_OBJECT_TO_STRING(union_pw_aff)
ISL_OBJECT_TO_STRING(union_pw_multi_aff)
//@}

/// C++ wrapper for isl_*_dump() functions.
//@{
#define ISL_DUMP_OBJECT(name) \
inline void dumpIslObj(const isl::name &Obj) { isl_##name##_dump(Obj.get()); }

ISL_DUMP_OBJECT(aff)
ISL_DUMP_OBJECT(aff_list)
ISL_DUMP_OBJECT(ast_expr)
ISL_DUMP_OBJECT(ast_node)
ISL_DUMP_OBJECT(ast_node_list)
ISL_DUMP_OBJECT(basic_map)
ISL_DUMP_OBJECT(basic_map_list)
ISL_DUMP_OBJECT(basic_set)
ISL_DUMP_OBJECT(basic_set_list)
ISL_DUMP_OBJECT(constraint)
ISL_DUMP_OBJECT(id)
ISL_DUMP_OBJECT(id_list)
ISL_DUMP_OBJECT(id_to_ast_expr)
ISL_DUMP_OBJECT(local_space)
ISL_DUMP_OBJECT(map)
ISL_DUMP_OBJECT(map_list)
ISL_DUMP_OBJECT(multi_aff)
ISL_DUMP_OBJECT(multi_pw_aff)
ISL_DUMP_OBJECT(multi_union_pw_aff)
ISL_DUMP_OBJECT(multi_val)
ISL_DUMP_OBJECT(point)
ISL_DUMP_OBJECT(pw_aff)
ISL_DUMP_OBJECT(pw_aff_list)
ISL_DUMP_OBJECT(pw_multi_aff)
ISL_DUMP_OBJECT(schedule)
ISL_DUMP_OBJECT(schedule_constraints)
ISL_DUMP_OBJECT(schedule_node)
ISL_DUMP_OBJECT(set)
ISL_DUMP_OBJECT(set_list)
ISL_DUMP_OBJECT(space)
ISL_DUMP_OBJECT(union_map)
ISL_DUMP_OBJECT(union_pw_aff)
ISL_DUMP_OBJECT(union_pw_aff_list)
ISL_DUMP_OBJECT(union_pw_multi_aff)
ISL_DUMP_OBJECT(union_set)
ISL_DUMP_OBJECT(union_set_list)
ISL_DUMP_OBJECT(val)
ISL_DUMP_OBJECT(val_list)
//@}

inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
__isl_keep isl_union_map *Map) {
OS << polly::stringFromIslObj(Map, "null");
Expand Down
2 changes: 1 addition & 1 deletion polly/include/polly/Support/ISLTools.h
Expand Up @@ -32,7 +32,7 @@ struct isl_iterator
using ElementT = list_element_type<ListT>;

explicit isl_iterator(const ListT &List)
: List(&List), Position(std::max(List.size(), 0)) {}
: List(&List), Position(std::max(List.size().release(), 0)) {}
isl_iterator(const ListT &List, int Position)
: List(&List), Position(Position) {}

Expand Down
4 changes: 2 additions & 2 deletions polly/lib/Analysis/DependenceInfo.cpp
Expand Up @@ -190,7 +190,7 @@ static void collectInfo(Scop &S, isl_union_map *&Read,

/// Fix all dimension of @p Zero to 0 and add it to @p user
static void fixSetToZero(isl::set Zero, isl::union_set *User) {
for (auto i : seq<isl_size>(0, Zero.tuple_dim()))
for (auto i : seq<isl_size>(0, Zero.tuple_dim().release()))
Zero = Zero.fix_si(isl::dim::set, i, 0);
*User = User->unite(Zero);
}
Expand Down Expand Up @@ -667,7 +667,7 @@ bool Dependences::isValidSchedule(
Dependences = Dependences.apply_range(Schedule);

isl::set Zero = isl::set::universe(ScheduleSpace);
for (auto i : seq<isl_size>(0, Zero.tuple_dim()))
for (auto i : seq<isl_size>(0, Zero.tuple_dim().release()))
Zero = Zero.fix_si(isl::dim::set, i, 0);

isl::union_set UDeltas = Dependences.deltas();
Expand Down
51 changes: 25 additions & 26 deletions polly/lib/Analysis/ScopBuilder.cpp
Expand Up @@ -202,7 +202,7 @@ static bool containsErrorBlock(RegionNode *RN, const Region &R, LoopInfo &LI,
static isl::map createNextIterationMap(isl::space SetSpace, unsigned Dim) {
isl::space MapSpace = SetSpace.map_from_set();
isl::map NextIterationMap = isl::map::universe(MapSpace);
for (auto u : seq<isl_size>(0, NextIterationMap.domain_tuple_dim()))
for (auto u : seq<isl_size>(0, NextIterationMap.domain_tuple_dim().release()))
if (u != (isl_size)Dim)
NextIterationMap =
NextIterationMap.equate(isl::dim::in, u, isl::dim::out, u);
Expand Down Expand Up @@ -230,10 +230,10 @@ static isl::set collectBoundedParts(isl::set S) {
/// both with regards to the dimension @p Dim.
static std::pair<isl::set, isl::set> partitionSetParts(isl::set S,
unsigned Dim) {
for (unsigned u = 0, e = S.tuple_dim(); u < e; u++)
for (unsigned u = 0, e = S.tuple_dim().release(); u < e; u++)
S = S.lower_bound_si(isl::dim::set, u, 0);

unsigned NumDimsS = S.tuple_dim();
unsigned NumDimsS = S.tuple_dim().release();
isl::set OnlyDimS = S;

// Remove dimensions that are greater than Dim as they are not interesting.
Expand Down Expand Up @@ -328,7 +328,7 @@ isl::set ScopBuilder::adjustDomainDimensions(isl::set Dom, Loop *OldL,
} else {
assert(OldDepth > NewDepth);
int Diff = OldDepth - NewDepth;
int NumDim = Dom.tuple_dim();
int NumDim = Dom.tuple_dim().release();
assert(NumDim >= Diff);
Dom = Dom.project_out(isl::dim::set, NumDim - Diff, Diff);
}
Expand Down Expand Up @@ -838,7 +838,7 @@ bool ScopBuilder::buildDomains(
isl_set_universe(isl_space_set_alloc(scop->getIslCtx().get(), 0, LD + 1));

InvalidDomainMap[EntryBB] = isl::manage(isl_set_empty(isl_set_get_space(S)));
isl::noexceptions::set Domain = isl::manage(S);
isl::set Domain = isl::manage(S);
scop->setDomain(EntryBB, Domain);

if (IsOnlyNonAffineRegion)
Expand Down Expand Up @@ -909,7 +909,7 @@ bool ScopBuilder::buildDomainsWithBranchConstraints(
continue;
isl::set Domain = scop->getDomainConditions(BB);

scop->updateMaxLoopDepth(Domain.tuple_dim());
scop->updateMaxLoopDepth(Domain.tuple_dim().release());

auto *BBLoop = getRegionNodeLoop(RN, LI);
// Propagate the domain from BB directly to blocks that have a superset
Expand Down Expand Up @@ -983,7 +983,7 @@ bool ScopBuilder::buildDomainsWithBranchConstraints(

// Check if the maximal number of domain disjunctions was reached.
// In case this happens we will clean up and bail.
if (SuccDomain.n_basic_set() < MaxDisjunctsInDomain)
if (SuccDomain.n_basic_set().release() < MaxDisjunctsInDomain)
continue;

scop->invalidate(COMPLEXITY, DebugLoc());
Expand Down Expand Up @@ -1063,7 +1063,7 @@ bool ScopBuilder::propagateInvalidStmtDomains(

// Check if the maximal number of domain disjunctions was reached.
// In case this happens we will bail.
if (SuccInvalidDomain.n_basic_set() < MaxDisjunctsInDomain)
if (SuccInvalidDomain.n_basic_set().release() < MaxDisjunctsInDomain)
continue;

InvalidDomainMap.erase(BB);
Expand Down Expand Up @@ -1162,7 +1162,7 @@ static isl::multi_union_pw_aff mapToDimension(isl::union_set USet, int N) {
auto Result = isl::union_pw_multi_aff::empty(USet.get_space());

for (isl::set S : USet.get_set_list()) {
int Dim = S.tuple_dim();
int Dim = S.tuple_dim().release();
auto PMA = isl::pw_multi_aff::project_out_map(S.get_space(), isl::dim::set,
N, Dim - N);
if (N > 1)
Expand Down Expand Up @@ -1307,10 +1307,8 @@ void ScopBuilder::buildSchedule(RegionNode *RN, LoopStackTy &LoopStack) {
// It is easier to insert the marks here that do it retroactively.
isl::id IslLoopId = createIslLoopAttr(scop->getIslCtx(), L);
if (!IslLoopId.is_null())
Schedule = Schedule.get_root()
.get_child(0)
.insert_mark(IslLoopId)
.get_schedule();
Schedule =
Schedule.get_root().child(0).insert_mark(IslLoopId).get_schedule();

LoopData->Schedule = combineInSequence(LoopData->Schedule, Schedule);
}
Expand Down Expand Up @@ -2405,7 +2403,7 @@ void ScopBuilder::foldSizeConstantsToRight() {
isl::map Transform = isl::map::universe(Array->getSpace().map_from_set());

std::vector<int> Int;
int Dims = Elements.tuple_dim();
int Dims = Elements.tuple_dim().release();
for (int i = 0; i < Dims; i++) {
isl::set DimOnly = isl::set(Elements).project_out(isl::dim::set, 0, i);
DimOnly = DimOnly.project_out(isl::dim::set, 1, Dims - i - 1);
Expand All @@ -2419,7 +2417,7 @@ void ScopBuilder::foldSizeConstantsToRight() {
continue;
}

if (DimHull.dim(isl::dim::div) == 1) {
if (DimHull.dim(isl::dim::div).release() == 1) {
isl::aff Diff = DimHull.get_div(0);
isl::val Val = Diff.get_denominator_val();

Expand Down Expand Up @@ -2839,8 +2837,8 @@ static bool isAccessRangeTooComplex(isl::set AccessRange) {
int NumTotalDims = 0;

for (isl::basic_set BSet : AccessRange.get_basic_set_list()) {
NumTotalDims += BSet.dim(isl::dim::div);
NumTotalDims += BSet.dim(isl::dim::set);
NumTotalDims += BSet.dim(isl::dim::div).release();
NumTotalDims += BSet.dim(isl::dim::set).release();
}

if (NumTotalDims > MaxDimensionsInAccessRange)
Expand Down Expand Up @@ -2869,7 +2867,8 @@ void ScopBuilder::addUserContext() {

isl::set UserContext = isl::set(scop->getIslCtx(), UserContextStr.c_str());
isl::space Space = scop->getParamSpace();
if (Space.dim(isl::dim::param) != UserContext.dim(isl::dim::param)) {
if (Space.dim(isl::dim::param).release() !=
UserContext.dim(isl::dim::param).release()) {
std::string SpaceStr = stringFromIslObj(Space, "null");
errs() << "Error: the context provided in -polly-context has not the same "
<< "number of dimensions than the computed context. Due to this "
Expand All @@ -2878,7 +2877,7 @@ void ScopBuilder::addUserContext() {
return;
}

for (auto i : seq<isl_size>(0, Space.dim(isl::dim::param))) {
for (auto i : seq<isl_size>(0, Space.dim(isl::dim::param).release())) {
std::string NameContext =
scop->getContext().get_dim_name(isl::dim::param, i);
std::string NameUserContext = UserContext.get_dim_name(isl::dim::param, i);
Expand Down Expand Up @@ -2962,7 +2961,7 @@ isl::set ScopBuilder::getNonHoistableCtx(MemoryAccess *Access,
return WrittenCtx;

WrittenCtx = WrittenCtx.remove_divs();
bool TooComplex = WrittenCtx.n_basic_set() >= MaxDisjunctsInDomain;
bool TooComplex = WrittenCtx.n_basic_set().release() >= MaxDisjunctsInDomain;
if (TooComplex || !isRequiredInvariantLoad(LI))
return {};

Expand Down Expand Up @@ -3028,7 +3027,7 @@ void ScopBuilder::addInvariantLoads(ScopStmt &Stmt,
isl::set DomainCtx = Stmt.getDomain().params();
DomainCtx = DomainCtx.subtract(StmtInvalidCtx);

if (DomainCtx.n_basic_set() >= MaxDisjunctsInDomain) {
if (DomainCtx.n_basic_set().release() >= MaxDisjunctsInDomain) {
auto *AccInst = InvMAs.front().MA->getAccessInstruction();
scop->invalidate(COMPLEXITY, AccInst->getDebugLoc(), AccInst->getParent());
return;
Expand Down Expand Up @@ -3304,7 +3303,7 @@ static bool buildMinMaxAccess(isl::set Set,
Set = Set.remove_divs();
polly::simplify(Set);

if (Set.n_basic_set() > RunTimeChecksMaxAccessDisjuncts)
if (Set.n_basic_set().release() > RunTimeChecksMaxAccessDisjuncts)
Set = Set.simple_hull();

// Restrict the number of parameters involved in the access as the lexmin/
Expand Down Expand Up @@ -3342,11 +3341,11 @@ static bool buildMinMaxAccess(isl::set Set,
// enclose the accessed memory region by MinPMA and MaxPMA. The pointer
// we test during code generation might now point after the end of the
// allocated array but we will never dereference it anyway.
assert((MaxPMA.is_null() || MaxPMA.dim(isl::dim::out)) &&
assert((MaxPMA.is_null() || MaxPMA.dim(isl::dim::out).release()) &&
"Assumed at least one output dimension");

Pos = MaxPMA.dim(isl::dim::out) - 1;
LastDimAff = MaxPMA.get_pw_aff(Pos);
Pos = MaxPMA.dim(isl::dim::out).release() - 1;
LastDimAff = MaxPMA.at(Pos);
OneAff = isl::aff(isl::local_space(LastDimAff.get_domain_space()));
OneAff = OneAff.add_constant_si(1);
LastDimAff = LastDimAff.add(OneAff);
Expand Down Expand Up @@ -3386,7 +3385,7 @@ bool ScopBuilder::calculateMinMaxAccess(AliasGroupTy AliasGroup,

static isl::set getAccessDomain(MemoryAccess *MA) {
isl::set Domain = MA->getStatement()->getDomain();
Domain = Domain.project_out(isl::dim::set, 0, Domain.tuple_dim());
Domain = Domain.project_out(isl::dim::set, 0, Domain.tuple_dim().release());
return Domain.reset_tuple_id();
}

Expand Down
27 changes: 14 additions & 13 deletions polly/lib/Analysis/ScopInfo.cpp
Expand Up @@ -185,7 +185,7 @@ static isl::set addRangeBoundsToSet(isl::set S, const ConstantRange &Range,
if (Range.isFullSet())
return S;

if (S.n_basic_set() > MaxDisjunctsInContext)
if (S.n_basic_set().release() > MaxDisjunctsInContext)
return S;

// In case of signed wrapping, we can refine the set of valid values by
Expand Down Expand Up @@ -473,8 +473,8 @@ void MemoryAccess::updateDimensionality() {
isl::space AccessSpace = AccessRelation.get_space().range();
isl::ctx Ctx = ArraySpace.ctx();

auto DimsArray = ArraySpace.dim(isl::dim::set);
auto DimsAccess = AccessSpace.dim(isl::dim::set);
auto DimsArray = ArraySpace.dim(isl::dim::set).release();
auto DimsAccess = AccessSpace.dim(isl::dim::set).release();
auto DimsMissing = DimsArray - DimsAccess;

auto *BB = getStatement()->getEntryBlock();
Expand Down Expand Up @@ -671,14 +671,14 @@ isl::set MemoryAccess::assumeNoOutOfBound() {
auto *SAI = getScopArrayInfo();
isl::space Space = getOriginalAccessRelationSpace().range();
isl::set Outside = isl::set::empty(Space);
for (int i = 1, Size = Space.dim(isl::dim::set); i < Size; ++i) {
for (int i = 1, Size = Space.dim(isl::dim::set).release(); i < Size; ++i) {
isl::local_space LS(Space);
isl::pw_aff Var = isl::pw_aff::var_on_domain(LS, isl::dim::set, i);
isl::pw_aff Zero = isl::pw_aff(LS);

isl::set DimOutside = Var.lt_set(Zero);
isl::pw_aff SizeE = SAI->getDimensionSizePw(i);
SizeE = SizeE.add_dims(isl::dim::in, Space.dim(isl::dim::set));
SizeE = SizeE.add_dims(isl::dim::in, Space.dim(isl::dim::set).release());
SizeE = SizeE.set_tuple_id(isl::dim::in, Space.get_tuple_id(isl::dim::set));
DimOutside = DimOutside.unite(SizeE.le_set(Var));

Expand Down Expand Up @@ -830,8 +830,8 @@ void MemoryAccess::foldAccessRelation() {
// Access dimension folding might in certain cases increase the number of
// disjuncts in the memory access, which can possibly complicate the generated
// run-time checks and can lead to costly compilation.
if (!PollyPreciseFoldAccesses &&
NewAccessRelation.n_basic_map() > AccessRelation.n_basic_map()) {
if (!PollyPreciseFoldAccesses && NewAccessRelation.n_basic_map().release() >
AccessRelation.n_basic_map().release()) {
} else {
AccessRelation = NewAccessRelation;
}
Expand Down Expand Up @@ -1006,7 +1006,7 @@ isl::pw_aff MemoryAccess::getPwAff(const SCEV *E) {
static isl::map getEqualAndLarger(isl::space SetDomain) {
isl::space Space = SetDomain.map_from_set();
isl::map Map = isl::map::universe(Space);
unsigned lastDimension = Map.domain_tuple_dim() - 1;
unsigned lastDimension = Map.domain_tuple_dim().release() - 1;

// Set all but the last dimension to be equal for the input and output
//
Expand Down Expand Up @@ -1046,9 +1046,10 @@ bool MemoryAccess::isStrideX(isl::map Schedule, int StrideWidth) const {

Stride = getStride(Schedule);
StrideX = isl::set::universe(Stride.get_space());
for (auto i : seq<isl_size>(0, StrideX.tuple_dim() - 1))
for (auto i : seq<isl_size>(0, StrideX.tuple_dim().release() - 1))
StrideX = StrideX.fix_si(isl::dim::set, i, 0);
StrideX = StrideX.fix_si(isl::dim::set, StrideX.tuple_dim() - 1, StrideWidth);
StrideX = StrideX.fix_si(isl::dim::set, StrideX.tuple_dim().release() - 1,
StrideWidth);
IsStrideX = Stride.is_subset(StrideX);

return IsStrideX;
Expand Down Expand Up @@ -1108,7 +1109,7 @@ void MemoryAccess::setNewAccessRelation(isl::map NewAccess) {
// Check whether access dimensions correspond to number of dimensions of the
// accesses array.
isl_size Dims = SAI->getNumberOfDimensions();
assert(NewAccessSpace.dim(isl::dim::set) == Dims &&
assert(NewAccessSpace.dim(isl::dim::set).release() == Dims &&
"Access dims must match array dims");
#endif

Expand Down Expand Up @@ -2143,10 +2144,10 @@ void Scop::intersectDefinedBehavior(isl::set Set, AssumptionSign Sign) {

// Limit the complexity of the context. If complexity is exceeded, simplify
// the set and check again.
if (DefinedBehaviorContext.n_basic_set() >
if (DefinedBehaviorContext.n_basic_set().release() >
MaxDisjunktsInDefinedBehaviourContext) {
simplify(DefinedBehaviorContext);
if (DefinedBehaviorContext.n_basic_set() >
if (DefinedBehaviorContext.n_basic_set().release() >
MaxDisjunktsInDefinedBehaviourContext)
DefinedBehaviorContext = {};
}
Expand Down

0 comments on commit d3fdbda

Please sign in to comment.