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

Simplify construction of parameteric pw affs #25

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

Conversation

tobiasgrosser
Copy link
Member

@tobiasgrosser tobiasgrosser commented May 16, 2018

This pull request proposes three new functions to simplify the generation of pw_aff expressions on parameter spaces. All expressions are generated on a universe domain.

#include <isl/aff.h>                                                     
__isl_give isl_pw_aff *isl_pw_aff_param_from_id(__isl_take isl_id *id);  
__isl_give isl_pw_aff *isl_pw_aff_val_from_val(__isl_take isl_val *val); 
__isl_give isl_pw_aff *isl_pw_aff_val_from_si(__isl_keep isl_ctx *ctx, int val);        

The piplib submodule was removed all the way back
isl-0.01-134-g309036cf4f (add copyright statements,
Wed Dec 16 19:25:40 2009 +0000), initially by mistake and
then properly in isl-0.01-146-gff1ea6be3f (properly remove
piplib submodule, Wed Jan 13 09:59:16 2010 +0100).
However, it may not get removed completely when moving from
an earlier commit to a later one since it may itself leave
some untracked files.  Just ignore it in that case.

Signed-off-by: Sven Verdoolaege <[email protected]>
Sven Verdoolaege and others added 7 commits May 17, 2018 16:03
This function will be reused in the next commit.

Signed-off-by: Sven Verdoolaege <[email protected]>
isl_multi_*_from_*_list calls isl_multi_*_set_* on
an uninitialized multi expression.  If any parameter alignment
needs to be performed, then it will fail (without error message)
on the uninitialized multi expression while trying to align
the missing elements.
Perform parameter alignment beforehand.

Signed-off-by: Sven Verdoolaege <[email protected]>
This function will be reused in the next commit.

Signed-off-by: Sven Verdoolaege <[email protected]>
This makes it more explicit when a multi expression may have
missing elements.

Signed-off-by: Sven Verdoolaege <[email protected]>
Signed-off-by: Sven Verdoolaege <[email protected]>
…tive

The isl AST generator will always produce division of this form.
For those created by the user, it's the user's responsibility.

Requested-by: Uday Reddy B <[email protected]>
Signed-off-by: Sven Verdoolaege <[email protected]>
Copy link
Member

@ftynse ftynse left a comment

Choose a reason for hiding this comment

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

All commit messages have the same typo "piecewiese". Individual comments are mostly typos and minor suggestions.

doc/user.pod Outdated
The following convenience functions first create a base expression and
then create a piecewise expression over a universe domain.
The following convenience functions first create a base expression and then
create a piecewise expression over a universe domain of a given (local) space.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that "over a universe domain of a space" is mathematically correct. "over domain that is a universe set in the given (local) space", leaving that to @skimo-openhub.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

doc/user.pod Outdated
@@ -3099,6 +3099,14 @@ then create a piecewise expression over a universe domain.
__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_zero(
__isl_take isl_space *space);

The following convenience functions first create a base expression and then
create a piecewise expression over a universe domain of a parameter space
which contains exactly one parameter dimension corresponding to the newly
Copy link
Member

Choose a reason for hiding this comment

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

"newly introduced" -> "given" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

doc/user.pod Outdated
The following convenience functions first create a base expression and then
create a piecewise expression over a universe domain of a parameter space
which contains exactly one parameter dimension corresponding to the newly
introduced parameter dimensions.
Copy link
Member

Choose a reason for hiding this comment

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

"dimension" (singular)

Copy link
Member Author

Choose a reason for hiding this comment

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

I used 'id' instead.

isl_aff.c Outdated
@@ -216,6 +216,26 @@ __isl_give isl_aff *isl_aff_var_on_domain(__isl_take isl_local_space *ls,
return NULL;
}

/* Return a piecewise affine expression defined over a one dimensional
Copy link
Member

Choose a reason for hiding this comment

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

"one-dimensional"

isl_test.c Outdated
if (equal < 0)
return isl_stat_error;
if (!equal)
isl_die(ctx, isl_error_unknown, "can not construct pw from id",
Copy link
Member

Choose a reason for hiding this comment

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

pw_aff

Copy link
Member Author

Choose a reason for hiding this comment

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

Used 'piecewise aff' to be more clear.

isl_test.c Outdated
@@ -6048,6 +6075,8 @@ int test_aff(isl_ctx *ctx)
isl_aff *aff;
int zero, equal;

if (test_pwa(ctx) < 0)
Copy link
Member

Choose a reason for hiding this comment

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

I'd call this function test_pa for consistency with the test_upa below

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

isl_aff.c Outdated
@@ -236,6 +236,21 @@ __isl_give isl_pw_aff *isl_pw_aff_param_from_id(__isl_take isl_id *id)
return isl_pw_aff_from_aff(aff);
}

/* Return a piecewise affine expression defined over a zero dimensional
Copy link
Member

Choose a reason for hiding this comment

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

"zero-dimensional"

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

isl_test.c Outdated
@@ -4765,10 +4765,12 @@ static isl_bool union_pw_aff_plain_is_equal(__isl_keep isl_union_pw_aff *upa,

/* Basic tests on isl_pw_aff.
*
* In particular test the construction of a single-parameter pw_aff from an id.
* In particular test the construction of a single-parameter pw_aff from an id
Copy link
Member

Choose a reason for hiding this comment

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

or a zero-parameter pw_aff from an isl val

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

isl_test.c Outdated
if (equal < 0)
return isl_stat_error;
if (!equal)
isl_die(ctx, isl_error_unknown, "can not construct pw from val",
Copy link
Member

Choose a reason for hiding this comment

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

from signed integer

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@tobiasgrosser tobiasgrosser force-pushed the simplify-construction-of-parameteric-pw-affs branch from b7667eb to 0ba9251 Compare May 28, 2018 09:26
This function constructs a new piecewise affine expression defined over
a one-dimensional parameter space where the parameter dimension
identifier is 'id' and the value of the piecewise affine expression is
the single parameter dimension over the full universe domain.

This function simplifies the construction of parameter expressions.
Specifically, there is no need to talk about set dimensions or even set
spaces in case parameter only expressions are constructed.

Signed-off-by: Tobias Grosser <[email protected]>
This function constructs a new piecewise affine expression defined over
a zero-dimensional parameter space. The value of the piecewise affine
expression is the constant value passed to this function.

This function simplifies the construction of parameter expressions.
Specifically, there is no need to talk about set dimensions or even set
spaces in case parameter only expressions are constructed. Constant
piecewise expressions with zero parameter dimensions can be combined
with other parameter-space only dimensions thanks to isl auto-alignment
of parameter dimensions.

Signed-off-by: Tobias Grosser <[email protected]>
This function constructs a new piecewise affine expression defined over
a zero-dimensional parameter space. The value of the piecewise affine
expression is the constant value passed to this function.

This function simplifies the construction of parameter expressions.
Specifically, there is no need to talk about set dimensions or even set
spaces in case parameter only expressions are constructed. Constant
piecewise expressions with zero parameter dimensions can be combined
with other parameter-space only dimensions thanks to isl auto-alignment
of parameter dimensions.

Signed-off-by: Tobias Grosser <[email protected]>
@tobiasgrosser tobiasgrosser force-pushed the simplify-construction-of-parameteric-pw-affs branch from 0ba9251 to dbfe618 Compare May 28, 2018 09:35
@tobiasgrosser
Copy link
Member Author

@ftynse, thanks for the comments. I addressed them all in the latest version of this patch set.

I missed a high-level comment from you. Do you think the functions themselves and specifically the function names picked make sense?

@ftynse
Copy link
Member

ftynse commented May 28, 2018

These functions make sense in context of further set/map construction. I don't see other potential uses now, but may be overlooking something.

I did think about the names. Existing aff construction functions use the pattern "_on_domain", but here we don't have the domain. Alternative names can be along the lines of "isl_pw_aff_cst_on_empty_domain_val", "isl_pw_aff_cst_on_empty_domain_si" and "isl_pw_aff_param_on_singular_domain", but they look too wordy. Using the pattern "<something>_from_<something>" is sort of associated with conversion, like map_from_multi_union_pw_aff, and often exported as overloads or even constructors. For me, a conversion from a constant to a constant function defined over zero-dimensional space sounds okay, not sure about @skimo-openhub.

@tobiasgrosser
Copy link
Member Author

tobiasgrosser commented May 28, 2018

OK, so we basically have the following two naming schemes:

Conversion-style naming

These functions transform a constant value / id into a constant function over a zero-dimensional space and are consequently conversion style constructors.

isl_pw_aff_param_from_id
isl_pw_aff_val_from_val
isl_pw_aff_val_from_si

Explicit function names (Alex)

isl_pw_aff_param_on_singular_domain
isl_pw_aff_cst_on_empty_domain_val
isl_pw_aff_cst_on_empty_domain_si

I think we should use param/val, as the term 'constant' might refer both to a parameter or an integer value -- basically everything that does not depend on a variable.

I also don't think that empty_domain is the right name. I would guess, if we call get_domain() on these pw_aff and ask if the domain is_empty() the reply would always be false. Not sure what would be a better name. The term 'singleton' would refer to a set with exactly one element, but does not say anything about the dimensionality of the set. We could use sth like on_param_domain to capture both the fact that the result is a singleton and/or that the space is a parameter space. Now, this won't give information about the number of parameter dimensions. However, as they are anyhow auto-aligned, that might be fine. Maybe the following:

Explicit function names (Tobias)

isl_pw_aff_param_on_param_domain
isl_pw_aff_val_on_param_domain_val
isl_pw_aff_val_on_param_domain_si

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.

2 participants