<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><br>
</p>
<div class="moz-cite-prefix">On 07/01/2017 05:33 PM, hameeza ahmed
wrote:<br>
</div>
<blockquote
cite="mid:CAFMPKeZEPLLV6aaFb00hcSZTg1d4LRrBdimH-VPmBnij3caYfg@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div dir="ltr">I am able to vectorize it with the following code;
<div><br>
</div>
<div>
<div>#include <stdio.h></div>
<div>#define N 100351</div>
<div> </div>
<div>// This function computes 2D-5 point Jacobi stencil </div>
<div>void stencil(int a[][N], int b[][N])</div>
<div>{</div>
<div> int i, j, k;</div>
<div> for (k = 0; k < N; k++) {</div>
<div> for (i = 1; i <= N-2; i++)</div>
<div> for (j = 1; j <= N-2; j++)</div>
<div> <span style="white-space:pre"> </span> b[i][j] =
0.25 * (a[i][j] + a[i-1][j] + a[i+1][j] + a[i][j-1] +
a[i][j+1]);</div>
<div><br>
</div>
<div>for (i = 1; i <= N-2; i++)</div>
<div><span style="white-space:pre"> </span>for (j = 1; j <=
N-2; j++)</div>
<div><span style="white-space:pre"> </span> a[i][j] =
b[i][j];</div>
<div> </div>
<div>}</div>
<div>}</div>
</div>
<div><br>
</div>
<div>I removed restrict over here.</div>
</div>
</blockquote>
<br>
That seems odd. Can you please file a bug report?<br>
<br>
-Hal<br>
<br>
<blockquote
cite="mid:CAFMPKeZEPLLV6aaFb00hcSZTg1d4LRrBdimH-VPmBnij3caYfg@mail.gmail.com"
type="cite">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sun, Jul 2, 2017 at 3:11 AM, hameeza
ahmed <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:hahmed2305@gmail.com" target="_blank">hahmed2305@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">further i modified the code to the following;
<div><br>
</div>
<div><span class="">
<div>#include <stdio.h></div>
<div>#define N 100351</div>
<div> </div>
<div>// This function computes 2D-5 point Jacobi
stencil </div>
</span>
<div>void stencil(int a[restrict][N], int
b[restrict][N])</div>
<div>{</div>
<div> int i, j, k;</div>
<div> for (k = 0; k < N; k++) {</div>
<span class="">
<div> for (i = 1; i <= N-2; i++)</div>
<div> for (j = 1; j <= N-2; j++)</div>
</span>
<div> <span style="white-space:pre-wrap"> </span>
b[i][j] = 0.25 * (a[i][j] + a[i-1][j] + a[i+1][j] +
a[i][j-1] + a[i][j+1]);</div>
<span class="">
<div><br>
</div>
<div>for (i = 1; i <= N-2; i++)</div>
<div><span style="white-space:pre-wrap"> </span>for (j
= 1; j <= N-2; j++)</div>
</span>
<div><span style="white-space:pre-wrap"> </span>
a[i][j] = b[i][j];</div>
<div> </div>
<div>}</div>
<div>}</div>
<div><br>
</div>
<div> but still no vectorization in IR. Also, when I
set vector width explicitly to 64, it gives the
following error:</div>
</div>
<div><br>
</div>
<div>
<div>remark: <unknown>:0:0: loop not vectorized:
call instruction cannot be vectorized</div>
<div>remark: <unknown>:0:0: loop not vectorized:
value that could not be identified as reduction is
used outside the loop</div>
</div>
<div><br>
</div>
<div>I need serious help on this. Please guide me.</div>
</div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sun, Jul 2, 2017 at 1:54
AM, hameeza ahmed <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:hahmed2305@gmail.com"
target="_blank">hahmed2305@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="auto">Does it happen due to loop carried
dependence? if yes what is the solution to
vectorize such codes?
<div dir="auto"><br>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">please reply. i m waiting.</div>
</div>
<div class="m_111627299988929908HOEnZb">
<div class="m_111627299988929908h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Jul 1, 2017
12:30 PM, "hameeza ahmed" <<a
moz-do-not-send="true"
href="mailto:hahmed2305@gmail.com"
target="_blank">hahmed2305@gmail.com</a>>
wrote:<br type="attribution">
<blockquote class="gmail_quote"
style="margin:0 0 0 .8ex;border-left:1px
#ccc solid;padding-left:1ex">
<div dir="ltr">I even tried polly but
still my llvm IR does not contain
vector instructions. i used the
following command;
<div><br>
</div>
<div>
<div>clang -S -emit-llvm stencil.c
-march=knl -O3 -mllvm -polly
-mllvm -polly-vectorizer=stripmine
-o stencil_poly.ll</div>
</div>
<div><br>
</div>
<div>Please specify what is wrong with
my code?</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sat, Jul
1, 2017 at 4:08 PM, hameeza ahmed <span
dir="ltr"><<a
moz-do-not-send="true"
href="mailto:hahmed2305@gmail.com"
target="_blank">hahmed2305@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir="ltr">Hello,
<div><br>
</div>
<div>I am trying to vectorize
following stencil code;</div>
<div><br>
</div>
<div>
<div>#include <stdio.h></div>
<div>#define N 100351</div>
<div> </div>
<div>// This function computes
2D-5 point Jacobi stencil </div>
<div>void stencil(int
a[restrict][N])</div>
<div>{</div>
<div> int i, j, k;</div>
<div> for (k = 0; k <
100; k++)</div>
<div> { for (i = 1; i
<= N-2; i++)</div>
<div> { for (j = 1; j
<= N-2; j++)</div>
<div> <span style="white-space:pre-wrap"> </span>{
a[i][j] = 0.25 * (a[i][j] +
a[i-1][j] + a[i+1][j] +
a[i][j-1] + a[i][j+1]);</div>
<div> }</div>
<div>}</div>
<div>}}</div>
</div>
<div><br>
</div>
<div>I have used the following
commands</div>
<div><br>
</div>
<div>clang -S -emit-llvm
stencil.c -march=knl -O3
-mllvm -disable-llvm-optzns -o
stencil.ll<br>
</div>
<div><br>
</div>
<div>opt -S -O3 stencil.ll -o
stencil_o3.ll<br>
</div>
<div><br>
</div>
<div>llc -x86-asm-syntax=intel
stencil_o3.ll -o stencil.s<br>
</div>
<div><br>
</div>
<div>But the code is not
vectorized. It still uses the
scalar instructions;</div>
<div><br>
</div>
<div>Please correct me.</div>
<div><br>
</div>
<div>Thank You</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>