Mesa (master): nir/validate: Size the set of blocks to avoid rehashing.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Nov 10 22:40:06 UTC 2020
Module: Mesa
Branch: master
Commit: eba97645c9f22c890d7b413dbe81b532c04d99fe
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eba97645c9f22c890d7b413dbe81b532c04d99fe
Author: Eric Anholt <eric at anholt.net>
Date: Tue Oct 20 14:32:28 2020 -0700
nir/validate: Size the set of blocks to avoid rehashing.
We can use num_blocks (if it's been initialized by some pass indexing
blocks) to pre-size our table, which helps on validating shaders with many
blocks which would otherwise reallocate the set several times.
No statistically significant performance difference on softpipe
KHR-GL33.texture_swizzle.functional runtime (n=15). A previous, similar
variant of this patch cut .3% of instructions in softpipe shader-db ./run
shaders/closed/steam/borderlands-2/35* (an arbitrary set of shaders that
completed in reasonable amount of time) according to callgrind.
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7244>
---
src/compiler/nir/nir.c | 1 +
src/compiler/nir/nir_validate.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index acedb0536ab..693d119671b 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -371,6 +371,7 @@ nir_function_impl_create_bare(nir_shader *shader)
exec_list_make_empty(&impl->locals);
impl->reg_alloc = 0;
impl->ssa_alloc = 0;
+ impl->num_blocks = 0;
impl->valid_metadata = nir_metadata_none;
impl->structured = true;
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index b974bc9f46d..fe50e291c70 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -1517,6 +1517,7 @@ validate_function_impl(nir_function_impl *impl, validate_state *state)
sizeof(BITSET_WORD));
_mesa_set_clear(state->blocks, NULL);
+ _mesa_set_resize(state->blocks, impl->num_blocks);
collect_blocks(&impl->body, state);
_mesa_set_add(state->blocks, impl->end_block);
validate_assert(state, !exec_list_is_empty(&impl->body));
More information about the mesa-commit
mailing list