[LLVMdev] Vectorization metadata

Hongbin Zheng etherzhhb at gmail.com
Wed Apr 18 11:11:34 PDT 2012


On Thu, Apr 19, 2012 at 12:30 AM, Renato Golin <rengolin at systemcall.org> wrote:
> Hal,
>
> I'm opening a new discussion on vectorization metadata, since it has
> little to do with fp-math. ;)
>
> What kind of metadata would you annotate in the instructions? If I
> remember from your talk, you're not doing any loop or whole-function
> analysis, possibly leaving it for Polly to help you along the way.
>
> I remember discussing it with Tobias that Polly could have three main steps:
>
> 1. Early analysis and annotation: a step that wouldn't modify code,
> but extensively annotate (with metadata), so that itself, and other
> passes like yours, could benefit from the polyhedral model.
hi renato,

Instead of exporting the polyhedral model of the program with
metadata, another possible solution is designing a generic "Loop
Parallelism" analysis interface just like the AliasAnalysis group.
For a particular loop, the interface simply answer how many loop
iterations can run in parallel. With information provided by this
interface we can unroll the loop to expose vectorizable iterations and
apply vectorization to the unrolled loop with BBVectorizer.

Like AliasAnalysis we can have difference implementation of loop
parallelism analysis, i.e., we can have a light weight loop
parallelism Analysis implementation based on SCEV (or the
LoopDependency Analysis), and we can also have a Loop Parallelism
Analysis implementation based on polyhedral model analysis implemented
in polly (called polyhedral loop parallelism analysis), but analysis
result of Polly is not visible at the scope of FunctionPass/LoopPass
as all polly passes are RegionPasses right now.

To allow polly export its analysis result to FunctionPass/LoopPass, we
need to make the polyhedral loop parallelism analysis became a
FunctionPass, and schedule it before all polly passes but do nothing
in its runOnFunction method, after that we can let another pass of
polly to fill the actually analysis results into the polyhedral loop
parallelism analysis pass. By doing this, other
FunctionPasses/LoopPasses can query the parallelism information
calculated by Polly.

If the parallelism information is available outside polly, we can also
find some way to move code generation support for OpenMP, Vecorization
and CUDA from Polly to LLVM transformation library, after that we can
also generate such code base on the analysis result of the SCEV based
parallelism analysis.

best regards
ether


>
> 2. Full polyhedral code modification: use the annotation of the
> previous pass to extensively modify code. This is what Polly does
> today, but the result of the analysis is not benefiting anyone except
> for Polly.
>
> This step can be fused with step 1 for performance reasons, but would
> be good to be able to pass only the analysis part
>  for the benefit of the annotation, without the heavy modifications.
> This will be fundamental for independently testing  vectorization
> passes that depend on Polly's metadata.
>
> 3. Code generation steps. As you said in your talk, and we discussed
> in the fp-math thread, some code-generation steps could be aware of
> the optimizations done via the metadata that was left in it.
>
> That will require some guarantees on metadata semantics and
> persistence that is not available today... Anyway, not sure any
> metadata-hardening will be very well accepted... ;)
>
> --
> cheers,
> --renato
>
> http://systemcall.org/
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list