Load Polly into clang and automatically run it at -O3
Warning: This example makes it very easy to use Polly. Still, please be aware
that Polly is a young research project. It is expected to crash, produce
invalid code or to hang in complex calculations even for simple examples. In
case you see such a problem, please check the Bug
database and consider reporting the bug.
Compiling code with Polly
To compile code with Polly you only need to add
-Xclang -load -Xclang
${POLLY_BUILD_DIR}/lib/LLVMPolly.so to your command line or your CFLAGS and
Polly is automatically executed at -O3.
WARNING: clang/LLVM/Polly need to be in sync. This means
you need to compile them yourself from a recent svn/git checkout
clang -Xclang -load -Xclang ${POLLY_BUILD_DIR}/lib/LLVMPolly.so -O3 file.c
Automatic OpenMP code generation
To automatically detect parallel loops and generate OpenMP code for them you
also need to add
-mllvm -enable-polly-openmp -lgomp to your CFLAGS.
clang -Xclang -load -Xclang ${POLLY_BUILD_DIR}/lib/LLVMPolly.so -O3 -mllvm -enable-polly-openmp -lgomp file.c
Automatic Vector code generation
Automatic vector code generation can be enabled by adding
-mllvm
-enable-polly-vector to your CFLAGS.
clang -Xclang -load -Xclang ${POLLY_BUILD_DIR}/lib/LLVMPolly.so -O3 -mllvm -enable-polly-vector file.c
Further options
Polly supports further options that are mainly useful for the development or
the
analysis of Polly. The relevant options can be added to clang by appending
-mllvm -option-name to the CFLAGS or the clang
command line.
Limit Polly to a single function
To limit the execution of Polly to a single function, use the option
-polly-detect-only=functionname.
Disable LLVM-IR generation
Polly normally regenerates LLVM-IR from the Polyhedral representation. To only
see the effects of the preparing transformation, but to disable Polly code
generation add the option
polly-no-codegen.
Graphical view of the SCoPs
Polly can use graphviz to show the SCoPs it detects in a program. The relevant
options are
-polly-show,
-polly-show-only,
-polly-dot and
-polly-dot-only. The 'show' options automatically run dotty or another
graphviz viewer to show the scops graphically. The 'dot' options store for each
function a dot file that highlights the detected SCoPs. If 'only' is appended at
the end of the option, the basic blocks are shown without the statements the
contain.
Disable the polyhedral optimizer
Polly automatically runs by default a polyhedral optimizer to optimize the
schedules.
-polly-no-optimizer disables this optimizer.
Use the PoCC optimizer
Polly uses by default the isl scheduling optimizer, a new implementation of the
well known Pluto algorithm. The main reason for the isl scheduler being the
default is that it does not require any additional libraries or tools to be
installed. As the new scheduler may still have some bugs and because being
able to compare is good in general, it is possible to switch the used optimizer
back to PoCC. For this add the option
-polly-use-pocc.
Disable tiling in the optimizer
By default both optimizers perform tiling, if possible. In case this is not
wanted the option
-polly-no-tiling can be used to disable it. (This
option disables tiling for both optimizers).
Ignore possible aliasing
By default we only detect scops, if we can prove that the different array bases
can not alias. This is correct do if we optimize automatically. However,
without special user annotations like 'restrict' we can often not prove that
no aliasing is possible. In case the user knows no aliasing can happen in the
code the
-polly-ignore-aliasing can be used to disable the check for
possible aliasing.
Importing and exporting JScop files
The flags
-polly-run-import-jscop and
-polly-run-export-jscop
allow the export and reimport of the polyhedral representation that Polly
generates for the Scops.