From f77369086ced2a76dd33358d28b7bb0706b1157f Mon Sep 17 00:00:00 2001 From: Anthony Pesch Date: Thu, 16 Jan 2020 09:11:16 -0500 Subject: [PATCH] util/hash_table: update users to use new optimal integer hash functions Reviewed-by: Eric Anholt Reviewed-by: Iago Toral Quiroga Tested-by: Marge Bot Part-of: --- src/broadcom/compiler/vir_live_variables.c | 14 +------------- src/etnaviv/drm/etnaviv_device.c | 16 ++-------------- src/freedreno/drm/freedreno_device.c | 17 ++--------------- src/gallium/drivers/iris/iris_bufmgr.c | 16 ++-------------- .../drivers/vc4/vc4_qir_live_variables.c | 14 +------------- src/mesa/drivers/dri/i965/brw_bufmgr.c | 16 ++-------------- 6 files changed, 10 insertions(+), 83 deletions(-) diff --git a/src/broadcom/compiler/vir_live_variables.c b/src/broadcom/compiler/vir_live_variables.c index d3ca02f1882..48d0201dc49 100644 --- a/src/broadcom/compiler/vir_live_variables.c +++ b/src/broadcom/compiler/vir_live_variables.c @@ -33,18 +33,6 @@ struct partial_update_state { uint8_t channels; }; -static uint32_t -int_hash(const void *key) -{ - return _mesa_hash_data(key, sizeof(int)); -} - -static bool -int_compare(const void *key1, const void *key2) -{ - return *(const int *)key1 == *(const int *)key2; -} - static int vir_reg_to_var(struct qreg reg) { @@ -197,7 +185,7 @@ static void vir_setup_def_use(struct v3d_compile *c) { struct hash_table *partial_update_ht = - _mesa_hash_table_create(c, int_hash, int_compare); + _mesa_hash_table_create(c, _mesa_hash_int, _mesa_key_int_equal); int ip = 0; vir_for_each_block(block, c) { diff --git a/src/etnaviv/drm/etnaviv_device.c b/src/etnaviv/drm/etnaviv_device.c index 32991d0a5b3..b1fc6b91c89 100644 --- a/src/etnaviv/drm/etnaviv_device.c +++ b/src/etnaviv/drm/etnaviv_device.c @@ -31,18 +31,6 @@ static pthread_mutex_t etna_drm_table_lock = PTHREAD_MUTEX_INITIALIZER; -static uint32_t -u32_hash(const void *key) -{ - return _mesa_hash_data(key, sizeof(uint32_t)); -} - -static bool -u32_equals(const void *key1, const void *key2) -{ - return *(const uint32_t *)key1 == *(const uint32_t *)key2; -} - struct etna_device *etna_device_new(int fd) { struct etna_device *dev = calloc(sizeof(*dev), 1); @@ -56,8 +44,8 @@ struct etna_device *etna_device_new(int fd) p_atomic_set(&dev->refcnt, 1); dev->fd = fd; - dev->handle_table = _mesa_hash_table_create(NULL, u32_hash, u32_equals); - dev->name_table = _mesa_hash_table_create(NULL, u32_hash, u32_equals); + dev->handle_table = _mesa_hash_table_create(NULL, _mesa_hash_u32, _mesa_key_u32_equal); + dev->name_table = _mesa_hash_table_create(NULL, _mesa_hash_u32, _mesa_key_u32_equal); etna_bo_cache_init(&dev->bo_cache); ret = drmCommandWriteRead(dev->fd, DRM_ETNAVIV_GET_PARAM, &req, sizeof(req)); diff --git a/src/freedreno/drm/freedreno_device.c b/src/freedreno/drm/freedreno_device.c index b2f6c981963..0a760bc4e38 100644 --- a/src/freedreno/drm/freedreno_device.c +++ b/src/freedreno/drm/freedreno_device.c @@ -33,19 +33,6 @@ static pthread_mutex_t table_lock = PTHREAD_MUTEX_INITIALIZER; -static uint32_t -u32_hash(const void *key) -{ - return _mesa_hash_data(key, sizeof(uint32_t)); -} - -static bool -u32_equals(const void *key1, const void *key2) -{ - return *(const uint32_t *)key1 == *(const uint32_t *)key2; -} - - struct fd_device * kgsl_device_new(int fd); struct fd_device * msm_device_new(int fd); @@ -90,8 +77,8 @@ out: p_atomic_set(&dev->refcnt, 1); dev->fd = fd; - dev->handle_table = _mesa_hash_table_create(NULL, u32_hash, u32_equals); - dev->name_table = _mesa_hash_table_create(NULL, u32_hash, u32_equals); + dev->handle_table = _mesa_hash_table_create(NULL, _mesa_hash_u32, _mesa_key_u32_equal); + dev->name_table = _mesa_hash_table_create(NULL, _mesa_hash_u32, _mesa_key_u32_equal); fd_bo_cache_init(&dev->bo_cache, FALSE); fd_bo_cache_init(&dev->ring_cache, TRUE); diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 167538d49c4..d0e641b2068 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -160,18 +160,6 @@ static uint64_t vma_alloc(struct iris_bufmgr *bufmgr, enum iris_memory_zone memzone, uint64_t size, uint64_t alignment); -static uint32_t -key_hash_uint(const void *key) -{ - return _mesa_hash_data(key, 4); -} - -static bool -key_uint_equal(const void *a, const void *b) -{ - return *((unsigned *) a) == *((unsigned *) b); -} - static struct iris_bo * find_and_ref_external_bo(struct hash_table *ht, unsigned int key) { @@ -1698,9 +1686,9 @@ iris_bufmgr_init(struct gen_device_info *devinfo, int fd, bool bo_reuse) init_cache_buckets(bufmgr); bufmgr->name_table = - _mesa_hash_table_create(NULL, key_hash_uint, key_uint_equal); + _mesa_hash_table_create(NULL, _mesa_hash_uint, _mesa_key_uint_equal); bufmgr->handle_table = - _mesa_hash_table_create(NULL, key_hash_uint, key_uint_equal); + _mesa_hash_table_create(NULL, _mesa_hash_uint, _mesa_key_uint_equal); if (devinfo->gen >= 12) { bufmgr->aux_map_ctx = gen_aux_map_init(bufmgr, &aux_map_allocator, diff --git a/src/gallium/drivers/vc4/vc4_qir_live_variables.c b/src/gallium/drivers/vc4/vc4_qir_live_variables.c index 5629ce044d9..61dc16915b7 100644 --- a/src/gallium/drivers/vc4/vc4_qir_live_variables.c +++ b/src/gallium/drivers/vc4/vc4_qir_live_variables.c @@ -34,18 +34,6 @@ struct partial_update_state { uint8_t channels; }; -static uint32_t -int_hash(const void *key) -{ - return _mesa_hash_data(key, sizeof(int)); -} - -static bool -int_compare(const void *key1, const void *key2) -{ - return *(const int *)key1 == *(const int *)key2; -} - static int qir_reg_to_var(struct qreg reg) { @@ -194,7 +182,7 @@ static void qir_setup_def_use(struct vc4_compile *c) { struct hash_table *partial_update_ht = - _mesa_hash_table_create(c, int_hash, int_compare); + _mesa_hash_table_create(c, _mesa_hash_int, _mesa_key_int_equal); int ip = 0; qir_for_each_block(block, c) { diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c index 536fe36e5e4..8c1a6a722f5 100644 --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c @@ -166,18 +166,6 @@ static uint64_t vma_alloc(struct brw_bufmgr *bufmgr, enum brw_memory_zone memzone, uint64_t size, uint64_t alignment); -static uint32_t -key_hash_uint(const void *key) -{ - return _mesa_hash_data(key, 4); -} - -static bool -key_uint_equal(const void *a, const void *b) -{ - return *((unsigned *) a) == *((unsigned *) b); -} - static struct brw_bo * hash_find_bo(struct hash_table *ht, unsigned int key) { @@ -1739,9 +1727,9 @@ brw_bufmgr_init(struct gen_device_info *devinfo, int fd, bool bo_reuse) init_cache_buckets(bufmgr); bufmgr->name_table = - _mesa_hash_table_create(NULL, key_hash_uint, key_uint_equal); + _mesa_hash_table_create(NULL, _mesa_hash_uint, _mesa_key_uint_equal); bufmgr->handle_table = - _mesa_hash_table_create(NULL, key_hash_uint, key_uint_equal); + _mesa_hash_table_create(NULL, _mesa_hash_uint, _mesa_key_uint_equal); return bufmgr; } -- 2.30.2