mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 03:29:57 +00:00
www: Adding webpage to track memory access transformation
llvm-svn: 133354
This commit is contained in:
parent
94085eaa83
commit
49a3a7ba20
143
polly/www/documentation/memaccess.html
Normal file
143
polly/www/documentation/memaccess.html
Normal file
@ -0,0 +1,143 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=ISO-8859-1"
|
||||
http-equiv="Content-Type">
|
||||
<title>memaccess.html</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="margin-left: 320px;"><small style="font-weight: bold;"><small><a><big><big><big>Support
|
||||
for
|
||||
memory access
|
||||
transformations in Polly</big></big></big></a></small></small><big><span
|
||||
style="font-weight: bold;"></span></big><br>
|
||||
<big><span style="font-weight: bold;"></span></big><br>
|
||||
<div style="text-align: left;"><strong></strong>This project adds
|
||||
memory access transformations to Polly. In many cases<br>
|
||||
changing the memory access pattern yields to better data
|
||||
locality or removes<br>
|
||||
dependences that would otherwise block
|
||||
transformations. They may also<br>
|
||||
allow LLVM to use registers to store
|
||||
certain values.<br>
|
||||
</div>
|
||||
<br>
|
||||
An examples which uses this feature is given below<br>
|
||||
</div>
|
||||
<div style="margin-left: 320px;"><br>
|
||||
Consider the following loop
|
||||
<ul>
|
||||
<ul>
|
||||
</ul>
|
||||
</ul>
|
||||
<div style="margin-left: 40px;"><small style="font-style: italic;">for
|
||||
(i = 0; i < 8; i++)</small><br>
|
||||
<small style="font-style: italic;">sum += A[i];</small><br
|
||||
style="font-style: italic;">
|
||||
</div>
|
||||
<br>
|
||||
With support for memory access transformation this loop can be executed<br>
|
||||
in parallel. It can be
|
||||
transformed to<small style="font-style: italic;"><br>
|
||||
<br>
|
||||
</small>
|
||||
<div style="margin-left: 40px;"><small style="font-style: italic;"><create
|
||||
and
|
||||
initialize an array 'tmp'
|
||||
with size 4></small><br>
|
||||
<small style="font-style: italic;">for (i = 0; i < 8; i++) {</small><br>
|
||||
<small style="font-style: italic;">tmp[i % 4] += A[i];</small><br>
|
||||
<small style="font-style: italic;">}</small><small><span
|
||||
style="font-style: italic;"></span></small><br>
|
||||
<small><span style="font-style: italic;">sum = tmp[0] + tmp[1] + tmp[2]
|
||||
+ tmp[3];</span></small><br>
|
||||
</div>
|
||||
<br>
|
||||
With the help of some optimizer (like
|
||||
PluTo) the following code can be <br>
|
||||
generated, where the outer loop is
|
||||
parallel.
|
||||
<p style="padding-left: 30px; font-style: italic;"><small>parfor (ii =
|
||||
0; ii < 4; ii++) {<br>
|
||||
tmp[ii] = 0;<br>
|
||||
for (i = ii * 2; i < (ii+1) * 2; i++)<br>
|
||||
tmp[ii] += A[i];</small></p>
|
||||
<p style="padding-left: 30px; font-style: italic; font-weight: bold;"><small><span
|
||||
style="font-weight: normal;">}</span><br style="font-weight: normal;">
|
||||
<span style="font-weight: normal;">sum = tmp[0] + tmp[1] + tmp[2] +
|
||||
tmp[3];</span><br>
|
||||
<strong></strong></small></p>
|
||||
<p><strong><span style="text-decoration: underline;">TODO<br>
|
||||
</span></strong></p>
|
||||
<p><strong><span style="text-decoration: underline;"><small>Step 1</small><br>
|
||||
</span></strong></p>
|
||||
Polly exports its polyhedral description in a JSCoP file. Define how
|
||||
memory <small><br>
|
||||
</small>layout transformations are going to be expressed in Polly and
|
||||
in
|
||||
the JSCOP file. <br>
|
||||
A simple example is given below.<br>
|
||||
<br>
|
||||
Consider the following loop.<br>
|
||||
<br>
|
||||
<div style="margin-left: 40px;"><small><span style="font-style: italic;">for
|
||||
(i
|
||||
= 0; i < 12; i++)</span><br style="font-style: italic;">
|
||||
<span style="font-style: italic;"> A[i] = 0;</span><br
|
||||
style="font-style: italic;">
|
||||
</small></div>
|
||||
<br>
|
||||
In the JSCOP file the memory is represented as follows.<br>
|
||||
<br>
|
||||
<div style="margin-left: 40px;"><small><span style="font-style: italic;">
|
||||
"accesses":
|
||||
[{</span></small><br style="font-style: italic;">
|
||||
<small><span style="font-style: italic;">
|
||||
"kind":
|
||||
"write",</span></small><br style="font-style: italic;">
|
||||
<small><span style="font-style: italic;">
|
||||
"relation":
|
||||
"{
|
||||
Stmt[i] -> </span><strong
|
||||
style="font-style: italic; font-weight: bold;">A</strong><span
|
||||
style="font-style: italic;"><span style="font-weight: bold;">[i]</span>
|
||||
}"</span></small><br style="font-style: italic;">
|
||||
<small><span style="font-style: italic;"> }]</span></small><br
|
||||
style="font-style: italic;">
|
||||
</div>
|
||||
<br>
|
||||
Suppose
|
||||
we want to perform a transformation such that the following<br>
|
||||
code is generated<br>
|
||||
<br>
|
||||
<div style="margin-left: 40px;"><small><span style="font-style: italic;">for
|
||||
(i
|
||||
= 0; i < 12; i++)</span><br style="font-style: italic;">
|
||||
<span style="font-style: italic;">
|
||||
A[0] = i;</span><br style="font-style: italic;">
|
||||
</small></div>
|
||||
<br>
|
||||
The corresponding JSCOP file represenation would be<br>
|
||||
<br>
|
||||
<div style="margin-left: 40px;"><small><span style="font-style: italic;">
|
||||
"accesses":
|
||||
[{</span><br style="font-style: italic;">
|
||||
<span style="font-style: italic;">
|
||||
"kind":
|
||||
"read",</span><br style="font-style: italic;">
|
||||
<span style="font-style: italic;">
|
||||
"relation":
|
||||
"{
|
||||
Stmt[i] -> </span><strong
|
||||
style="font-style: italic; font-weight: bold;">A</strong><span
|
||||
style="font-style: italic;"><span style="font-weight: bold;">[0]</span>
|
||||
}"</span><br style="font-style: italic;">
|
||||
<span style="font-style: italic;"> }]</span><br
|
||||
style="font-style: italic;">
|
||||
</small></div>
|
||||
<br>
|
||||
We need to detect this access function change.<br>
|
||||
</div>
|
||||
<span id="q_12f99e5de7fd0932_1" class="h4"></span>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user