<div dir="ltr"><div>Hi Sjoerd,<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 3, 2019 at 8:19 AM Sjoerd Meijer via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="gmail-m_-8372716903124045064appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I read that out-of-order cores are supported. How about in-order cores? Would it be easy/difficult to add support for that?</div>
<div> 
<br></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Cheers,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Sjoerd.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br></div></div></blockquote><div><br></div><div>I don't think that it would be difficult to support in-order superscalar cores.</div><div>However, it would require a different llvm-mca pipeline of stages. That is because some stages (and simulated hardware components) work under the assumption that the processor is out-of-order (example: the dispatch stage and the retire stage).</div><div>That being sadi, it would be a bit more complicated to add support instruction itineraries. At the moment, the tool doesn't understand itineraries.<br></div><div><br></div><div>If there is interest in supporting in-order cores, then we should probably raise a bug for it.</div><div><br></div><div>-Andrea</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-8372716903124045064divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> on behalf of Matt Davis via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Sent:</b> 02 May 2019 19:59<br>
<b>To:</b> Shoaib Meenai; lorenzo chelini; <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [llvm-dev] Llvm-mca library.</font>
<div> </div>
</div>
<div lang="EN-US">
<div class="gmail-m_-8372716903124045064x_WordSection1">
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
Hi Lorenzo,</p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
I’ll answer the first question you have:</p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue"">> I would like to use llvm-mca to estimate the IPC of a given code region. I am interested in the library version (<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D50929-3Fid-3D162210&d=DwMFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=Ehy5cbFrTOTrtNpj4jTjwnMXspCxyoUuKpn3m8pxGpg&s=iEwPb0T8FqcGV-IscWqa3SAw64L-buGNLYvMLOgWoi4&e=" target="_blank">https://reviews.llvm.org/D50929?id=162210</a>)
 but I have troubles understanding how to use it. Could you please point me to some documentations or (better) some code examples if any?</span></p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
The best example of the llvm-mca library being used is the actual llvm-mca tool itself.  If you look in llvm/tools/llvm-mca/llvm-mca.cpp you’ll see that it is just a large program that uses the llvm-mca API and library.  You’ll want to look at main() where
 the default pipline is created and the viewers are associated to that pipeline instance.</p>
<ol start="1" style="margin-bottom:0in;margin-top:0in" type="1">
<li class="gmail-m_-8372716903124045064x_MsoListParagraph" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
You’ll need to construct an mca::Context and use that to create a mca::Pipeline instance.  For starters, I suggest just using the default “out-of-order” pipeline.  “createDefaultPipeline”</li><li class="gmail-m_-8372716903124045064x_MsoListParagraph" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
Next, register some handlers take a look at the HWEventListener class in include/llvm/MCA.  Use “Pipeline::addEventListener” to register for the events you might be interested in, such as pipeline stalls.</li></ol>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt 0.5in;font-size:11pt;font-family:Calibri,sans-serif">
llvm-mca.cpp does this on behalf of the Viewers.  If you trace what the viewers are doing in the source file, you’ll probably</p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt 0.5in;font-size:11pt;font-family:Calibri,sans-serif">
want to do something similar. </p>
<ol start="3" style="margin-bottom:0in;margin-top:0in" type="1">
<li class="gmail-m_-8372716903124045064x_MsoListParagraph" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
Call “Pipeline::run” to start your experiment and collect performance information.</li></ol>
<p class="gmail-m_-8372716903124045064x_MsoListParagraph" style="margin:0in 0in 0.0001pt 0.5in;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
Your second question:</p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue"">> Reading the documentation (<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_docs_CommandGuide_llvm-2Dmca.html&d=DwMFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=Ehy5cbFrTOTrtNpj4jTjwnMXspCxyoUuKpn3m8pxGpg&s=5845DcPA4uSN_lgPE_SlH6XwRSShIfPIvYR1t8AZHpU&e=" target="_blank">https://llvm.org/docs/CommandGuide/llvm-mca.html</a>)
 it also seems that llvm-mca does not take into account the cache hierarchy. Does this mean that the tool assumes all the loads/stores hit the L1 cache?</span></p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
As you pointed out, MCA does not really model the cache hierarchy.  You might want to take a look at the Load/Store unit documentation as well:
<a href="http://llvm.org/doxygen/classllvm_1_1mca_1_1LSUnit.html" target="_blank">http://llvm.org/doxygen/classllvm_1_1mca_1_1LSUnit.html</a></p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
You probably already saw this from the CommandGuide for llvm-mca, but I’ll repeat it here:</p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
“The LSUnit does not attempt to predict if a load or store hits or misses the L1 cache. It only knows if an instruction “MayLoad” and/or “MayStore.” For loads, the scheduling model provides an “optimistic” load-to-use latency (which usually matches the load-to-use
 latency for when there is a hit in the L1D).”</p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
Hope that helps,</p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
-Matt</p>
<p class="gmail-m_-8372716903124045064x_MsoListParagraph" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-size:10.5pt;font-family:"Lucida Grande",sans-serif;color:black;background:white none repeat scroll 0% 0%"> </span></p>
<p class="gmail-m_-8372716903124045064x_MsoListParagraph" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
<div style="border-color:rgb(181,196,223) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in">
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<b><span style="font-size:12pt;color:black">From: </span></b><span style="font-size:12pt;color:black">Shoaib Meenai <<a href="mailto:smeenai@fb.com" target="_blank">smeenai@fb.com</a>><br>
<b>Date: </b>Thursday, May 2, 2019 at 11:34 AM<br>
<b>To: </b>lorenzo chelini <<a href="mailto:l.chelini@icloud.com" target="_blank">l.chelini@icloud.com</a>>, "<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>, Matt Davis <<a href="mailto:nullptr@fb.com" target="_blank">nullptr@fb.com</a>><br>
<b>Subject: </b>Re: [llvm-dev] Llvm-mca library.</span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
</div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
(Adding Matt Davis, who should be able to help out here.)</p>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
<div style="border-color:rgb(181,196,223) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in">
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<b><span style="font-size:12pt;color:black">From: </span></b><span style="font-size:12pt;color:black">llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> on behalf of lorenzo chelini via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Reply-To: </b>lorenzo chelini <<a href="mailto:l.chelini@icloud.com" target="_blank">l.chelini@icloud.com</a>><br>
<b>Date: </b>Thursday, May 2, 2019 at 4:15 AM<br>
<b>To: </b>"<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject: </b>[llvm-dev] Llvm-mca library.</span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
 </p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue"">Hi All,</span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue""> </span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue"">I would like to use llvm-mca to estimate the IPC of a given code region. I am interested in the library version (<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D50929-3Fid-3D162210&d=DwMFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=Ehy5cbFrTOTrtNpj4jTjwnMXspCxyoUuKpn3m8pxGpg&s=iEwPb0T8FqcGV-IscWqa3SAw64L-buGNLYvMLOgWoi4&e=" target="_blank">https://reviews.llvm.org/D50929?id=162210</a>)
 but I have troubles understanding how to use it. Could you please point me to some documentations or (better) some code examples if any?</span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue""> </span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue"">Reading the documentation (<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_docs_CommandGuide_llvm-2Dmca.html&d=DwMFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=Ehy5cbFrTOTrtNpj4jTjwnMXspCxyoUuKpn3m8pxGpg&s=5845DcPA4uSN_lgPE_SlH6XwRSShIfPIvYR1t8AZHpU&e=" target="_blank">https://llvm.org/docs/CommandGuide/llvm-mca.html</a>)
 it also seems that llvm-mca does not take into account the cache hierarchy. Does this mean that the tool assumes all the loads/stores hit the L1 cache?</span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue""> </span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue"">Looking forward to hearing from you.</span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue"">Best regards,</span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue""> </span></p>
</div>
<div>
<p class="gmail-m_-8372716903124045064x_MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">
<span style="font-family:"Helvetica Neue"">Lorenzo Chelini.</span></p>
</div>
</div>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>