<div dir="auto"><div>Oh, and an important disclaimer.</div><div dir="auto">I have not ran this through picking, nor have I done a complete </div><div dir="auto">run of shader-db for performance comparisons on more realistic workloads.</div><div dir="auto">I'll see what time I can find this evening, or some time tomorrow.<br><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">On Jan 1, 2017 19:38, "Thomas Helland" <<a href="mailto:thomashelland90@gmail.com">thomashelland90@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all.<br>
<br>
This is a series I've put together to lower the overhead of<br>
the copy propagation pass in glsl. The series is not refined,<br>
so please treat it as a proof of concept / RFC.<br>
<br>
The first five patches might be merge-ready, but their benefit is<br>
quite low compared to the actual major change here.<br>
<br>
The series goes on to copy our existing hash table implementation,<br>
and modify it in steps to allow insertion of multiple data entries<br>
with the same key. I've kept the series in steps corresponding to<br>
the way I worked when modifying it, as I found it nice for clarity.<br>
There is some obvious cleanups and squashing that will need to happen<br>
before this can be considered for merging.<br>
<br>
The major change is the last patch. This uses the new hash table in<br>
our copy propagation pass. This effectively makes the algorithm<br>
O(2n) instead of O(n^2), which is a big win. I tested with the<br>
shader mentioned in [1] but took the shaders and made a shader_test<br>
that I used in conjunction with shader-db to do testing.<br>
I cut down on the ridiculous amount of expression some, to make it<br>
even compile in a reasonable time on my poor laptop.<br>
<br>
So, on to the results. Compilation of the aforementioned shader<br>
went from 98 to 75 seconds. Perf shows that previously we spent<br>
19% of the time walking the acp-table with _mesa_hash_table_next_entry.<br>
After this series, the hash table is practically gone from the profile.<br>
This is a major win, and I'm guite happy with the results.<br>
There is obviously a lot more work to be done though.<br>
<br>
Please leave critical feedback and ideas. This was merely a test<br>
from my part, but it seems there is some opportunities here.<br>
<br>
<a href="https://bugs.freedesktop.org/show_bug.cgi?id=94477" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=94477</a><br>
<br>
Thomas Helland (14):<br>
  glsl: Don't rehash the values when copying to new table<br>
  glsl: Don't compute the hash when we already have it available<br>
  nir: Remove unused include of nir_array<br>
  nir: Move nir_array to util, and rename to dyn_array<br>
  glsl: Use dyn_array instead of the exec_list<br>
  util: Make a copy of the existing hash table implementation<br>
  util: Add field for pointing to next data<br>
  util: Implement the insertion functionality<br>
  util: Implement deletion of entries<br>
  util: Add a comment about ordering of entries with matching keys<br>
  util: Implement returning the last added entry on search<br>
  util: Rename functions and structs<br>
  util: Use hashing functions from hash_table.h<br>
  glsl: Restructure copy propagation to use the non replacing hash table<br>
<br>
 src/compiler/Makefile.sources                      |   1 -<br>
 src/compiler/glsl/opt_copy_<wbr>propagation.cpp         | 112 +++--<br>
 .../glsl/opt_copy_propagation_<wbr>elements.cpp         |   6 +-<br>
 src/compiler/nir/nir_lower_<wbr>locals_to_regs.c        |   1 -<br>
 src/compiler/spirv/vtn_cfg.c                       |   6 +-<br>
 src/compiler/spirv/vtn_<wbr>private.h                   |   4 +-<br>
 src/util/Makefile.sources                          |   3 +<br>
 src/{compiler/nir/nir_array.h => util/dyn_array.h} |  18 +-<br>
 src/util/non_replacing_hash_<wbr>table.c                | 513 +++++++++++++++++++++<br>
 src/util/non_replacing_hash_<wbr>table.h                | 135 ++++++<br>
 10 files changed, 743 insertions(+), 56 deletions(-)<br>
 rename src/{compiler/nir/nir_array.h => util/dyn_array.h} (86%)<br>
 create mode 100644 src/util/non_replacing_hash_<wbr>table.c<br>
 create mode 100644 src/util/non_replacing_hash_<wbr>table.h<br>
<font color="#888888"><br>
--<br>
2.11.0<br>
<br>
</font></blockquote></div><br></div></div></div>