blob: a148fafcbedb5d64cb7a90cdb3d4f335b9decf11 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Polly - Load Polly into clang</title>
<link type="text/css" rel="stylesheet" href="menu.css">
<link type="text/css" rel="stylesheet" href="content.css">
</head>
<body>
<!--#include virtual="menu.html.incl"-->
<div id="content">
<!--=====================================================================-->
<h1>Load Polly into clang and automatically run it at -O3</h1>
<!--=====================================================================-->
<p><b>Warning:</b> Even though this example makes it very easy to use Polly,
you should 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 <a
href="bugs.html">Bug database</a> and consider reporting a bug.
<p>
<b>Warning II:</b> clang/LLVM/Polly need to be in sync. This means
you need to compile them yourself from a recent svn/git checkout</b>
<h2>Load Polly into clang</h2>
By loading Polly into clang (or opt) the Polly options become automatically
available. You can load Polly either by adding the relevant commands to
the CPPFLAGS or by creating an alias.
<pre class="code">
$ export CPPFLAGS="-Xclang -load -Xclang ${POLLY_BUILD_DIR}/lib/LLVMPolly.so"
</pre>
or
<pre class="code">
$ alias pollycc clang -Xclang -load -Xclang ${POLLY_BUILD_DIR}/lib/LLVMPolly.so
</pre>
<h2>Optimizing with Polly</h2>
Optimizing with Polly is as easy as adding <b>-O3 -mllvm -polly</b> to your
compiler flags (Polly is only available at -O3).
<pre class="code">pollycc -O3 -mllvm -polly file.c</pre>
<h2>Automatic OpenMP code generation</h2>
To automatically detect parallel loops and generate OpenMP code for them you
also need to add <b>-mllvm -enable-polly-openmp -lgomp</b> to your CFLAGS.
<pre class="code">pollycc -O3 -mllvm -polly -mllvm -enable-polly-openmp -lgomp file.c</pre>
<h2>Automatic Vector code generation</h2>
Automatic vector code generation can be enabled by adding <b>-mllvm
-enable-polly-vector</b> to your CFLAGS.
<pre class="code">pollycc -O3 -mllvm -polly -mllvm -enable-polly-vector file.c</pre>
<h2>Extract a preoptimized LLVM-IR file</h2>
Often it is useful to derive from a C-file the LLVM-IR code that is actually
optimized by Polly. Normally the LLVM-IR is automatically generated from
the C code by first lowering C to LLVM-IR (clang) and by subsequently applying a
set of preparing transformations on the LLVM-IR. To get the LLVM-IR after the
preparing transformations have been applied run Polly with '-O0'.
<pre class="code">pollycc -O0 -mllvm -polly -S -emit-llvm file.c</pre>
<h2>Further options</h2>
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
<b>-mllvm -option-name</b> to the CFLAGS or the clang
command line.
<h3>Limit Polly to a single function</h3>
To limit the execution of Polly to a single function, use the option
<b>-polly-detect-only=functionname</b>.
<h3>Disable LLVM-IR generation</h3>
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 <b>polly-no-codegen</b>.
<h3>Graphical view of the SCoPs</h3>
Polly can use graphviz to show the SCoPs it detects in a program. The relevant
options are <b>-polly-show</b>, <b>-polly-show-only</b>, <b>-polly-dot</b> and
<b>-polly-dot-only</b>. 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.
<h3>Disable the polyhedral optimizer</h3>
Polly automatically runs by default a polyhedral optimizer to optimize the
schedules. <b>-polly-no-optimizer</b> disables this optimizer.
<h3>Change the Polly optimizer</h3>
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 <b>-polly-optimizer=pocc</b>.
<h3>Disable tiling in the optimizer</h3>
By default both optimizers perform tiling, if possible. In case this is not
wanted the option <b>-polly-no-tiling</b> can be used to disable it. (This
option disables tiling for both optimizers).
<h3>Ignore possible aliasing</h3>
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 <b>-polly-ignore-aliasing</b> can be used to disable the check for
possible aliasing.
<h3>Importing and exporting JScop files</h3>
The flags <b>-polly-run-import-jscop</b> and <b>-polly-run-export-jscop</b>
allow the export and reimport of the polyhedral representation that Polly
generates for the Scops.
</div>
</body>
</html>