[Polly] Allow multiple reductions in one statement

Tobias Grosser tobias at grosser.es
Thu Jun 26 13:59:47 PDT 2014


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



More information about the llvm-commits mailing list