[svn-r2191] Changed hash function for caching to avoid as many hash clashes.

This commit is contained in:
Quincey Koziol 2000-04-22 16:19:41 -05:00
parent 932d6e3804
commit b0f996f5fb
2 changed files with 16 additions and 30 deletions

View File

@ -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 &&

View File

@ -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 &&