<div dir="ltr">Just wow! It would be crime not to merge this branch, with the sole reason "LLVM is the future".<div>Fantastic work Vadim.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 15, 2013 at 1:00 PM, Vadim Girlin <span dir="ltr"><<a href="mailto:vadimgirlin@gmail.com" target="_blank">vadimgirlin@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 02/14/2013 02:42 PM, Christian König wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Vadim,<br>
<br>
nice work, I think you've made quite a progress here, but on the other<br>
hand it should be clear that the LLVM backend is the future and we<br>
should concentrate on that.<br>
</blockquote>
<br></div>
"LLVM backend is the future" is a pretty abstract argument. I prefer to operate with real facts. After a year of LLVM backend development what are the real benefits for the users? What are the real use cases where the users might prefer LLVM backend? To me this situation looks like the use of LLVM requires a lot more time and development efforts than the custom solution, despite the initial expectations. Maybe you are right and the LLVM backend will become the best alternative for users sometime in the future, but I only have some today's results:<br>


<br>
Heaven 3.0, all settings high/enabled, 1280x720, HD5750:<br>
  default backend : 20.0 fps<br>
  llvm backend    : 18.8 fps<br>
  r600-sb         : 38.0 fps<br>
<br>
When I'm looking at these results, the benefits of LLVM-based solution are not very clear to me.<br>
<br>
I'm not trying to persuade anyone, just wanted to explain why I decided to switch back to work on the non-LLVM solution.<br>
<br>
Anyway, it's absolutely not a problem for me if this branch will never make it to mesa, I was ready to this before I started. One of the goals of this branch was just to show that the use of LLVM is possibly not the the best way of the GL shaders compilation for r600g. And another goal, of course, is to get better performance with r600g *today*, not in the future.<br>


<br>
Vadim<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
To sum it up I'm not sure what we should do with this branch :)<br>
<br>
As Dragomir already wrote even if the code won't be used much the<br>
know-how you gained while coding it will stay, believe me that this is<br>
or far more value than the code itself.<br>
<br>
Christian.<br>
<br>
Am 14.02.2013 11:10, schrieb Dragomir Ivanov:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Greetings,<br>
I hope that, even if you work will be short-lived, e.g. until LLVM<br>
bytecode compiler takes off, the know-how is still very useful.<br>
<br>
<br>
On Thu, Feb 14, 2013 at 4:04 AM, Vadim Girlin <<a href="mailto:vadimgirlin@gmail.com" target="_blank">vadimgirlin@gmail.com</a><br></div><div><div class="h5">
<mailto:<a href="mailto:vadimgirlin@gmail.com" target="_blank">vadimgirlin@gmail.com</a>><u></u>> wrote:<br>
<br>
    Hi,<br>
<br>
    Last month I finally found the time to work on the rewrite of my<br>
    previous shader optimization branch, now it's mostly done in terms<br>
    of the correctness of produced code and feature support (at least<br>
    on evergreen), though it's still a work in progress in terms of<br>
    the efficiency of generated shader code and the efficiency of the<br>
    backend itself.<br>
<br>
    I spent some time last year studying the LLVM infrastructure and<br>
    R600 LLVM backend and trying to improve it, but after all I came<br>
    to the conclusion that for me it might be easier to implement all<br>
    that I wanted in the custom backend. This allows for more simple<br>
    and efficient implementation - e.g. I don't have to deal with CFGs<br>
    because in fact we have structured code, so it's possible to use<br>
    more simple and efficient algorithms.<br>
<br>
    Currently the branch has no regressions with piglit's<br>
    quick-driver.tests on evergreen (it doesn't rely on the fallback<br>
    to unoptimized code for the shaders with relative addressing and<br>
    other cases unlike the previous branch), and so far I don't see<br>
    any rendering issues with the apps that I used for testing -<br>
     Lightsmark 2008, Unigine Heaven 3.0 and some others.. There are<br>
    also some performance improvements with the gpu-bound apps.<br>
<br>
    I tried to keep in mind the differences between chip classes, so I<br>
    hope it should only require minor fixes to make it work on<br>
    non-evergreen chips, but I doubt that it will work out of the box<br>
    - support for some non-evergreen hw-specific features is still<br>
    missing, e.g. I'm sure that indirect addressing currently won't<br>
    work on R6xx, though basic tests might work in theory. Fixing this<br>
    shouldn't require a lot of work though.<br>
<br>
    The branch can be found in my freedesktop repo:<br>
<br>
    <a href="http://cgit.freedesktop.org/~vadimg/mesa/log/?h=r600-sb" target="_blank">http://cgit.freedesktop.org/~<u></u>vadimg/mesa/log/?h=r600-sb</a><br></div></div>
    <<a href="http://cgit.freedesktop.org/%7Evadimg/mesa/log/?h=r600-sb" target="_blank">http://cgit.freedesktop.org/%<u></u>7Evadimg/mesa/log/?h=r600-sb</a>><div><div class="h5"><br>
<br>
    Regarding the differences from the previous branch - there are<br>
    some additional optimizations, e.g. global value numbering with<br>
    some basic support for constant folding (not all instructions are<br>
    currently handled, but it's easy to extend), global code motion<br>
    that can hoist invariant code out of the loops etc. Some<br>
    optimizations that were implemented in the previous branch are not<br>
    implemented in the new branch (yet), e.g. propagation of modifiers<br>
    (I'm not even sure if it has any noticeable effect on performance).<br>
<br>
    Unlike the previous branch, there is support for indirect<br>
    addressing on registers -  currently it uses my previously posted<br>
    patch (that was not very welcome) for obtaining the  information<br>
    about addressable register ranges, but it's not required and can<br>
    be dropped, I just used that patch for testing. Without that<br>
    information opportunities for optimization are limited though, and<br>
    perhaps it makes sense to not try to optimize the shaders with<br>
    indirect gpr addressing at all and rely on the old backend until<br>
    we'll have the proper solution to pass that information to the<br>
    drivers.<br>
<br>
    There is also initial support for ALU predication, but it's not<br>
    complete and currently unused, I'm not sure if predication support<br>
    will have significant effect on performance that will justify more<br>
    complex and expensive algorithms for register allocator and<br>
    scheduler, probably I'll look into it later, I consider this as a<br>
    low priority. In the case of predicated source code (from LLVM<br>
    backend) the predication is eliminated using speculative execution<br>
    and conditional moves, same as with the simple if-conversion pass<br>
    that is also implemented.<br>
<br>
    The branch currently uses as source the bytecode built by the old<br>
    backend (that may also come from LLVM backend) and some additional<br>
    information (about inputs etc), final bytecode is built by the new<br>
    builder in the branch. Building two versions of the bytecode<br>
    doesn't look very efficient, but currently it simplifies<br>
    debugging. I'm planning to implement translation from TGSI<br>
    directly to my representation, it should simplify the translator<br>
    and allow to get rid of unnecessary intermediate passes.<br>
<br>
    Some old and new environment variables can be used to control the<br>
    behavior of this backend:<br>
<br>
    R600_SB - 0 - disable new backend completely, 1 - enable (default)<br>
    R600_SB_USE_NEW_BYTECODE - 0 - disable use of the produced<br>
    bytecode (useful if you only want to look at the dump of the<br>
    optimized shader without passing it to hw), 1 - enable (default)<br>
    R600_DUMP_SHADERS - will also dump the dissasemble of the<br>
    optimized shader after original bytecode (if backend is not<br>
    disabled with R600_SB=0).<br>
<br>
    Produced shader code is not ideal - e.g. you may notice not very<br>
    necessary MOVs inserted before DOT4 instructions, it's a known<br>
    issue and I'm going to look into it - this may require rework of<br>
    the regalloc/scheduler. I had to sacrifice some features to make<br>
    it work correctly with Heaven first, so that now I can try to<br>
    improve it while being able to test for regressions.<br>
<br>
    Also probably there are some issues with the cleanness of the code<br>
    - I had to rework some parts a few times while fixing all<br>
    problems, so there is possibly unused code and other remnants of<br>
    the previous versions. Anyway, I still consider it as a work in<br>
    progress and some things are going to be reworked.<br>
<br>
    I'm not sure what will be the destiny of this branch, taking into<br>
    account that we also have actively developed LLVM backend that is<br>
    required for OpenCL anyway. Your opinions are welcome.<br>
<br>
    Vadim<br>
    ______________________________<u></u>_________________<br>
    mesa-dev mailing list<br>
    <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br></div></div>
<mailto:<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.<u></u>freedesktop.org</a>><div class="im"><br>
    <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/mesa-dev</a><br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/mesa-dev</a><br>
</div></blockquote>
<br>
<br>
</blockquote>
<br>
<br>
<br>
<br>
</blockquote></div><br></div>