On Wed, 2015-07-15 at 16:42 +1000, Timothy Arceri wrote: > Hi guys, > > As I've mentioned a couple of times in previous patches some of the cts AoA > tests are taking very long time to compile. This is due to excessive > optimisation passes mainly in the glsl optimisations (there are some > slowdowns > in the intel backend too but these seemed to go away when I tried the new > nir > vec4 backend). > > I fixed part of the problem with this patch to do the dead code elimination > in > a single pass [1]. > These excessive passes exist in normal shaders but its generally not an > issue > as the number of passes is generally quite low, and inexpensive. However > when > you have an 8 dimensional array constantly walking this becomes quite > expensive. > > The remaining issue I'm seeking some advice for is with constant > propagation/folding. > > It seems for interators used in loops you can get into a situation where an > optimisation pass is needed for each loop iteration in order to make all > values of the iterator constant. > > I didn't have look too find some real world examples of this in the public > shader-db. For example here is it happening for a Unity shader: > > ---------------------- Linker Pass 1 ---------------------- > opt_function_inlining progress > opt_dead_functions progress > opt_copy_propagation_elements progress > opt_tree_grafting progress > opt_constant_folding progress > opt_algebraic progress > ---------------------- Linker Pass 1 ---------------------- > constant prop : l_3, Value : 0 > constant prop : l_3, Value : 0 > constant prop : l_3, Value : 0 > constant prop : l_3, Value : 0 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 2 ---------------------- > constant prop : l_3, Value : 1 > constant prop : l_3, Value : 1 > constant prop : l_3, Value : 1 > constant prop : l_3, Value : 1 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 3 ---------------------- > constant prop : l_3, Value : 2 > constant prop : l_3, Value : 2 > constant prop : l_3, Value : 2 > constant prop : l_3, Value : 2 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 4 ---------------------- > constant prop : l_3, Value : 3 > constant prop : l_3, Value : 3 > constant prop : l_3, Value : 3 > constant prop : l_3, Value : 3 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 5 ---------------------- > constant prop : l_3, Value : 4 > constant prop : l_3, Value : 4 > constant prop : l_3, Value : 4 > constant prop : l_3, Value : 4 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 6 ---------------------- > constant prop : l_3, Value : 5 > constant prop : l_3, Value : 5 > constant prop : l_3, Value : 5 > constant prop : l_3, Value : 5 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 7 ---------------------- > constant prop : l_3, Value : 6 > constant prop : l_3, Value : 6 > constant prop : l_3, Value : 6 > constant prop : l_3, Value : 6 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 8 ---------------------- > constant prop : l_3, Value : 7 > constant prop : l_3, Value : 7 > constant prop : l_3, Value : 7 > constant prop : l_3, Value : 7 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 9 ---------------------- > constant prop : l_3, Value : 8 > constant prop : l_3, Value : 8 > constant prop : l_3, Value : 8 > constant prop : l_3, Value : 8 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 10 ---------------------- > constant prop : l_3, Value : 9 > constant prop : l_3, Value : 9 > constant prop : l_3, Value : 9 > constant prop : l_3, Value : 9 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 11 ---------------------- > constant prop : l_3, Value : 10 > constant prop : l_3, Value : 10 > constant prop : l_3, Value : 10 > constant prop : l_3, Value : 10 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 12 ---------------------- > constant prop : l_3, Value : 11 > constant prop : l_3, Value : 11 > constant prop : l_3, Value : 11 > constant prop : l_3, Value : 11 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 13 ---------------------- > constant prop : l_3, Value : 12 > constant prop : l_3, Value : 12 > constant prop : l_3, Value : 12 > constant prop : l_3, Value : 12 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 14 ---------------------- > constant prop : l_3, Value : 13 > constant prop : l_3, Value : 13 > constant prop : l_3, Value : 13 > constant prop : l_3, Value : 13 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 15 ---------------------- > constant prop : l_3, Value : 14 > constant prop : l_3, Value : 14 > constant prop : l_3, Value : 14 > constant prop : l_3, Value : 14 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 16 ---------------------- > constant prop : l_3, Value : 15 > constant prop : l_3, Value : 15 > constant prop : l_3, Value : 15 > constant prop : l_3, Value : 15 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 17 ---------------------- > constant prop : l_3, Value : 16 > constant prop : l_3, Value : 16 > constant prop : l_3, Value : 16 > constant prop : l_3, Value : 16 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 18 ---------------------- > constant prop : l_3, Value : 17 > constant prop : l_3, Value : 17 > constant prop : l_3, Value : 17 > constant prop : l_3, Value : 17 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 19 ---------------------- > constant prop : l_3, Value : 18 > constant prop : l_3, Value : 18 > constant prop : l_3, Value : 18 > constant prop : l_3, Value : 18 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 20 ---------------------- > constant prop : l_3, Value : 19 > constant prop : l_3, Value : 19 > constant prop : l_3, Value : 19 > constant prop : l_3, Value : 19 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 21 ---------------------- > constant prop : l_3, Value : 20 > constant prop : l_3, Value : 20 > constant prop : l_3, Value : 20 > constant prop : l_3, Value : 20 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 22 ---------------------- > constant prop : l_3, Value : 21 > constant prop : l_3, Value : 21 > constant prop : l_3, Value : 21 > constant prop : l_3, Value : 21 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 23 ---------------------- > constant prop : l_3, Value : 22 > constant prop : l_3, Value : 22 > constant prop : l_3, Value : 22 > constant prop : l_3, Value : 22 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 24 ---------------------- > constant prop : l_3, Value : 23 > constant prop : l_3, Value : 23 > constant prop : l_3, Value : 23 > constant prop : l_3, Value : 23 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 25 ---------------------- > constant prop : l_3, Value : 24 > constant prop : l_3, Value : 24 > constant prop : l_3, Value : 24 > constant prop : l_3, Value : 24 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 26 ---------------------- > constant prop : l_3, Value : 25 > constant prop : l_3, Value : 25 > constant prop : l_3, Value : 25 > constant prop : l_3, Value : 25 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 27 ---------------------- > constant prop : l_3, Value : 26 > constant prop : l_3, Value : 26 > constant prop : l_3, Value : 26 > constant prop : l_3, Value : 26 > opt_constant_propagation progress > opt_constant_folding progress > ---------------------- Linker Pass 28 ---------------------- > constant prop : l_3, Value : 27 > constant prop : l_3, Value : 27 > constant prop : l_3, Value : 27 > constant prop : l_3, Value : 27 > opt_constant_propagation progress > opt_constant_folding progress > > > <snip> > > shaders/unity/68.shader_test - FS SIMD8 shader: 1058 inst, 0 loops, 0:0 > spills:fills, Promoted 144 constants, compacted 16928 to 13008 bytes. > shaders/unity/68.shader_test - FS SIMD16 shader: 1338 inst, 0 loops, 0:0 > spills:fills, Promoted 144 constants, compacted 21408 to 17488 bytes. > shaders/unity/68.shader_test - VS vec4 shader: 10 inst, 0 loops, compacted > 160 > to 144 bytes. > > > The problem I'm having is that its expensive to walk over these large arrays > and in the tests I'm working with the interator goes through 256 > optimisation > passes (and then is later dead code eliminated anyway). > > So question for those who have more knowledge about these optimisations then > me is what would you recommend I do as a next step? Does it make sense to > try > to do more of this work in a single pass or should I just try to avoid > constantly walking the arrays somehow. > > Thanks for your time, > Tim > > [1] http://lists.freedesktop.org/archives/mesa-dev/2015-July/088651.html
I used the word iterator throught this email as that was the variable name in the shader, to be clear I really just meant the loop index/counter. _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev