Commit Graph

10 Commits

Author SHA1 Message Date
Timothy Arceri 410609c968 glsl: remove dead code in a single pass
Currently only one ir assignment is removed for each var in a single
dead code optimisation pass. This means if a var has more than one
assignment, then it requires all the glsl optimisations to be run again
for each additional assignment to be removed.
Another pass is also required to remove the variable itself.

With this change all assignments and the variable are removed in a single
pass.

Some of the arrays of arrays conformance tests that were looping
through 8 dimensions ended up with a var with hundreds of assignments.

This change helps ES31-CTS.arrays_of_arrays.InteractionFunctionCalls1
go from around 3 min 20 sec -> 2 min

ES31-CTS.arrays_of_arrays.InteractionFunctionCalls2 went from
around 9 min 20 sec to 7 min 30 sec

I had difficulty getting the public shader-db to give a consistent result
with or without this change but the results seemed unchanged at between
15-20 seconds.

Thomas Helland measured change with shader-db on his machine from
approx 117 secs to 112 secs.

V3: Simplify freeing of list as suggested by Ian, and spelling fixes.

V2: Add assert to be sure references are counted before assignments.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-By: Thomas Helland <thomashelland90@gmail.com>
Tested-by: Ian Romanick <ian.d.romanick@intel.com>
2015-10-15 20:36:14 +11:00
Jason Ekstrand 94303a0750 util/hash_table: Rework the API to know about hashing
Previously, the hash_table API required the user to do all of the hashing
of keys as it passed them in.  Since the hashing function is intrinsically
tied to the comparison function, it makes sense for the hash table to know
about it.  Also, it makes for a somewhat clumsy API as the user is
constantly calling hashing functions many of which have long names.  This
is especially bad when the standard call looks something like

_mesa_hash_table_insert(ht, _mesa_pointer_hash(key), key, data);

In the above case, there is no reason why the hash table shouldn't do the
hashing for you.  We leave the option for you to do your own hashing if
it's more efficient, but it's no longer needed.  Also, if you do do your
own hashing, the hash table will assert that your hash matches what it
expects out of the hashing function.  This should make it harder to mess up
your hashing.

v2: change to call the old entrypoint "pre_hashed" rather than
    "with_hash", like cworth's equivalent change upstream (change by
    anholt, acked-in-general by Jason).

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-12-14 19:32:53 -08:00
Kenneth Graunke 72e55bb688 util: Move the open-addressing linear-probing hash_table to src/util.
This hash table is used in core Mesa, the GLSL compiler, and the i965
driver, which makes it a good candidate for the new src/util module.

It's much faster than program/hash_table.[ch] (see commit 6991c2922f
for data), and José's u_hash_table.c has a comment saying Gallium should
probably consider switching to a linear probing hash table at some point.
So this seems like the best candidate for a shared data structure.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>

v2 (Jason Ekstrand): Pick up another hash_table use and patch up scons

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2014-08-04 11:07:05 -07:00
Paul Berry e00b93a1f7 glsl/loops: replace loop controls with a normative bound.
This patch replaces the ir_loop fields "from", "to", "increment",
"counter", and "cmp" with a single integer ("normative_bound") that
serves the same purpose.

I've used the name "normative_bound" to emphasize the fact that the
back-end is required to emit code to prevent the loop from running
more than normative_bound times.  (By contrast, an "informative" bound
would be a bound that is informational only).

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-12-09 10:54:33 -08:00
Paul Berry 9d2951ea0a glsl: Teach ir_variable_refcount about ir_loop::counter variables.
If an ir_loop has a non-null "counter" field, the variable referred to
by this field is implicitly read and written by the loop.  We need to
account for this in ir_variable_refcount, otherwise there is a danger
we will try to dead-code-eliminate the loop counter variable.

Note: at the moment the dead code elimination bug doesn't occur due to
a bug in ir_hierarchical_visitor: it doesn't visit the "counter"
field, so dead code elimination doesn't treat it as a candidate for
elimination.  But the patch to follow will fix that bug, so we need to
fix ir_variable_refcount first in order to avoid breaking dead code
elimination.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-11-29 21:46:13 -08:00
Eric Anholt 1ddc021b2a mesa: Use the new hash table for the variable refcount visitor.
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
[jordan.l.justen@intel.com: open_hash_table => hash_table]
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-12-07 14:46:18 -08:00
Kenneth Graunke e3b5200496 glsl: Rename class variable_entry to ir_variable_refcount_entry.
Exporting a publicly visible class with a generic name like
"variable_entry" via ir_variable_refcount.h is kind of mean.

Many IR transformers would like to define their own "variable_entry"
class.  If they accidentally include this header, the compiler/linker
may get confused and try to instantiate the wrong variable_entry class,
leading to bizarre runtime crashes.

The hope is that renaming this one will allow .cpp files to safely
declare and use their own file-scope "variable_entry" classes.

This avoids crashes caused by converting src/glsl to automake.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-and-tested-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2012-01-30 17:44:52 -08:00
Brian Paul 2eb8b2d3bb glsl2: move constructor into .cpp file to work around compiler bug
Fixes fd.o bug 29770

The refcount==0 assertion only failed on some systems.  One example
being 32-bit Linux with gcc 4.4.4.
2010-08-24 10:01:44 -06:00
Vinson Lee c8b26c63fd glsl: Add assert to check variable_entry referenced_count after construction.
A variable_entry after construction should have its referenced_count
member set to 0. However, occassionally this isn't the case and
entry->referenced_count has been observed to be a garbage value. This
leads to crashes of several tests in the Piglit test suite.

This patch adds an assert to check that a variable_entry instance has
its referenced_count member initialized to 0 after construction.
2010-08-24 01:16:46 -07:00
Eric Anholt d72edc4ddd glsl2: Factor out the variable refcounting part of ir_dead_code.cpp. 2010-07-31 15:52:21 -07:00