<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix"><tt>Sergei,</tt><tt><br>
</tt><tt><br>
</tt><tt>I reviewed the patch; LGTM.</tt><tt><br>
</tt><tt><br>
</tt><tt>-Anshu</tt><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt>
<p class="MsoNormal"><tt><span style="font-size: 10.5pt;">---<o:p></o:p></span></tt></p>
<tt><span style="font-size: 10.5pt;">Qualcomm Innovation Center,
Inc. is a member of Code Aurora Forum, hosted by The Linux
Foundation</span></tt><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt><tt>On 11/13/2012 11:41 AM, Sergei Larin wrote:</tt><tt><br>
</tt></div>
<blockquote cite="mid:000601cdc1c6$18f335d0$4ad9a170$@org"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 12 (filtered
medium)">
<base href="x-msg://10814/">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.apple-converted-space
{mso-style-name:apple-converted-space;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);">Andy and everyone interested, <o:p></o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);"> This patch addresses the MI DAG
construction indeterminism discussed in the thread below.
It also needs a new method (find()) for MapVector<>.<o:p></o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);">It tests clean on Hexagon and x86.<o:p></o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);">Please review.<o:p></o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);">Sergei<o:p></o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></tt></p>
<div>
<p class="MsoNormal"><tt><span style="font-size: 10.5pt;
color: rgb(31, 73, 125);">---<o:p></o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 10.5pt;
color: rgb(31, 73, 125);">Qualcomm Innovation Center,
Inc. is a member of Code Aurora Forum, hosted by The
Linux Foundation</span></tt><tt><span style="font-size:
10.5pt; color: rgb(31, 73, 125);"><o:p></o:p></span></tt></p>
</div>
<p class="MsoNormal"><tt><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></tt></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in
0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><tt><b><span style="font-size: 10pt;">From:</span></b></tt><tt><span
style="font-size: 10pt;"> Andrew Trick
[<a class="moz-txt-link-freetext" href="mailto:atrick@apple.com">mailto:atrick@apple.com</a>] <br>
<b>Sent:</b> Wednesday, October 17, 2012 5:57 PM<br>
<b>To:</b> Sergei Larin<br>
<b>Cc:</b> 'LLVM Developers Mailing List'<br>
<b>Subject:</b> Re: [LLVMdev] MI DAG constructor
indeterminism<o:p></o:p></span></tt></p>
</div>
</div>
<p class="MsoNormal"><tt><o:p> </o:p></tt></p>
<p class="MsoNormal"><tt><o:p> </o:p></tt></p>
<div>
<div>
<p class="MsoNormal"><tt>On Oct 17, 2012, at 3:10 PM,
Sergei Larin <</tt><tt><a moz-do-not-send="true"
href="mailto:slarin@codeaurora.org">slarin@codeaurora.org</a></tt><tt>>
wrote:</tt><tt><o:p></o:p></tt></p>
</div>
<p class="MsoNormal"><tt><br>
</tt><tt><br>
</tt><tt><o:p></o:p></tt></p>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);">Andy,</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> So if it is not a
feature… then couple questions:</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> First, I also do not
see an easy way to restructure work sets in this
case – so let’s assume std::map is needed here.
Then the way I understand it, there are five
objects that cause the indeterminism:</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> std::map<const
Value *, SUnit *> AliasMemDefs,
NonAliasMemDefs;</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> std::map<const
Value *, std::vector<SUnit *> >
AliasMemUses, NonAliasMemUses;</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> std::set<SUnit*>
RejectMemNodes;</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);">…since all of them at
different point of time are traversed begin to
end, and as such are affected by pointer value.</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);">The case of
“std::set<SUnit*> RejectMemNodes; “ is
easy. Something like this will work:</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);">struct SortSUComp {</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> bool
operator()(const SUnit *left, const SUnit *right)
const {</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> return
left->NodeNum < right->NodeNum;</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> }</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> };</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> typedef
std::set<SUnit*, SortSUComp> SortedSUSet;</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> SortedSUSet
RejectMemNodes;</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);">But in case of Value *
as a key – is there any unique ID that is
deterministic and could be used here? As I
understand getValueID () is not unique, or could
it be sufficient in this case?</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);">Something as bulky as
temporary sorting queue/vector is also possible,
but I do not like it very much.</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);">Any other ideas?</span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<p class="MsoNormal"><tt><o:p> </o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt>I don't have any great ideas, but
anything is an improvement over std::map/std::set.</tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><o:p> </o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt>AFAIK we don't need to remove
individual elements from the map. Is that right? So
SetVector and MapVector should work fine. They don't
sort by key but maintain a side vector to track
insertion order.</tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><o:p> </o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt>-Andy</tt><tt><o:p></o:p></tt></p>
</div>
<p class="MsoNormal"><tt><br>
</tt><tt><br>
</tt><tt><o:p></o:p></tt></p>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);">Thanks.</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);">Sergei</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
10.5pt; color: rgb(31, 73, 125);">---</span></tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
10.5pt; color: rgb(31, 73, 125);">Qualcomm
Innovation Center, Inc. is a member of Code
Aurora Forum, hosted by The Linux Foundation</span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
<div style="border:none;border-left:solid blue
1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF
1.0pt;padding:3.0pt 0in 0in 0in">
<div>
<p class="MsoNormal"><tt><b><span
style="font-size: 10pt;">From:</span></b></tt><tt><span
class="apple-converted-space"><span
style="font-size: 10pt;"> </span></span></tt><tt><span
style="font-size: 10pt;">Andrew Trick
[<a class="moz-txt-link-freetext" href="mailto:atrick@">mailto:atrick@</a><a moz-do-not-send="true"
href="http://apple.com">apple.com</a>]<span
class="apple-converted-space"> </span><br>
<b>Sent:</b><span
class="apple-converted-space"> </span>Tuesday,
October 16, 2012 10:44 PM<br>
<b>To:</b><span
class="apple-converted-space"> </span>Sergei
Larin<br>
<b>Cc:</b><span
class="apple-converted-space"> </span>'LLVM
Developers Mailing List'<br>
<b>Subject:</b><span
class="apple-converted-space"> </span>Re:
[LLVMdev] MI DAG constructor indeterminism</span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><tt> </tt><tt><o:p></o:p></tt></p>
</div>
<div>
<p class="MsoNormal"><tt> </tt><tt><o:p></o:p></tt></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><tt>On Oct 16, 2012, at 1:43
PM, Sergei Larin <</tt><tt><a
moz-do-not-send="true"
href="mailto:slarin@codeaurora.org"><span
style="color:purple">slarin@codeaurora.org</span></a></tt><tt>>
wrote:</tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<p class="MsoNormal"><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt><tt><o:p></o:p></tt></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
11pt; color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
11pt; color: rgb(31, 73, 125);">Andy,</span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
11pt; color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
11pt; color: rgb(31, 73, 125);"> This is
less of a question but rather a status quo
verification…</span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
11pt; color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
11pt; color: rgb(31, 73, 125);"> We
currently have certain indeterminism in MI
scheduler DAG construction – it is
introduces by the use of std::map/std::set
during edge traversal.</span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
11pt; color: rgb(31, 73, 125);">Result – a
random variation in SUnit edge order
(which will remain fixed thereafter).
Logically, it is the same DAG, but
topologically it is a slightly different
one, and if some algorithm is dependent on
the order of edge traversal, we can have
performance and debugging indeterminism.
The way I have discovered it – VLIW
scheduler can produce identical cost
function for a pair of SUs, making
visitation order the tie breaker, which is
not deterministic per above discussion.
For me it is trivial to fix, but I wonder
if this might become a source of well
hidden issues in the future.</span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
11pt; color: rgb(31, 73, 125);"> </span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt><span style="font-size:
11pt; color: rgb(31, 73, 125);"> I am at
this time not proposing anything – a fix
is definitely possible, but I wonder what
people think about it before I even
consider this a bug.</span></tt><tt><o:p></o:p></tt></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><tt> </tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt>This looks like a bug. The
edge order could even affect some heuristics and
influence codegen.</tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt> </tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt>I don't have a better idea
than using SetVector/MapVector for Value* keys.
For SUnits we could just key on NodeNum. Go
ahead and file a bug and/or submit a patch.</tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt> </tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt>Thanks!</tt><tt><o:p></o:p></tt></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><tt>-Andy</tt><tt><o:p></o:p></tt></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><tt><o:p> </o:p></tt></p>
</div>
</div>
<tt><br>
</tt>
<fieldset class="mimeAttachmentHeader"></fieldset>
<tt><br>
</tt>
<pre wrap="">_______________________________________________
llvm-commits mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a>
</pre>
</blockquote>
<tt><br>
</tt>
</body>
</html>