<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Sep 20, 2015 at 6:42 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">We can, but I think we don't have to, because I didn't see any measurable difference between this code and the old racy one.</p></blockquote><div>... in terms of speed.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote">2015/09/20 18:32 "Sean Silva" <<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>>:<div><div class="h5"><br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It seems unfortunate for us to need any synchronization at all just to generate a unique ID. Can we just have a bunch of counters, one per thread, then initialize them to `ThreadIndex << 50` or something? (make sure they are each on their own cache line)<div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 19, 2015 at 6:44 PM, Rui Ueyama via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Sat Sep 19 20:44:44 2015<br>
New Revision: 248106<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248106&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248106&view=rev</a><br>
Log:<br>
COFF: Fix race condition.<br>
<br>
NextID is updated inside parallel_for_each, so it needs mutual exclusion.<br>
<br>
Modified:<br>
lld/trunk/COFF/ICF.cpp<br>
<br>
Modified: lld/trunk/COFF/ICF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ICF.cpp?rev=248106&r1=248105&r2=248106&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ICF.cpp?rev=248106&r1=248105&r2=248106&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/COFF/ICF.cpp (original)<br>
+++ lld/trunk/COFF/ICF.cpp Sat Sep 19 20:44:44 2015<br>
@@ -73,7 +73,7 @@ private:<br>
bool forEachGroup(std::vector<SectionChunk *> &Chunks, Comparator Eq);<br>
bool partition(ChunkIterator Begin, ChunkIterator End, Comparator Eq);<br>
<br>
- uint64_t NextID = 1;<br>
+ std::atomic<uint64_t> NextID = { 1 };<br>
};<br>
<br>
// Entry point to ICF.<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</blockquote></div></div></div>
</blockquote></div><br></div></div>