GSOC2012 Project: Adding a data prefetching transformation to LLVM Polly – generating load-balanced and coarse-grain loop pipelinable code for more task level parallelism and data locality (Done and Todo)
Hi all! I want to make a post here about the recent progress of my project "adding a data prefetching transformation to LLVM Polly". Here's the done and todo list.
Done:
1) Add to polly a polly-pipfor
pass, which initially implements most of the analysis part of the Google Summer
of Code 2012 proposal: Adding a data prefetching transformation to LLVM Polly –
generating load-balanced and coarse-grain loop pipelinable code for more task
level parallelism and data locality http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/tangkk/1
For the moment, this pass can: a)
Extract the HEAD(which is a vector of those read memory accesses), FOOT(which
is a vector of those write memory accesses) and BODY(which is a vector of those
instructions occur between a pair of load and store); b) Tell the RAW or WAR dependence distances of those read or write
memory accesses within the same scopstmt; c)Provide
the instruction of each memory access; d)Brief calculate the LoadAnalysis
claimed at the proposal(but it seems not a good idea to do so in the llvm IR
level, so we may left this method here and add better things inside afterwards)
You can see inside the following testcases for more detail about the analysis
result.
2)
Add a Pipfor folder that contains 12 testcases, which can
represent many types of loop, for this pass:
test/Pipfor/2mm.ll
test/Pipfor/3mm.ll
test/Pipfor/RAW_loop.ll
test/Pipfor/WAR_loop.ll
test/Pipfor/correlation.ll
test/Pipfor/covariance.ll
test/Pipfor/matmul.ll
test/Pipfor/sim2mm.ll
test/Pipfor/simatax.ll
test/Pipfor/simbicg.ll
test/Pipfor/simdoitgen.ll
test/Pipfor/simple_loop.ll
All of these, except for the simbicg.ll, pass the test. Only simbicg.ll is
expected to fail. The test begins with “sim” is a paraphrase of the Polybench
test cases for simplicity, for example, sim2mm is a paraphrase of 2mm.The “sim”
version discards the kernel function call and replaces it with an inline kernel
within the main function.
3)
This analyzed pass is invoked through “-polly-pipfor”
option when individually schedule the polly passes, for example:
opt -S -mem2reg -loop-simplify -indvars $LLVMASM
> $LLVMIR
opt -basicaa -polly-prepare -polly-region-simplify -polly-detect -polly-pipfor
-analyze $LLVMIR
And it is invoked through “-polly-piploop” option when loading polly into
clang and automatically run it at -O3,for example:
pollycc -O3 -mllvm -polly $SOURCE -mllvm
-polly-piploop –mllvm
The patches are attached. Note that:
* Patch 0001 adds four helper functions for isl_aff and isl_pw_aff.
* Patch 0002 adds a getInstructionFor method to return the memory access instruction.
* Patch 0003 is the patch for the Pipfor Pass. It implements those things mentioned above.
* Patch 0004 is the patch for testcases.
Todo:
1) Separate the pass into several small commits that are logical related so as to be better reviewed
2) More different types of testcases. Write some guard statements to judge those cases that cannot be dealt with for the moment
3) Implement fine-grain statement
4) Include indirect dependence analysis
5) A webpage that shows the up-to-date progress or status of this project
6) If possible, the codegen part of my proposal.
Thanks for the patch,
Besides, A trivial test case to demonstrate this bug would be great.