<div dir="ltr">Hi Denis,<div><br></div><div>Looking forward to your talk at LLVM-CGO!<br><br>Here are some directions that I have seen lately:<br><br>1) "Unconstrained" Optimization<br><br>Currently, optimization passes use a pre-determined series of steps. So, optimizations are inherently constrained in how big leaps<br>the transformations can make. On the other hand, research such as STOKE [1] has showed that a "more dumb" but unconstrained<br>optimizer can change radically even the very algorithm used. To explain the "more dumb" but unconstrained part, the algorithm used to optimize<div>the program is literally:</div><div><br>- Start with a program (or no program, in which case the program is synthesized)<br><br>- Do a random change to the program<br>  - Compute a cost (whose specifics deserve a big discussion but it's not the central point here; the first pointer at the end is related though)<br>  - If the cost is better, keep the change<br>  - Otherwise, based on some probability, keep the change<br>  - Repeat<br><br>This resulted in great improvements to the program, in a not horrible compilation time.<br><br>2) Automatic Parallelization Revival<br><br>Automatic Parallelization is thought to have died, but in the last couple of years a group in Princeton has shown some<br>promising improvements, specifically with Perspective [2]. I think this a great step forward as it obtained a _23.0x_ for<br>12 general-purpose C/C++ programs (SPEC IIRC) running on a 28-core shared-memory commodity machine.<br>I would urge you to take a closer look to that since the infrastructure is built on top of LLVM.<br><br>Here's some related work [3] trying to revive automatic parallelization from a different perspective (pun not intended).<br><br>3) Decoupling Transformations and Cost-Modeling<br><br>An important problem I think in today's compilers is that cost is baked into the transformations (and it's<br>not even clear how it is computed).<br><br>The result of this is that even if you had a perfect oracle, which always knew the perfect transformations to be done,<br>there is simply no way to instruct the compiler to perform the sequence. So, my personal opinion is that in<br>the years to come, there will be an effort to separate transformations into their own, dedicated and fine-grained<br>modules (as opposed to the monolithic entities which now are, i.e. passes). This in turn can enable machine-learning<br>models (which will decide _what_ has to happen and then they'll use the fine-grained APIs of transformations to make it happen).</div><div><br></div><div>(I think this is closely related to what Mircea said above)<br><br>--- Random pointers ---<br><br>* The DeepCompiler [4] project at MIT has done significant improvements in predicting the performance of X86 code: <br>* Alex Aiken's opinion on the future of compilers [5]<br><br>Disclaimer: This is definitely not an exhaustive list!<br><br>[1] <a href="https://github.com/StanfordPL/stoke">https://github.com/StanfordPL/stoke</a><br>[2] <a href="https://liberty.princeton.edu/Projects/AutoPar/Perspective/">https://liberty.princeton.edu/Projects/AutoPar/Perspective/</a><br>[3] <a href="https://www.youtube.com/watch?v=8B25HQeJ0Ms">https://www.youtube.com/watch?v=8B25HQeJ0Ms</a>

<br>[4] <a href="https://www.deep-compiler.org/">https://www.deep-compiler.org/</a>

<br>[5] <a href="https://youtu.be/ob0nfNr2FLc?t=156">https://youtu.be/ob0nfNr2FLc?t=156</a>

</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Στις Τρί, 23 Φεβ 2021 στις 2:57 π.μ., ο/η Mircea Trofin via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> έγραψε:<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 dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 22, 2021 at 4:50 PM Denis Bakhvalov 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:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello,<br><br>I'll be giving a short presentation on the LLVM performance workshop soon and I want to touch on the topic of future performance improvements. I decided to ask the community about what can drive performance improvements in a classic C++ LLVM compiler CPU backend in the future? If I summarize all the thoughts and opinions, I think it would be an interesting discussion.<br><br>There is already a body of research on the topic, including [1] which talks about superoptimizers, but maybe anybody has some interesting new ideas.<br>In particular, I'm interested to hear thoughts on the following things:<br>1. How big is the performance headroom in existing LLVM optimization passes?<br>2. I think PGO can play a bigger role in the future. I see the benefits of more optimizations being guided by profiling data. For example, there is potential for intelligent injection of memory prefetching hints based on HW telemetry data on modern Intel CPUs. This HW telemetry data allows finding memory accesses that miss in caches and estimate the prefetch window (in cycles). Using this data compiler can determine the place for a prefetch hint. Obviously, there are lots of limitations, but it's just a thought. BTW, the same can be done for PGO-driven branch-to-cmov conversion (fighting branch mispredictions).<br>3. ML opportunities in compiler tooling. For example, code similarity analysis [2][3] opens a wide range of opportunities, e.g. build a recommendation system that will suggest a better performing code sequence.<br></div></div></div></blockquote><div>on this, also: replacing hand-crafted heuristics with machine learned policies, for those passes that are heuristics driven - like inlining, regalloc, instruction selection, etc. Same for cost models.</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 dir="ltr"><div dir="ltr"><br>Please also share any thoughts you have that are not on this list.<br><br>If that topic was discussed in the past, sorry, and please send links to those discussions.<br><br>-Denis<br><a href="https://easyperf.net" target="_blank">https://easyperf.net</a><br><br>[1]: <a href="https://arxiv.org/abs/1809.02161" target="_blank">https://arxiv.org/abs/1809.02161</a><br>[2]: <a href="https://doi.org/10.1145/3360578" target="_blank">https://doi.org/10.1145/3360578</a><br>[3]: <a href="https://arxiv.org/abs/2006.05265" target="_blank">https://arxiv.org/abs/2006.05265</a><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><br><br><br><br></div></div></div></div></div></div></div></div></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>
_______________________________________________<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>