[Polly] Allow multiple reductions in one statement

Johannes Doerfert jdoerfert at codeaurora.org
Thu Jun 26 17:10:54 PDT 2014


I changed the first loop nest to perform the task in linear time; the second
is still as it was.
I used the summary in the last mail as git commit message (thus I have the
comment in there).
Should I also add it to the code?

Is it ok (modulo adding the comment in the code also)?

--

Johannes Doerfert
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by
The Linux Foundation


-----Original Message-----
From: Tobias Grosser [mailto:tobias at grosser.es] 
Sent: Thursday, June 26, 2014 2:00 PM
To: Johannes Doerfert; llvm-commits at cs.uiuc.edu
Cc: 'Sebastian Pop'; 'zino'
Subject: Re: [Polly] Allow multiple reductions in one statement

On 26/06/2014 21:55, Johannes Doerfert wrote:
> Hey,
>
>
>
> I attached the patch to allow multiple reductions in one statement. 
> The dependency analysis changes over the last days allow us to handle 
> them now without further changes.
>

Nice, the patch is small and self contained.

> We discussed already the basic idea but to summarize it:
>
>    Look at each load-store pair in the statement and check if they are 
> connected by a binary operator which is commutative & associative.

This seems to be a quadratic algorithm. Not that we don't have such
algorithms in Polly, but in this case it seems that can be easily avoided if
we start from each write and just follow back the operator chain to return
the set of possible reduction reads.

The subsequent loop has again quadratic behaviour, but I would hope that the
actual number of reduction pairs is commonly small. So it seems less
important here.

>    If the load-store chain looks good we also verify that no other 
> access in this statement might "interfere", thus it might access the 
> same
>
>   memory locations at some point. This check overestimates the actual 
> problem but it is an easy way to guarantee no intermediate value
>
>    will escape or be overwritten during the execution. The 
> overestimation prevents us at the moment to consider statements like
>
> A[i] += A[j] which is a reduction for certain values of I and j but not
all.

I think this is worth a comment.

> I also attached a couple of test cases as we now are able to detect a 
> lot of different reductions.

Very nice.

> +
> +void ScopStmt::checkForReductions() {
> +  // Iterate over all load-store memory access pairs and check for 
> +valid binary
> +  // reductions. For all candidates we check if they have the same 
> +base address
> +  // and there are no other accesses wich overlapping with them.

which


Cheers,
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Allow-multiple-reductions-per-statement_v2.patch
Type: application/octet-stream
Size: 57175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140626/985aac11/attachment.obj>


More information about the llvm-commits mailing list