<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 18, 2015 at 3:07 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: Fri Sep 18 17:07:10 2015<br>
New Revision: 248052<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248052&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248052&view=rev</a><br>
Log:<br>
COFF: Parallelize Writer::writeSections().<br>
<br>
Self-hosting took 801 ms on my machine. Of which this function took<br>
69 ms. Now it takes 37 ms. That is about 4% overall performance<br>
improvement.<br>
<br>
Modified:<br>
lld/trunk/COFF/Writer.cpp<br>
<br>
Modified: lld/trunk/COFF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=248052&r1=248051&r2=248052&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=248052&r1=248051&r2=248052&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/COFF/Writer.cpp (original)<br>
+++ lld/trunk/COFF/Writer.cpp Fri Sep 18 17:07:10 2015<br>
@@ -14,6 +14,7 @@<br>
#include "SymbolTable.h"<br>
#include "Symbols.h"<br>
#include "Writer.h"<br>
+#include "lld/Core/Parallel.h"<br>
#include "llvm/ADT/ArrayRef.h"<br>
#include "llvm/ADT/DenseMap.h"<br>
#include "llvm/ADT/STLExtras.h"<br>
@@ -708,8 +709,8 @@ void Writer::writeSections() {<br>
// ADD instructions).<br>
if (Sec->getPermissions() & IMAGE_SCN_CNT_CODE)<br>
memset(SecBuf, 0xCC, Sec->getRawSize());<br>
- for (Chunk *C : Sec->getChunks())<br>
- C->writeTo(SecBuf);<br>
+ parallel_for_each(Sec->getChunks().begin(), Sec->getChunks().end(),<br>
+ [&](Chunk *C) { C->writeTo(SecBuf); });<br></blockquote><div><br></div><div>I gather this is safely parallelizable as each Chunk will write to distinct regions of SecBuf, without ever overlapping/racing?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
}<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">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></div>