util: Move the open-addressing linear-probing hash_table to src/util.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 25 Feb 2014 09:08:45 +0000 (01:08 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 4 Aug 2014 18:07:05 +0000 (11:07 -0700)
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 6991c2922f5
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>
35 files changed:
configure.ac
src/glsl/Makefile.am
src/glsl/SConscript
src/glsl/ir_variable_refcount.cpp
src/glsl/link_uniform_block_active_visitor.h
src/glsl/link_uniform_blocks.cpp
src/glsl/opt_dead_code.cpp
src/mesa/Makefile.sources
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/intel_fbo.c
src/mesa/main/errors.c
src/mesa/main/hash.c
src/mesa/main/shaderapi.c
src/mesa/main/shared.c
src/mesa/main/syncobj.c
src/mesa/main/tests/Makefile.am
src/mesa/main/vdpau.c
src/util/Makefile.am
src/util/Makefile.sources
src/util/SConscript
src/util/hash_table.c [moved from src/mesa/main/hash_table.c with 99% similarity]
src/util/hash_table.h [moved from src/mesa/main/hash_table.h with 99% similarity]
src/util/tests/Makefile.am
src/util/tests/hash_table/.gitignore [moved from src/mesa/main/tests/hash_table/.gitignore with 100% similarity]
src/util/tests/hash_table/Makefile.am [moved from src/mesa/main/tests/hash_table/Makefile.am with 96% similarity]
src/util/tests/hash_table/collision.c [moved from src/mesa/main/tests/hash_table/collision.c with 100% similarity]
src/util/tests/hash_table/delete_and_lookup.c [moved from src/mesa/main/tests/hash_table/delete_and_lookup.c with 100% similarity]
src/util/tests/hash_table/delete_management.c [moved from src/mesa/main/tests/hash_table/delete_management.c with 100% similarity]
src/util/tests/hash_table/destroy_callback.c [moved from src/mesa/main/tests/hash_table/destroy_callback.c with 100% similarity]
src/util/tests/hash_table/insert_and_lookup.c [moved from src/mesa/main/tests/hash_table/insert_and_lookup.c with 100% similarity]
src/util/tests/hash_table/insert_many.c [moved from src/mesa/main/tests/hash_table/insert_many.c with 100% similarity]
src/util/tests/hash_table/null_destroy.c [moved from src/mesa/main/tests/hash_table/null_destroy.c with 100% similarity]
src/util/tests/hash_table/random_entry.c [moved from src/mesa/main/tests/hash_table/random_entry.c with 100% similarity]
src/util/tests/hash_table/remove_null.c [moved from src/mesa/main/tests/hash_table/remove_null.c with 100% similarity]
src/util/tests/hash_table/replacement.c [moved from src/mesa/main/tests/hash_table/replacement.c with 100% similarity]

index b2b61c7..a3b3abd 100644 (file)
@@ -2279,9 +2279,9 @@ AC_CONFIG_FILES([Makefile
                src/mesa/drivers/osmesa/osmesa.pc
                src/mesa/drivers/x11/Makefile
                src/mesa/main/tests/Makefile
-               src/mesa/main/tests/hash_table/Makefile
                src/util/Makefile
-               src/util/tests/Makefile])
+               src/util/tests/Makefile
+               src/util/tests/hash_table/Makefile])
 
 dnl Sort the dirs alphabetically
 GALLIUM_TARGET_DIRS=`echo $GALLIUM_TARGET_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
index 292c8f7..2a20d11 100644 (file)
@@ -53,7 +53,6 @@ check_PROGRAMS =                                      \
 noinst_PROGRAMS = glsl_compiler
 
 tests_general_ir_test_SOURCES =                \
-       $(top_srcdir)/src/mesa/main/hash_table.c        \
        $(top_srcdir)/src/mesa/main/imports.c           \
        $(top_srcdir)/src/mesa/program/prog_hash_table.c\
        $(top_srcdir)/src/mesa/program/symbol_table.c   \
@@ -71,7 +70,6 @@ tests_general_ir_test_LDADD =                         \
        $(PTHREAD_LIBS)
 
 tests_uniform_initializer_test_SOURCES =               \
-       $(top_srcdir)/src/mesa/main/hash_table.c        \
        $(top_srcdir)/src/mesa/main/imports.c           \
        $(top_srcdir)/src/mesa/program/prog_hash_table.c\
        $(top_srcdir)/src/mesa/program/symbol_table.c   \
@@ -120,7 +118,6 @@ libglsl_la_SOURCES =                                        \
        $(LIBGLSL_FILES)
 
 glsl_compiler_SOURCES = \
-       $(top_srcdir)/src/mesa/main/hash_table.c \
        $(top_srcdir)/src/mesa/main/imports.c \
        $(top_srcdir)/src/mesa/program/prog_hash_table.c \
        $(top_srcdir)/src/mesa/program/symbol_table.c \
@@ -131,7 +128,6 @@ glsl_compiler_LDADD =                                       \
        $(PTHREAD_LIBS)
 
 glsl_test_SOURCES = \
-       $(top_srcdir)/src/mesa/main/hash_table.c \
        $(top_srcdir)/src/mesa/main/imports.c \
        $(top_srcdir)/src/mesa/program/prog_hash_table.c \
        $(top_srcdir)/src/mesa/program/symbol_table.c \
index d1d5993..847e962 100644 (file)
@@ -58,7 +58,6 @@ if env['msvc']:
 
 # Copy these files to avoid generation object files into src/mesa/program
 env.Prepend(CPPPATH = ['#src/mesa/main'])
-env.Command('hash_table.c', '#src/mesa/main/hash_table.c', Copy('$TARGET', '$SOURCE'))
 env.Command('imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', '$SOURCE'))
 # Copy these files to avoid generation object files into src/mesa/program
 env.Prepend(CPPPATH = ['#src/mesa/program'])
@@ -68,7 +67,6 @@ env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET'
 compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
 
 mesa_objs = env.StaticObject([
-    'hash_table.c',
     'imports.c',
     'prog_hash_table.c',
     'symbol_table.c',
index 923eb1a..f67fe67 100644 (file)
@@ -33,7 +33,7 @@
 #include "ir_visitor.h"
 #include "ir_variable_refcount.h"
 #include "glsl_types.h"
-#include "main/hash_table.h"
+#include "util/hash_table.h"
 
 ir_variable_refcount_visitor::ir_variable_refcount_visitor()
 {
index 524cd6b..64de826 100644 (file)
@@ -26,7 +26,7 @@
 #define LINK_UNIFORM_BLOCK_ACTIVE_VISITOR_H
 
 #include "ir.h"
-#include "main/hash_table.h"
+#include "util/hash_table.h"
 
 struct link_uniform_block_active {
    const glsl_type *type;
index fef3626..0b1291d 100644 (file)
@@ -26,7 +26,7 @@
 #include "linker.h"
 #include "ir_uniform.h"
 #include "link_uniform_block_active_visitor.h"
-#include "main/hash_table.h"
+#include "util/hash_table.h"
 #include "program.h"
 
 namespace {
index da90bfb..3df01b4 100644 (file)
@@ -31,7 +31,7 @@
 #include "ir_visitor.h"
 #include "ir_variable_refcount.h"
 #include "glsl_types.h"
-#include "main/hash_table.h"
+#include "util/hash_table.h"
 
 static bool debug = false;
 
index 8a04980..5ccce54 100644 (file)
@@ -57,7 +57,6 @@ MAIN_FILES = \
        $(SRCDIR)main/getstring.c \
        $(SRCDIR)main/glformats.c \
        $(SRCDIR)main/hash.c \
-       $(SRCDIR)main/hash_table.c \
        $(SRCDIR)main/hint.c \
        $(SRCDIR)main/histogram.c \
        $(SRCDIR)main/image.c \
index 0d1185b..13ef6dd 100644 (file)
@@ -32,7 +32,7 @@ extern "C" {
 
 #include <sys/types.h>
 
-#include "main/hash_table.h"
+#include "util/hash_table.h"
 #include "main/macros.h"
 #include "main/shaderobj.h"
 #include "main/fbobject.h"
index e43e18b..12bd452 100644 (file)
@@ -36,9 +36,9 @@
 #include "main/context.h"
 #include "main/teximage.h"
 #include "main/image.h"
-#include "main/hash_table.h"
 #include "main/set.h"
 #include "main/condrender.h"
+#include "util/hash_table.h"
 
 #include "swrast/swrast.h"
 #include "drivers/common/meta.h"
index aa0ff50..9cde1e0 100644 (file)
@@ -36,7 +36,7 @@
 #include "hash.h"
 #include "mtypes.h"
 #include "version.h"
-#include "hash_table.h"
+#include "util/hash_table.h"
 
 static mtx_t DynamicIDMutex = _MTX_INITIALIZER_NP;
 static GLuint NextDynamicID = 1;
index 674c29d..52095f7 100644 (file)
@@ -37,7 +37,7 @@
 #include "glheader.h"
 #include "imports.h"
 #include "hash.h"
-#include "hash_table.h"
+#include "util/hash_table.h"
 
 /**
  * Magic GLuint object name that gets stored outside of the struct hash_table.
index 85b9753..b4a5e70 100644 (file)
@@ -42,7 +42,6 @@
 #include "main/dispatch.h"
 #include "main/enums.h"
 #include "main/hash.h"
-#include "main/hash_table.h"
 #include "main/mtypes.h"
 #include "main/pipelineobj.h"
 #include "main/shaderapi.h"
@@ -53,6 +52,7 @@
 #include "program/prog_print.h"
 #include "program/prog_parameter.h"
 #include "util/ralloc.h"
+#include "util/hash_table.h"
 #include <stdbool.h>
 #include "../glsl/glsl_parser_extras.h"
 #include "../glsl/ir.h"
index 5ae7014..0189dd2 100644 (file)
@@ -30,7 +30,6 @@
 #include "imports.h"
 #include "mtypes.h"
 #include "hash.h"
-#include "hash_table.h"
 #include "atifragshader.h"
 #include "bufferobj.h"
 #include "shared.h"
@@ -42,6 +41,7 @@
 #include "shaderobj.h"
 #include "syncobj.h"
 
+#include "util/hash_table.h"
 
 /**
  * Allocate and initialize a shared context state structure.
index a88d7e4..225399e 100644 (file)
@@ -64,7 +64,7 @@
 #include "dispatch.h"
 #include "mtypes.h"
 #include "set.h"
-#include "hash_table.h"
+#include "util/hash_table.h"
 
 #include "syncobj.h"
 
index 3c7c1b5..251474d 100644 (file)
@@ -1,5 +1,3 @@
-SUBDIRS = hash_table
-
 AM_CFLAGS = \
        $(X11_CFLAGS) \
        $(PTHREAD_CFLAGS)
index 975b812..e1c3e00 100644 (file)
@@ -32,9 +32,9 @@
  */
 
 #include <stdbool.h>
+#include "util/hash_table.h"
 #include "context.h"
 #include "glformats.h"
-#include "hash_table.h"
 #include "set.h"
 #include "texobj.h"
 #include "teximage.h"
index 1ed70c2..0f9dcab 100644 (file)
@@ -28,6 +28,7 @@ noinst_LTLIBRARIES = libmesautil.la
 libmesautil_la_CPPFLAGS = \
        $(DEFINES) \
        -I$(top_srcdir)/include \
+       -I$(top_srcdir)/src/mapi \
        -I$(top_srcdir)/src/mesa \
        $(VISIBILITY_CFLAGS)
 
index c4c79ca..5daa731 100644 (file)
@@ -1,2 +1,3 @@
-MESA_UTIL_FILES := \
+MESA_UTIL_FILES :=     \
+       hash_table.c    \
        ralloc.c
index 9653ef6..a36340d 100644 (file)
@@ -8,6 +8,7 @@ env = env.Clone()
 
 env.Prepend(CPPPATH = [
     '#include',
+    '#src/mapi',
     '#src/mesa',
     '#src/util',
 ])
similarity index 99%
rename from src/mesa/main/hash_table.c
rename to src/util/hash_table.c
index b51dada..f98a1a6 100644 (file)
@@ -43,9 +43,9 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "main/hash_table.h"
+#include "hash_table.h"
 #include "main/macros.h"
-#include "util/ralloc.h"
+#include "ralloc.h"
 
 static const uint32_t deleted_key_value;
 
similarity index 99%
rename from src/mesa/main/hash_table.h
rename to src/util/hash_table.h
index f51131a..5fa5899 100644 (file)
@@ -31,7 +31,7 @@
 #include <inttypes.h>
 #include <stdbool.h>
 
-#include "compiler.h"
+#include "main/compiler.h"
 
 #ifdef __cplusplus
 extern "C" {
index a2b5498..8ec8c3a 100644 (file)
@@ -19,6 +19,8 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
+SUBDIRS = hash_table
+
 AM_CFLAGS = \
        $(PTHREAD_CFLAGS)
 AM_CPPFLAGS = \
similarity index 96%
rename from src/mesa/main/tests/hash_table/Makefile.am
rename to src/util/tests/hash_table/Makefile.am
index 0330ebb..55cc0b7 100644 (file)
@@ -20,6 +20,8 @@
 
 AM_CPPFLAGS = \
        -I$(top_srcdir)/include \
+       -I$(top_srcdir)/src/util \
+       -I$(top_srcdir)/src/mesa \
        -I$(top_srcdir)/src/mesa/main \
        $(DEFINES) $(INCLUDE_DIRS)