<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 11, 2021 at 2:21 PM users users via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear LLVM Developers:<div><br></div><div>1.   Recently I built llvm/12.0 on IBM power8 using gcc/<a href="http://8.2.0." target="_blank">8.2.0.</a> When I run clang++ with an example from <a href="https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique" target="_blank">https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique</a>:</div><div><br></div><div> <span style="color:rgb(51,153,0);background-color:rgb(249,249,249);font-size:12.8px">#include <iostream></span></div><pre style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12.8px;line-height:1.2em;padding:0px;border:0px none white;color:rgb(0,0,0);background-image:none;background-color:rgb(249,249,249);border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;margin-top:0px;margin-bottom:0px;width:55em;overflow:auto;vertical-align:top;background-position:initial initial;background-repeat:initial initial"><span style="color:rgb(51,153,0)">#include <iomanip></span>
<span style="color:rgb(51,153,0)">#include <memory></span>
 
<span style="color:rgb(0,0,221)">struct</span> Vec3
<span style="color:rgb(0,128,0)">{</span>
    <span style="color:rgb(0,0,255)">int</span> x, y, z<span style="color:rgb(0,128,128)">;</span>
 
    <span style="color:rgb(144,144,144)">// following constructor is no longer needed since C++20</span>
    Vec3<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,0,255)">int</span> x <span style="color:rgb(0,0,128)">=</span> <span style="color:rgb(0,0,128)">0</span>, <span style="color:rgb(0,0,255)">int</span> y <span style="color:rgb(0,0,128)">=</span> <span style="color:rgb(0,0,128)">0</span>, <span style="color:rgb(0,0,255)">int</span> z <span style="color:rgb(0,0,128)">=</span> <span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,128,0)">)</span> <span style="color:rgb(0,0,221)">noexcept</span> <span style="color:rgb(0,128,128)">:</span> x<span style="color:rgb(0,128,0)">(</span>x<span style="color:rgb(0,128,0)">)</span>, y<span style="color:rgb(0,128,0)">(</span>y<span style="color:rgb(0,128,0)">)</span>, z<span style="color:rgb(0,128,0)">(</span>z<span style="color:rgb(0,128,0)">)</span> <span style="color:rgb(0,128,0)">{</span> <span style="color:rgb(0,128,0)">}</span>
 
    <span style="color:rgb(0,0,221)">friend</span> <a href="http://en.cppreference.com/w/cpp/io/basic_ostream" style="text-decoration-line:none;color:rgb(0,48,128);background-image:none;background-position:initial initial;background-repeat:initial initial" target="_blank"><span>std::<span>ostream</span></span></a><span style="color:rgb(0,0,64)">&</span> operator<span style="color:rgb(0,0,128)"><<</span><span style="color:rgb(0,128,0)">(</span><a href="http://en.cppreference.com/w/cpp/io/basic_ostream" style="text-decoration-line:none;color:rgb(0,48,128);background-image:none;background-position:initial initial;background-repeat:initial initial" target="_blank"><span>std::<span>ostream</span></span></a><span style="color:rgb(0,0,64)">&</span> os, <span style="color:rgb(0,0,255)">const</span> Vec3<span style="color:rgb(0,0,64)">&</span> v<span style="color:rgb(0,128,0)">)</span> <span style="color:rgb(0,128,0)">{</span>
        <span style="color:rgb(0,0,221)">return</span> os <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,128,0)">"{ x="</span> <span style="color:rgb(0,0,128)"><<</span> v.<span>x</span> <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,128,0)">", y="</span> <span style="color:rgb(0,0,128)"><<</span> v.<span>y</span> <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,128,0)">", z="</span> <span style="color:rgb(0,0,128)"><<</span> v.<span>z</span> <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,128,0)">" }"</span><span style="color:rgb(0,128,128)">;</span>
    <span style="color:rgb(0,128,0)">}</span>
<span style="color:rgb(0,128,0)">}</span><span style="color:rgb(0,128,128)">;</span>
 
<span style="color:rgb(0,0,255)">int</span> main<span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span>
<span style="color:rgb(0,128,0)">{</span>
    <span style="color:rgb(144,144,144)">// Use the default constructor.</span>
    <a href="http://en.cppreference.com/w/cpp/memory/unique_ptr" style="text-decoration-line:none;color:rgb(0,48,128);background-image:none;background-position:initial initial;background-repeat:initial initial" target="_blank"><span>std::<span>unique_ptr</span></span></a><span style="color:rgb(0,0,128)"><</span>Vec3<span style="color:rgb(0,0,128)">></span> v1 <span style="color:rgb(0,0,128)">=</span> std<span style="color:rgb(0,128,128)">::</span><span>make_unique</span><span style="color:rgb(0,0,128)"><</span>Vec3<span style="color:rgb(0,0,128)">></span><span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
    <span style="color:rgb(144,144,144)">// Use the constructor that matches these arguments</span>
    <a href="http://en.cppreference.com/w/cpp/memory/unique_ptr" style="text-decoration-line:none;color:rgb(0,48,128);background-image:none;background-position:initial initial;background-repeat:initial initial" target="_blank"><span>std::<span>unique_ptr</span></span></a><span style="color:rgb(0,0,128)"><</span>Vec3<span style="color:rgb(0,0,128)">></span> v2 <span style="color:rgb(0,0,128)">=</span> std<span style="color:rgb(0,128,128)">::</span><span>make_unique</span><span style="color:rgb(0,0,128)"><</span>Vec3<span style="color:rgb(0,0,128)">></span><span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(0,0,128)">1</span>,<span style="color:rgb(0,0,128)">2</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
    <span style="color:rgb(144,144,144)">// Create a unique_ptr to an array of 5 elements</span>
    <a href="http://en.cppreference.com/w/cpp/memory/unique_ptr" style="text-decoration-line:none;color:rgb(0,48,128);background-image:none;background-position:initial initial;background-repeat:initial initial" target="_blank"><span>std::<span>unique_ptr</span></span></a><span style="color:rgb(0,0,128)"><</span>Vec3<span style="color:rgb(0,128,0)">[</span><span style="color:rgb(0,128,0)">]</span><span style="color:rgb(0,0,128)">></span> v3 <span style="color:rgb(0,0,128)">=</span> std<span style="color:rgb(0,128,128)">::</span><span>make_unique</span><span style="color:rgb(0,0,128)"><</span>Vec3<span style="color:rgb(0,128,0)">[</span><span style="color:rgb(0,128,0)">]</span><span style="color:rgb(0,0,128)">></span><span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,0,128)">5</span><span style="color:rgb(0,128,0)">)</span><span style="color:rgb(0,128,128)">;</span>
 
    <a href="http://en.cppreference.com/w/cpp/io/cout" style="text-decoration-line:none;color:rgb(0,48,128);background-image:none;background-position:initial initial;background-repeat:initial initial" target="_blank"><span>std::<span>cout</span></span></a> <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,128,0)">"make_unique<Vec3>():      "</span> <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,0,64)">*</span>v1 <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,128,0)">'<span style="font-weight:bold">\n</span>'</span>
              <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,128,0)">"make_unique<Vec3>(0,1,2): "</span> <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,0,64)">*</span>v2 <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,128,0)">'<span style="font-weight:bold">\n</span>'</span>
              <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,128,0)">"make_unique<Vec3[]>(5):   "</span><span style="color:rgb(0,128,128)">;</span>
    <span style="color:rgb(0,0,221)">for</span> <span style="color:rgb(0,128,0)">(</span><span style="color:rgb(0,0,255)">int</span> i <span style="color:rgb(0,0,128)">=</span> <span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,128,128)">;</span> i <span style="color:rgb(0,0,128)"><</span> <span style="color:rgb(0,0,128)">5</span><span style="color:rgb(0,128,128)">;</span> i<span style="color:rgb(0,0,64)">++</span><span style="color:rgb(0,128,0)">)</span> <span style="color:rgb(0,128,0)">{</span>
        <a href="http://en.cppreference.com/w/cpp/io/cout" style="text-decoration-line:none;color:rgb(0,48,128);background-image:none;background-position:initial initial;background-repeat:initial initial" target="_blank"><span>std::<span>cout</span></span></a> <span style="color:rgb(0,0,128)"><<</span> <a href="http://en.cppreference.com/w/cpp/io/manip/setw" style="text-decoration-line:none;color:rgb(0,48,128);background-image:none;background-position:initial initial;background-repeat:initial initial" target="_blank"><span>std::<span>setw</span></span></a><span style="color:rgb(0,128,0)">(</span>i <span style="color:rgb(0,128,128)">?</span> <span style="color:rgb(0,0,128)">30</span> <span style="color:rgb(0,128,128)">:</span> <span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,128,0)">)</span> <span style="color:rgb(0,0,128)"><<</span> v3<span style="color:rgb(0,128,0)">[</span>i<span style="color:rgb(0,128,0)">]</span> <span style="color:rgb(0,0,128)"><<</span> <span style="color:rgb(0,128,0)">'<span style="font-weight:bold">\n</span>'</span><span style="color:rgb(0,128,128)">;</span>
    <span style="color:rgb(0,128,0)">}</span>
<span style="color:rgb(0,128,0)">}</span></pre><div><span style="background-color:rgb(249,249,249);color:rgb(0,0,0);font-size:12.8px"></span><br></div><div>It failed with the following errors:</div><div>    Error: no member named 'make_unique' in namespace 'std'</div><div>       std::unique_ptr<Vec3> v1 = std::make_unique<Vec3>();</div><div>    ... ...</div><div><br></div><div>Any idea and suggestion about what is going on? or have I missed something? The command I used to compile the code above:</div><div>     $ clang++ a.cpp</div></div></blockquote><div><br></div><div>Maybe `clang++ -std=c++11 a.cpp` ?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>2.  Comparing this llvm with my current gcc/8.2.0 on a project (openmp code running 1 thread), it showed that llvm is almost twice as slow as gcc (both compile with -O3) on my IBM power8 machine. Is it suppose to be with such slower performance than gcc? </div></div></blockquote><div><br></div><div>It is very sensitive to how you built it, by default it'll be built in debug mode. For best performance you would ideally you enable Release mode, and bootstrap with LTO/PGO.</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Thank you very much for any advice!</div><div><br></div><div>Best Regards,</div><div>Shelton </div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><div><br></div><div><br></div><div><br></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>