-
Notifications
You must be signed in to change notification settings - Fork 212
[WIP] use templated isl types #533
base: master
Are you sure you want to change the base?
Conversation
From a quick glance, this looks great to me |
@@ -365,7 +371,7 @@ bool accessSubscriptsAreUnrolledLoops( | |||
auto subdomain = activeDomainPointsBelow(root, leaf); | |||
|
|||
auto unrolledDims = isl::union_pw_aff_list(leaf->ctx_, 1); | |||
for (auto node : ancestors) { | |||
for (const detail::ScheduleTree* node : ancestors) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not immediately obvious why this had to be changed, but leaving in auto
results in
home/skimo/git/c2isl/tc/core/polyhedral/cuda/memory_promotion_heuristic.cc:375:60: error: expected primary-expression before ‘>’ token
auto band = node->elemAs<detail::ScheduleTreeElemBand>();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try (I think):
auto band = node.template operator->(elemAs<detail::ScheduleTreeElemBand>());
Not sure if it works I seem to remember using that with operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or what @ftynse explained :)
@@ -365,7 +371,7 @@ bool accessSubscriptsAreUnrolledLoops( | |||
auto subdomain = activeDomainPointsBelow(root, leaf); | |||
|
|||
auto unrolledDims = isl::union_pw_aff_list(leaf->ctx_, 1); | |||
for (auto node : ancestors) { | |||
for (const detail::ScheduleTree* node : ancestors) { | |||
auto band = node->elemAs<detail::ScheduleTreeElemBand>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing this as auto band = node->template elemAs<detail::ScheduleTreeElemBand>();
allows me to keep the auto
, but it is again not obvious why I need to introduce template
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntactic disambiguation. A particularly nasty interplay between templates and type inference. The syntax of a template is checked when parsing its definition. But type inference for auto
is performed at template instantiation time. When parsing elemAs<detail::ScheduleTreeElemBand
, the compiler wouldn't know if <
is a comparison operator or the start of a template argument list. Unless elemAs
is known to be a template (but it is not known because it's type has not been inferred yet when node
is declared as auto
), <
is treated as a comparison operator. In this case, the RHS must be an expression. detail::ScheduleTreeElemBand>()
is not a valid expression so the compiler complains. Adding the template
prefix indicates that <
must be always treated as the start of the template argument list, so it fixes the problem. So does manually specifying the type of node
because the compiler now knows that elemAs
is a function template.
On Fri, Jun 22, 2018 at 04:52:38AM -0700, ftynse wrote:
Syntactic disambiguation. A particularly nasty interplay between templates and type inference. The syntax of a template is checked when parsing its definition. But type inference for `auto` is performed at template instantiation time. When parsing `elemAs<detail::ScheduleTreeElemBand`, the compiler wouldn't know if `<` is a comparison operator or the start of a template argument list. Unless `elemAs` is known to be a template (but it is not known because it's type has not been inferred yet when `node` is declared as `auto`), `<` is treated as a comparison operator. In this case, the RHS must be an expression. `detail::ScheduleTreeElemBand>()` is not a valid expression so the compiler complains. Adding the `template` prefix indicates that `<` must be always treated as the start of the template argument list, so it fixes the problem. So does manually specifying the type of `node` because the compiler now knows that `elemAs` is a function template.
Thanks. It makes sense now.
skimo
|
2a546c8
to
22cf55d
Compare
I like the general idea. What worries me is the need to manually introduce member functions in the class templates. Those in isl bindings are autogenerated... |
On Fri, Jun 29, 2018 at 05:50:56AM -0700, ftynse wrote:
I like the general idea. What worries me is the need to manually introduce member functions in the class templates. Those in isl bindings are autogenerated...
The idea would be for us to experiment with this for a while and
if it turns out to be useful, we can think of autogenerating
these functions too. Note that this would require some
additional annotations.
skimo
|
Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours has expired. Before we can review or merge your code, we need you to email [email protected] with your details so we can update your status. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
22cf55d
to
835035f
Compare
On Fri, Jun 29, 2018 at 05:50:56AM -0700, ftynse wrote:
I like the general idea. What worries me is the need to manually introduce member functions in the class templates. Those in isl bindings are autogenerated...
I'm now generating these as well, but I'm still trying
to pick the pieces apart, so it's not quite ready yet.
skimo
|
340ddb8
to
57e4ceb
Compare
This allows outputRanges to be converted to templated isl types without having to convert TensorReferenceGroup::promotion at the same time. Automatic type deduction will be reintroduced when TensorReferenceGroup::promotion is converted.
Since removeRangeStrides has not been converted yet, a separate variable is introduced to store its result. Since ScopedFootprint::strideOffsets is modified, TensorReferenceGroup::promotion needs some modifications too.
This allows TensorReferenceGroup.originalAccesses() to be converted to templated isl types without having to convert accessSubscriptsAreUnrolledLoops at the same time. Automatic type deduction will be reintroduced when accessSubscriptsAreUnrolledLoops is converted.
0b3446d
to
dbc7391
Compare
I got kicked out of the GitHub Facebook organization yesterday (before the end of my working day), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trying to unsubscribe, don't see a way other than approving
Templated isl types require the user to specify the domain and range
universes of isl objects, allowing the compiler to check whether
it makes sense to combine pairs of objects.
This RFC only converts isPromotableToRegistersBelow and some related
functions to illustrate the effect.
The isPromotableToRegistersBelow was already applying operations
correctly, so the code itself did not require any changes.
However, one variable was reused to store different types
of intermediate result and this one had to be split up into
several variables because they now have different types.