40 |
|
*/ |
41 |
|
#include <algorithm> |
42 |
|
#include "brains/BlockSnapshotManager.hpp" |
43 |
+ |
#include "utils/residentMem.h" |
44 |
|
#include "utils/physmem.h" |
45 |
|
#include "utils/Algorithm.hpp" |
46 |
|
#include "brains/SimInfo.hpp" |
55 |
|
nAtoms_ = info->getNGlobalAtoms(); |
56 |
|
nRigidBodies_ = info->getNGlobalRigidBodies(); |
57 |
|
|
58 |
< |
double avalPhysMem = physmem_available(); |
58 |
> |
double physMem = physmem_total(); |
59 |
> |
double rssMem = residentMem(); |
60 |
> |
double avaliablePhysMem = physMem - rssMem; |
61 |
|
|
62 |
|
int bytesPerStuntDouble = DataStorage::getBytesPerStuntDouble(storageLayout); |
63 |
|
|
64 |
|
int bytesPerFrame = (nRigidBodies_ + nAtoms_) * bytesPerStuntDouble; |
65 |
|
|
66 |
< |
int frameCapacity = int (avalPhysMem / bytesPerFrame); |
66 |
> |
int frameCapacity = int (avaliablePhysMem / bytesPerFrame); |
67 |
|
|
68 |
|
nSnapshotPerBlock_ = frameCapacity /blockCapacity_ ; |
66 |
– |
|
69 |
|
reader_ = new DumpReader(info, filename); |
70 |
|
nframes_ = reader_->getNFrames(); |
71 |
|
|
81 |
|
blocks_.back().second = nframes_; |
82 |
|
|
83 |
|
snapshots_.insert(snapshots_.begin(), nframes_, static_cast<Snapshot*>(NULL)); |
84 |
+ |
|
85 |
+ |
std::cout << "physmem = " << int(physMem) << "\trssMem = "<< int(rssMem) << "\t availablePhysMem = " << int(avaliablePhysMem) <<std::endl; |
86 |
+ |
std::cout << "nSnapshotPerBlock = " << nSnapshotPerBlock_ << "\t total block = " << nblocks << std::endl; |
87 |
|
|
88 |
|
} |
89 |
|
|
183 |
|
} |
184 |
|
|
185 |
|
bool BlockSnapshotManager::hasZeroRefBlock(){ |
186 |
< |
return std::find(activeRefCount_.begin(), activeRefCount_.end(), 0); |
186 |
> |
return std::find(activeRefCount_.begin(), activeRefCount_.end(), 0) != activeRefCount_.end() ? true : false; |
187 |
|
} |
188 |
|
|
189 |
|
int BlockSnapshotManager::getFirstZeroRefBlock(){ |