--- trunk/src/brains/BlockSnapshotManager.cpp 2014/01/24 13:53:41 1965 +++ trunk/src/brains/BlockSnapshotManager.cpp 2015/03/07 21:41:51 2071 @@ -53,8 +53,9 @@ namespace OpenMD { int storageLayout, long long int memSize, int blockCapacity) - : SnapshotManager(storageLayout), info_(info), memSize_(memSize), - blockCapacity_(blockCapacity), activeBlocks_(blockCapacity_, -1), + : SnapshotManager(storageLayout), info_(info), + blockCapacity_(blockCapacity), memSize_(memSize), + activeBlocks_(blockCapacity_, -1), activeRefCount_(blockCapacity_, 0) { nAtoms_ = info->getNGlobalAtoms(); @@ -68,8 +69,11 @@ namespace OpenMD { int bytesPerStuntDouble = DataStorage::getBytesPerStuntDouble(storageLayout); int bytesPerCutoffGroup = DataStorage::getBytesPerStuntDouble(DataStorage::dslPosition); + + int bytesPerFrameData = Snapshot::getFrameDataSize(); int bytesPerFrame = (nRigidBodies_ + nAtoms_) * bytesPerStuntDouble - + nCutoffGroups_ * bytesPerCutoffGroup; + + nCutoffGroups_ * bytesPerCutoffGroup + + bytesPerFrameData; // total number of frames that can fit in memory //RealType frameCapacity = avaliablePhysMem / bytesPerFrame; @@ -96,21 +100,33 @@ namespace OpenMD { snapshots_.insert(snapshots_.begin(), nframes_, static_cast(NULL)); - std::cout << "-----------------------------------------------------"<::iterator i = findActiveBlock(block); - bool loadSuccess; + bool loadSuccess(false); if (i != activeBlocks_.end()) { - //if block is already in memory, just increast the reference count + // If the block is already in memory, just increase the + // reference count: ++activeRefCount_[i - activeBlocks_.begin()]; loadSuccess = true; } else if (getNActiveBlocks() < blockCapacity_){ - //if number of active blocks is less than the block capacity, just load it + // If the number of active blocks is less than the block + // capacity, just load the block: internalLoad(block); loadSuccess = true; } else if ( hasZeroRefBlock() ) { - //if already reach the block capacity, need to unload a block with 0 reference + // If we have already reached the block capacity, we need to + // unload a block with 0 references: int zeroRefBlock = getFirstZeroRefBlock(); assert(zeroRefBlock != -1); internalUnload(zeroRefBlock); internalLoad(block); } else { - //reach the capacity and all blocks in memory are not zero reference + // We have reached capacity and all blocks in memory are have + // non-zero references: loadSuccess = false; - } - + } return loadSuccess; }