Skip to content
This repository has been archived by the owner on Apr 28, 2023. It is now read-only.

[WIP] use templated isl types #533

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

[WIP] use templated isl types #533

wants to merge 102 commits into from

Conversation

skimo-openhub
Copy link
Contributor

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.

@nicolasvasilache
Copy link
Contributor

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) {
Copy link
Contributor Author

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>();

Copy link
Contributor

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.

Copy link
Contributor

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>();
Copy link
Contributor Author

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.

Copy link
Contributor

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.

@skimo-openhub skimo-openhub changed the base branch from pr/clean_up to master June 22, 2018 11:01
@skimo-openhub
Copy link
Contributor Author

skimo-openhub commented Jun 22, 2018 via email

@ftynse
Copy link
Contributor

ftynse commented Jun 29, 2018

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...

@skimo-openhub
Copy link
Contributor Author

skimo-openhub commented Jun 29, 2018 via email

@facebook-github-bot
Copy link

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.

@skimo-openhub skimo-openhub self-assigned this Jul 26, 2018
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@skimo-openhub skimo-openhub changed the title [RFC] use templated isl types [WIP] use templated isl types Jul 26, 2018
@skimo-openhub
Copy link
Contributor Author

skimo-openhub commented Jul 26, 2018 via email

@skimo-openhub skimo-openhub force-pushed the pr/template branch 12 times, most recently from 340ddb8 to 57e4ceb Compare August 1, 2018 10:00
Sven Verdoolaege added 27 commits August 3, 2018 12:35
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.
@skimo-openhub
Copy link
Contributor Author

I got kicked out of the GitHub Facebook organization yesterday (before the end of my working day),
so I can't update this PR. I created a new one instead (#604).

Copy link
Contributor

@nicolasvasilache nicolasvasilache left a 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

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

Successfully merging this pull request may close these issues.

4 participants