Optimizing loops w/ local dimensions

20 views
Skip to first unread message

Daniel Maier

unread,
Oct 5, 2018, 12:35:37 PM10/5/18
to pluto-de...@googlegroups.com
Hi,

I am trying to optimize loops with local dimensions like this:

for(i=0; i<N; i++)
if(i%2==0)
S1();

However, I realized that Pluto asserts that there are no local
dimensions. What is the exact reason for this?

Is there any way around this limitation?

Best regards
Daniel

David

unread,
Oct 6, 2018, 7:03:55 AM10/6/18
to Pluto development
Well i experimenting with this tool for a while now, im not really an expert.
All i know (or experienced) PLUTO hates modulo operator. Also wouldn't be easier to just:

for(i=0; i<N; i+=2)  
    S1();

Sven Verdoolaege

unread,
Oct 6, 2018, 12:58:56 PM10/6/18
to Daniel Maier, pluto-de...@googlegroups.com
On Fri, Oct 05, 2018 at 06:35:34PM +0200, Daniel Maier wrote:
> Hi,
>
> I am trying to optimize loops with local dimensions like this:
>
> for(i=0; i<N; i++)
> if(i%2==0)
> S1();

What do you call a "local dimension"?

> However, I realized that Pluto asserts that there are no local
> dimensions. What is the exact reason for this?

What exactly did you do and what error message did you get?

skimo

Uday Kumar Reddy B

unread,
Oct 6, 2018, 1:26:19 PM10/6/18
to Daniel Maier, pluto-de...@googlegroups.com


On Friday 05 October 2018 09:35 AM, Daniel Maier wrote:
> Hi,
>
> I am trying to optimize loops with local dimensions like this:
>
> for(i=0; i<N; i++)
> if(i%2==0)
> S1();
>
> However, I realized that Pluto asserts that there are no local
> dimensions. What is the exact reason for this?

Although Pluto uses pet for parsing (and pet/isl can represent modulo
constraints), Pluto's data structures itself can't represent modulo (and
similarly div) constraints. The modulo's lead to local dimensions in
isl, and if these don't get eliminated ultimately, it leads to this
assertion. For eg., a case where the local dimension / modulo gets
eliminated is when i is known to be a multiple of two. Overall, this
issue can be fixed with additional support, but there are ways you can
workaround this depending on what your rest of the code looks like.

For eg., something like

M = N/2;
#pragma scop
for (i = 0; i < M; i++) {
S1(2i);
}
#pragma endscop

will work.

~ Uday

Uday Kumar Reddy B

unread,
Oct 6, 2018, 1:40:36 PM10/6/18
to David, Pluto development


On Saturday 06 October 2018 04:03 AM, David wrote:
> Well i experimenting with this tool for a while now, im not really an
> expert.
> All i know (or experienced) PLUTO hates modulo operator. Also wouldn't
> be easier to just:

That's right - modulo operator in conditionals/bounds won't work unless
the modulo gets eliminated / simplified. However, modulo's will usually
be fine in array access functions; most of the stencil code examples
with Pluto are in fact written this way and this is the preferred way to
write them for best performance:

a[i%2][...] = f(a[(i+1)%2] ...

Pluto uses 'pet' to parse and get hold of the statement domains, access
functions initially (which are just isl structures and thus able to
represent mod's div's w.r.t constants precisely), and then does
dependence analysis using isl while passing these structures directly;
finally, the result of these are converted to Pluto's structures
(PlutoProg, PlutoConstraints, etc.). It is this last step that will fail
if the local dimensions introduced due to mod's, div's can't be
eliminated and represented using a "dense" set/relation, which is what
Pluto's PlutoConstraints can represent. One of the reasons that this
wasn't changed is that Pluto still primarily uses cloog-isl/ for code
generation (through its text/file interface), and Cloog's input format
didn't (or still doesn't) allow local variables to be specified in domains.

~ Uday

>
> for(i=0; i<N; i+=2)
> S1();


>
>
> 2018. október 5., péntek 18:35:37 UTC+2 időpontban Daniel Maier a
> következőt írta:
>
> Hi,
>
> I am trying to optimize loops with local dimensions like this:
>
> for(i=0; i<N; i++)
> if(i%2==0)
> S1();
>
> However, I realized that Pluto asserts that there are no local
> dimensions. What is the exact reason for this?
>
> Is there any way around this limitation?
>
> Best regards
> Daniel
>
> --
> You received this message because you are subscribed to the Google
> Groups "Pluto development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pluto-developm...@googlegroups.com
> <mailto:pluto-developm...@googlegroups.com>.
> To post to this group, send email to pluto-de...@googlegroups.com
> <mailto:pluto-de...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/pluto-development.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages