<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi, Tom,</p>
<p>Yes, OpenMP SIMD hints are currently translated into metadata
that is used by the vectorizer. If you'd like to know how that's
done, see:</p>
<p><a class="moz-txt-link-freetext"
href="http://llvm.org/docs/LangRef.html#llvm-mem-parallel-loop-access-metadata">http://llvm.org/docs/LangRef.html#llvm-mem-parallel-loop-access-metadata</a></p>
<p>(and should also enable the vectorizer: <a
class="moz-txt-link-freetext"
href="http://llvm.org/docs/LangRef.html#llvm-loop-vectorize-enable-metadata">http://llvm.org/docs/LangRef.html#llvm-loop-vectorize-enable-metadata</a>)</p>
<p>The relevant Clang code is in clang/lib/CodeGen/CGLoopInfo.cpp
and lib/CodeGen/CGStmtOpenMP.cpp (see, in particular, the comments
around emitSimdlenSafelenClause and EmitOMPSimdInit regarding
safelen and semantics).</p>
<p>The relevant check for the vectorizer is in
LoopAccessAnalysis.cpp:</p>
<p> const bool IsAnnotatedParallel =
TheLoop->isAnnotatedParallel();<br>
</p>
<p>where isAnnotatedParallel checks for the parallel-loop-access
metadata (that indicates that the loop is data parallel) and is
part of LoopInfo.</p>
<p> -Hal<br>
</p>
<br>
<div class="moz-cite-prefix">On 01/19/2018 02:38 AM, Tom Sun via
llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:dc432999-b092-1cf4-112e-661ba6f255d7@cam.ac.uk">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<p style="margin: 0px 0px 1em; padding: 0px; border: 0px;
font-family: Arial, "Helvetica Neue", Helvetica,
sans-serif; font-size: 15px; font-style: normal;
font-variant-caps: normal; font-weight: normal; font-stretch:
inherit; line-height: inherit; vertical-align: baseline; clear:
both; color: rgb(36, 39, 41); letter-spacing: normal; orphans:
auto; text-align: left; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing: 0px;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">Hi
all,<br>
</p>
<p style="margin: 0px 0px 1em; padding: 0px; border: 0px;
font-family: Arial, "Helvetica Neue", Helvetica,
sans-serif; font-size: 15px; font-style: normal;
font-variant-caps: normal; font-weight: normal; font-stretch:
inherit; line-height: inherit; vertical-align: baseline; clear:
both; color: rgb(36, 39, 41); letter-spacing: normal; orphans:
auto; text-align: left; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing: 0px;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">I
am currently looking into how "#pragma omp for simd" is actually
recognized in llvm. To my knowledge, clang will parse it and set
metadata in IR to indicate this force-vectorization hint and
later optimization passes would read it and vectorize the marked
loop. Therefore, the loop should be vectorized even the compiler
think it might not be safe to do so?</p>
<p style="margin: 0px 0px 1em; padding: 0px; border: 0px;
font-family: Arial, "Helvetica Neue", Helvetica,
sans-serif; font-size: 15px; font-style: normal;
font-variant-caps: normal; font-weight: normal; font-stretch:
inherit; line-height: inherit; vertical-align: baseline; clear:
both; color: rgb(36, 39, 41); letter-spacing: normal; orphans:
auto; text-align: left; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing: 0px;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">So
my assumption is that such force-vectorization hints should
bypass both the vectorization legality and cost model check.
However, in LoopVectorize.cpp, I can't see how this is done. All
loops will be sent to a legality check of LVL.canVectorize()
and, if this condition does not fit, it return to false directly
without actually reaching the vectorization stage.<span
class="Apple-converted-space"> </span></p>
<p style="margin: 0px 0px 1em; padding: 0px; border: 0px;
font-family: Arial, "Helvetica Neue", Helvetica,
sans-serif; font-size: 15px; font-style: normal;
font-variant-caps: normal; font-weight: normal; font-stretch:
inherit; line-height: inherit; vertical-align: baseline; clear:
both; color: rgb(36, 39, 41); letter-spacing: normal; orphans:
auto; text-align: left; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing: 0px;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">Is
there anything wrong with my assumption made on the use of
force-vectorization hints?</p>
<p style="margin: 0px 0px 1em; padding: 0px; border: 0px;
font-family: Arial, "Helvetica Neue", Helvetica,
sans-serif; font-size: 15px; font-style: normal;
font-variant-caps: normal; font-weight: normal; font-stretch:
inherit; line-height: inherit; vertical-align: baseline; clear:
both; color: rgb(36, 39, 41); letter-spacing: normal; orphans:
auto; text-align: left; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing: 0px;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">Thanks
in advance,</p>
<p style="margin: 0px 0px 1em; padding: 0px; border: 0px;
font-family: Arial, "Helvetica Neue", Helvetica,
sans-serif; font-size: 15px; font-style: normal;
font-variant-caps: normal; font-weight: normal; font-stretch:
inherit; line-height: inherit; vertical-align: baseline; clear:
both; color: rgb(36, 39, 41); letter-spacing: normal; orphans:
auto; text-align: left; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing: 0px;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">T<br>
</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</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>