summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2000-04-22 21:19:41 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2000-04-22 21:19:41 (GMT)
commitb0f996f5fb38997184e2ef5a9fcb6d4199c8fdc8 (patch)
treeaa093da68d6ef4cf0fa6c41ef714256d3077f36c
parent932d6e38044794866b9405d95788b23c8c2f4b92 (diff)
downloadhdf5-b0f996f5fb38997184e2ef5a9fcb6d4199c8fdc8.zip
hdf5-b0f996f5fb38997184e2ef5a9fcb6d4199c8fdc8.tar.gz
hdf5-b0f996f5fb38997184e2ef5a9fcb6d4199c8fdc8.tar.bz2
[svn-r2191] Changed hash function for caching to avoid as many hash clashes.
-rw-r--r--src/H5Distore.c23
-rw-r--r--src/H5Fistore.c23
2 files changed, 16 insertions, 30 deletions
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 17102f9..b0f7a39 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -175,16 +175,10 @@ H5B_class_t H5B_ISTORE[1] = {{
H5F_istore_debug_key, /*debug */
}};
-#define H5F_MIXUP(X) { \
- (X) += (X)<<12; \
- (X) ^= (X)>>22; \
- (X) += (X)<<4; \
- (X) ^= (X)>>9; \
- (X) += (X)<<10; \
- (X) ^= (X)>>2; \
- (X) += (X)<<7; \
- (X) ^= (X)>>12; \
-}
+#define H5F_HASH_DIVISOR 8 /* Attempt to spread out the hashing */
+ /* This should be the same size as the alignment of */
+ /* of the smallest file format object written to the file. */
+#define H5F_HASH(F,ADDR) H5F_addr_hash((ADDR/H5F_HASH_DIVISOR),(F)->shared->rdcc.nslots)
/* Declare a free list to manage the chunk information */
@@ -1348,13 +1342,12 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
if (rdcc->nslots>0) {
/* We don't care about loss of precision in the following statement. */
- idx = (uintn)(layout->addr);
- H5F_MIXUP(idx);
- for (i=0; i<layout->ndims; i++) {
+ for (i=0, idx=0; i<layout->ndims; i++) {
+ idx *= layout->dim[i];
idx += offset[i];
- H5F_MIXUP(idx);
}
- idx %= rdcc->nslots;
+ idx += (uintn)(layout->addr);
+ idx=H5F_HASH(f,idx);
ent = rdcc->slot[idx];
if (ent &&
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index 17102f9..b0f7a39 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -175,16 +175,10 @@ H5B_class_t H5B_ISTORE[1] = {{
H5F_istore_debug_key, /*debug */
}};
-#define H5F_MIXUP(X) { \
- (X) += (X)<<12; \
- (X) ^= (X)>>22; \
- (X) += (X)<<4; \
- (X) ^= (X)>>9; \
- (X) += (X)<<10; \
- (X) ^= (X)>>2; \
- (X) += (X)<<7; \
- (X) ^= (X)>>12; \
-}
+#define H5F_HASH_DIVISOR 8 /* Attempt to spread out the hashing */
+ /* This should be the same size as the alignment of */
+ /* of the smallest file format object written to the file. */
+#define H5F_HASH(F,ADDR) H5F_addr_hash((ADDR/H5F_HASH_DIVISOR),(F)->shared->rdcc.nslots)
/* Declare a free list to manage the chunk information */
@@ -1348,13 +1342,12 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
if (rdcc->nslots>0) {
/* We don't care about loss of precision in the following statement. */
- idx = (uintn)(layout->addr);
- H5F_MIXUP(idx);
- for (i=0; i<layout->ndims; i++) {
+ for (i=0, idx=0; i<layout->ndims; i++) {
+ idx *= layout->dim[i];
idx += offset[i];
- H5F_MIXUP(idx);
}
- idx %= rdcc->nslots;
+ idx += (uintn)(layout->addr);
+ idx=H5F_HASH(f,idx);
ent = rdcc->slot[idx];
if (ent &&