[MOAB-dev] r3442 - MOAB/trunk
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Tue Jan 19 18:45:55 CST 2010
Author: kraftche
Date: 2010-01-19 18:45:55 -0600 (Tue, 19 Jan 2010)
New Revision: 3442
Modified:
MOAB/trunk/BitTagServer.cpp
MOAB/trunk/BitTagServer.hpp
Log:
Fix bug in BitTagServer.
When re-writing BitTagServer, I initially used variable-sized bit pages
(as a function of bits per tag value.) It appears that I only partially
checked in the change to fixed-size pages. It is interesting (in an
unfortunate way) that this code worked as checked in.
Modified: MOAB/trunk/BitTagServer.cpp
===================================================================
--- MOAB/trunk/BitTagServer.cpp 2010-01-20 00:43:23 UTC (rev 3441)
+++ MOAB/trunk/BitTagServer.cpp 2010-01-20 00:45:55 UTC (rev 3442)
@@ -76,10 +76,17 @@
// store smallest power of two greater than or
// equal to the number of bits
storedBitsPerEntity = 1;
- pageShift = Ln2PageSize+1;
+ unsigned ln2storedbits = 0;
while (storedBitsPerEntity < bits) {
storedBitsPerEntity *= 2;
+ ++ln2storedbits;
}
+
+ // pageShift = log2( ents_per_page() )
+ // = log2( 8 * pageSize / storedBitsPerEntity )
+ // = log2(8) + log2(pageSize) - log2(storedBitsPerEntity)
+ // = 3 * Ln2PageSize - ln2storedbits;
+ pageShift = 3 + Ln2PageSize - ln2storedbits;
return MB_SUCCESS;
}
Modified: MOAB/trunk/BitTagServer.hpp
===================================================================
--- MOAB/trunk/BitTagServer.hpp 2010-01-20 00:43:23 UTC (rev 3441)
+++ MOAB/trunk/BitTagServer.hpp 2010-01-20 00:45:55 UTC (rev 3442)
@@ -259,7 +259,7 @@
std::vector<BitPage*> pageList[MBMAXTYPE]; //!< Array of BitPage instances storing actual data.
unsigned int requestedBitsPerEntity; //!< user-requested bits per entity
unsigned int storedBitsPerEntity; //!< allocated bits per entity (power of 2)
- unsigned int pageShift; //!< Ln2PageSize + log2(storedBitsPerEntity)
+ unsigned int pageShift; //!< log2( ents_per_page() )
/**\brief Get indices from handle
*
@@ -271,8 +271,8 @@
{
type = TYPE_FROM_HANDLE(h);
h = ID_FROM_HANDLE(h);
- page = ((size_t)h) >> pageShift; // h / (offset*storedBitsPerEntity)
- offset = h & ((1u<<pageShift)-1u); // h % (offset*storedBitsPerEntity)
+ page = ((size_t)h) >> pageShift; // h / ents_per_page()
+ offset = h & ((1u<<pageShift)-1u); // h % ends_per_page()
}
/**\brief Get the number of tag values that are stored in each BitPage */
More information about the moab-dev
mailing list