| 53 |  | int storageLayout, | 
| 54 |  | long long int memSize, | 
| 55 |  | int blockCapacity) | 
| 56 | < | : SnapshotManager(storageLayout), info_(info), memSize_(memSize), | 
| 57 | < | blockCapacity_(blockCapacity), activeBlocks_(blockCapacity_, -1), | 
| 56 | > | : SnapshotManager(storageLayout), info_(info), | 
| 57 | > | blockCapacity_(blockCapacity), memSize_(memSize), | 
| 58 | > | activeBlocks_(blockCapacity_, -1), | 
| 59 |  | activeRefCount_(blockCapacity_, 0) { | 
| 60 |  |  | 
| 61 |  | nAtoms_ = info->getNGlobalAtoms(); | 
| 68 |  | // RealType avaliablePhysMem = physMem - rssMem; | 
| 69 |  |  | 
| 70 |  | int bytesPerStuntDouble = DataStorage::getBytesPerStuntDouble(storageLayout); | 
| 71 | < | int bytesPerFrame = (nRigidBodies_ + nAtoms_) * bytesPerStuntDouble; | 
| 71 | > | int bytesPerCutoffGroup = DataStorage::getBytesPerStuntDouble(DataStorage::dslPosition); | 
| 72 |  |  | 
| 73 | + | int bytesPerFrameData = Snapshot::getFrameDataSize(); | 
| 74 | + | int bytesPerFrame = (nRigidBodies_ + nAtoms_) * bytesPerStuntDouble | 
| 75 | + | + nCutoffGroups_ * bytesPerCutoffGroup | 
| 76 | + | + bytesPerFrameData; | 
| 77 | + |  | 
| 78 |  | // total number of frames that can fit in memory | 
| 79 |  | //RealType frameCapacity = avaliablePhysMem / bytesPerFrame; | 
| 80 |  | RealType frameCapacity = (RealType) memSize_ / (RealType) bytesPerFrame; | 
| 100 |  |  | 
| 101 |  | snapshots_.insert(snapshots_.begin(), nframes_, static_cast<Snapshot*>(NULL)); | 
| 102 |  |  | 
| 103 | < | std::cout << "-----------------------------------------------------"<<std::endl; | 
| 103 | > | std::cout << "-----------------------------------------------------" | 
| 104 | > | << std::endl; | 
| 105 |  | std::cout << "BlockSnapshotManager memory report:" << std::endl; | 
| 106 |  | std::cout << "\n"; | 
| 107 |  | // std::cout << "  Physical Memory available:\t" << (unsigned long)physMem <<  " bytes" <<std::endl; | 
| 108 |  | //std::cout << "     Resident Memory in use:\t" << (unsigned long)rssMem << " bytes" <<std::endl; | 
| 109 |  | //std::cout << "Memory available for OpenMD:\t" << (unsigned long)avaliablePhysMem << " bytes" <<std::endl; | 
| 110 | < | std::cout << "Memory requested for OpenMD:\t" << (unsigned long)memSize_ << " bytes" <<std::endl; | 
| 111 | < | std::cout << "      Bytes per StuntDouble:\t" << (unsigned long)bytesPerStuntDouble <<std::endl; | 
| 112 | < | std::cout << "            Bytes per Frame:\t" << (unsigned long)bytesPerFrame <<std::endl; | 
| 113 | < | std::cout << "             Frame Capacity:\t" << (unsigned long)frameCapacity <<std::endl; | 
| 114 | < | std::cout << "       Frames in trajectory:\t" << (unsigned long)nframes_ <<std::endl; | 
| 115 | < | std::cout << "        Snapshots per Block:\t" << (unsigned long)nSnapshotPerBlock_ <<std::endl; | 
| 116 | < | std::cout << "     Total number of Blocks:\t" << (unsigned long)nblocks << std::endl; | 
| 117 | < | std::cout << "-----------------------------------------------------"<<std::endl; | 
| 110 | > | std::cout << "Memory requested for OpenMD:\t" | 
| 111 | > | << (unsigned long)memSize_ << " bytes" << std::endl; | 
| 112 | > | std::cout << "        Bytes per FrameData:\t" | 
| 113 | > | << (unsigned long)bytesPerFrameData << std::endl; | 
| 114 | > | std::cout << "      Bytes per StuntDouble:\t" | 
| 115 | > | << (unsigned long)bytesPerStuntDouble << std::endl; | 
| 116 | > | std::cout << "     Bytes per Cutoff Group:\t" | 
| 117 | > | << (unsigned long)bytesPerCutoffGroup << std::endl; | 
| 118 | > | std::cout << "            Bytes per Frame:\t" | 
| 119 | > | << (unsigned long)bytesPerFrame << std::endl; | 
| 120 | > | std::cout << "             Frame Capacity:\t" | 
| 121 | > | << (unsigned long)frameCapacity << std::endl; | 
| 122 | > | std::cout << "       Frames in trajectory:\t" | 
| 123 | > | << (unsigned long)nframes_ << std::endl; | 
| 124 | > | std::cout << "        Snapshots per Block:\t" | 
| 125 | > | << (unsigned long)nSnapshotPerBlock_ << std::endl; | 
| 126 | > | std::cout << "     Total number of Blocks:\t" | 
| 127 | > | << (unsigned long)nblocks << std::endl; | 
| 128 | > | std::cout << "-----------------------------------------------------" | 
| 129 | > | << std::endl; | 
| 130 |  |  | 
| 131 |  | } | 
| 132 |  |  | 
| 164 |  |  | 
| 165 |  | bool BlockSnapshotManager::loadBlock(int block) { | 
| 166 |  | std::vector<int>::iterator i = findActiveBlock(block); | 
| 167 | < | bool loadSuccess; | 
| 167 | > | bool loadSuccess(false); | 
| 168 |  | if (i != activeBlocks_.end()) { | 
| 169 | < | //if block is already in memory, just increast the reference count | 
| 169 | > | // If the block is already in memory, just increase the | 
| 170 | > | // reference count: | 
| 171 |  | ++activeRefCount_[i - activeBlocks_.begin()]; | 
| 172 |  | loadSuccess = true; | 
| 173 |  | } else if (getNActiveBlocks() < blockCapacity_){ | 
| 174 | < | //if number of active blocks is less than the block capacity, just load it | 
| 174 | > | // If the number of active blocks is less than the block | 
| 175 | > | // capacity, just load the block: | 
| 176 |  | internalLoad(block); | 
| 177 |  | loadSuccess = true; | 
| 178 |  | } else if ( hasZeroRefBlock() ) { | 
| 179 | < | //if already reach the block capacity, need to unload a block with 0 reference | 
| 179 | > | // If we have already reached the block capacity, we need to | 
| 180 | > | // unload a block with 0 references: | 
| 181 |  | int zeroRefBlock = getFirstZeroRefBlock(); | 
| 182 |  | assert(zeroRefBlock != -1); | 
| 183 |  | internalUnload(zeroRefBlock); | 
| 184 |  | internalLoad(block); | 
| 185 |  | } else { | 
| 186 | < | //reach the capacity and all blocks in memory are not zero reference | 
| 186 | > | // We have reached capacity and all blocks in memory are have | 
| 187 | > | // non-zero references: | 
| 188 |  | loadSuccess = false; | 
| 189 | < | } | 
| 167 | < |  | 
| 189 | > | } | 
| 190 |  | return loadSuccess; | 
| 191 |  | } | 
| 192 |  |  |