Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bound #521

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open

Bound #521

wants to merge 25 commits into from

Conversation

manya-bansal
Copy link

Remove bound as a relation node in the provenance graph. Instead, tag the indexVar with information about the bound.

Copy link
Contributor

@rohany rohany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some initial comments (ignoring things various nits around code quality), which can be covered when the design seems right.

@@ -601,6 +601,8 @@ class IndexStmt : public util::IntrusivePtr<const IndexStmtNode> {
/// variable, a \textit{tail strategy} is employed such as emitting a variable
/// sized loop that handles remaining iterations.
/// Preconditions: splitFactor is a positive nonzero integer
IndexStmt splitUpDown(IndexVar i, IndexVar i1, IndexVar i2, bool split_up, size_t splitFactor) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like this shouldn't be a separate API call, but instead an additional argument to the existing split call that takes in an enum, with an enum that has a default value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed: it is not relevant to this pull request

IndexStmt bound(IndexVar i, IndexVar i1, size_t bound, BoundType bound_type) const;


IndexStmt bound(IndexVar i, size_t bound, BoundType bound_type) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably remove the old bound call and replace all users with the new method (I don't think we care that much about backwards compat, and bound doesn't have that many users).

@@ -1031,6 +1038,18 @@ class IndexVar : public IndexExpr, public IndexVarInterface {
/// Returns the name of the index variable.
std::string getName() const;

size_t& getBound() const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these things attached to this index variable instead of tagged to a particular for loop?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mapping a for all to an index var's bound is not possible since adding schedules replaces the occurrence of the index var from the stmt in certain cases.

Instead, in the updated pull request, we tag this information to a suchThatNode, adding a map that relates the bounded variable, bound size and bound type.

if (!transformed.defined()) {
taco_uerror << reason;
}
taco_uerror << "Depericated Bound: bounding " << i.getName() << " ignoring " << i1.getName() << endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling error, but this method should be removed.

src/index_notation/index_notation.cpp Outdated Show resolved Hide resolved
if (indexVar == getOuterVar()) {
ir::Expr minBound = ir::Div::make(parentBound[0], ir::Literal::make(getSplitFactor(), splitFactorType));
ir::Expr maxBound = ir::Div::make(ir::Add::make(parentBound[1], ir::Literal::make(getSplitFactor()-1, splitFactorType)), ir::Literal::make(getSplitFactor(), splitFactorType));
if ( ir::isa<ir::Literal>(ir::simplify(maxBound)) && indexVar.isBound() && !ir::to<ir::Literal>(ir::simplify(maxBound))->equalsScalar(indexVar.getBound()) ){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this a reasonable restriction, and can instead be checked when performing the split transformation rather than here.

@@ -461,6 +473,23 @@ std::vector<ir::Expr> PosRelNode::deriveIterBounds(taco::IndexVar indexVar,
std::map<taco::IndexVar, taco::ir::Expr> variableNames,
Iterators iterators,
ProvenanceGraph provGraph) const {


if (indexVar.isBound()){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the provenance graph still has to answer queries about bounded variables, then it should have the information about bounded variables, rather than the indexvar perhaps. I could see a relation similar to how bound existed already, but is instead a marker for an index variable, rather than relating two variables? I assume that this was considered in your discussions though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the updated pull request, the provenance graph keeps a map of bounded vars. We cannot add the bound as VarRelNode instead since we want to get around the problem of having to create a new indexVar in order to bound it.

At it's current implementation, we cannot have cycles in the provenance graph, but the bound (if implemented as a RelNode, we will introduce a cycle since the parent and child would be the same).

taco_iassert(indexVar == getPrecomputeVar());
taco_iassert(parentIterBounds.count(getParentVar()) == 1);

if (indexVar.isBound()){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's quite weird that each relation node's implementation now has to check things about bound. That's not a modular design

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to remove this check for deriveIterBounds from the RelNodes functions to the deriveIterBounds for the provenance graph (so, we only need to make this check once).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants